summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2020-08-27 17:14:36 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-03 11:27:05 +0200
commit5b8306512f81286d3b71a6c9a1539a5b1e5c3f9c (patch)
treecdbf0bb607204307b97c94609f3b73f594a6d535
parent23e6e070e003a0bf98bd4bad6f82aa19467c791d (diff)
downloadlinux-crypto-5b8306512f81286d3b71a6c9a1539a5b1e5c3f9c.tar.gz
linux-crypto-5b8306512f81286d3b71a6c9a1539a5b1e5c3f9c.zip
crypto: af_alg - Work around empty control messages without MSG_MORE
commit 113767ab58ba2b4430fa802ccafd7e4c04ae512b upstream. The iwd daemon uses libell which sets up the skcipher operation with two separate control messages. As the first control message is sent without MSG_MORE, it is interpreted as an empty request. While libell should be fixed to use MSG_MORE where appropriate, this patch works around the bug in the kernel so that existing binaries continue to work. We will print a warning however. A separate issue is that the new kernel code no longer allows the control message to be sent twice within the same request. This restriction is obviously incompatible with what iwd was doing (first setting an IV and then sending the real control message). This patch changes the kernel so that this is explicitly allowed. Reported-by: Caleb Jorden <caljorden@hotmail.com> Fixes: a52eb0489f96 ("crypto: algif_aead - Only wake up when...") Cc: <stable@vger.kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--crypto/af_alg.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 35e026ba..1d4b0157 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <linux/net.h>
#include <linux/rwsem.h>
+#include <linux/sched.h>
#include <linux/sched/signal.h>
#include <linux/security.h>
@@ -847,9 +848,15 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
}
lock_sock(sk);
- if (ctx->init && (init || !ctx->more)) {
- err = -EINVAL;
- goto unlock;
+ if (ctx->init && !ctx->more) {
+ if (ctx->used) {
+ err = -EINVAL;
+ goto unlock;
+ }
+
+ pr_info_once(
+ "%s sent an empty control message without MSG_MORE.\n",
+ current->comm);
}
ctx->init = true;