From: Herbert Xu Date: Thu, 27 Aug 2020 07:14:36 +0000 (+1000) Subject: crypto: af_alg - Work around empty control messages without MSG_MORE X-Git-Tag: v5.15~2938^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c195d66a8a75c60515819b101975f38b7ec6577f;p=platform%2Fkernel%2Flinux-starfive.git crypto: af_alg - Work around empty control messages without MSG_MORE 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 Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...") Cc: Signed-off-by: Herbert Xu --- diff --git a/crypto/af_alg.c b/crypto/af_alg.c index a6f581a..8be8bec 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -845,9 +846,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;