]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
crypto: af_alg - Fix regression on empty requests
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 2 Jul 2020 03:32:21 +0000 (13:32 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:05:31 +0000 (13:05 +0200)
[ Upstream commit 662bb52f50bca16a74fe92b487a14d7dccb85e1a ]

Some user-space programs rely on crypto requests that have no
control metadata.  This broke when a check was added to require
the presence of control metadata with the ctx->init flag.

This patch fixes the regression by setting ctx->init as long as
one sendmsg(2) has been made, with or without a control message.

Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
crypto/af_alg.c

index ed8ace8675b776c642f1ea337ec4456e81fc6dec..35e026ba2c7edc4964f01ab0e38f39d9c363d13c 100644 (file)
@@ -851,6 +851,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
                err = -EINVAL;
                goto unlock;
        }
+       ctx->init = true;
 
        if (init) {
                ctx->enc = enc;
@@ -858,7 +859,6 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
                        memcpy(ctx->iv, con.iv->iv, ivsize);
 
                ctx->aead_assoclen = con.aead_assoclen;
-               ctx->init = true;
        }
 
        while (size) {