Skip to content

Commit c195d66

Browse files
committed
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 <[email protected]> Fixes: f3c802a ("crypto: algif_aead - Only wake up when...") Cc: <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent bfe8fe9 commit c195d66

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

crypto/af_alg.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/module.h>
1717
#include <linux/net.h>
1818
#include <linux/rwsem.h>
19+
#include <linux/sched.h>
1920
#include <linux/sched/signal.h>
2021
#include <linux/security.h>
2122

@@ -845,9 +846,15 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
845846
}
846847

847848
lock_sock(sk);
848-
if (ctx->init && (init || !ctx->more)) {
849-
err = -EINVAL;
850-
goto unlock;
849+
if (ctx->init && !ctx->more) {
850+
if (ctx->used) {
851+
err = -EINVAL;
852+
goto unlock;
853+
}
854+
855+
pr_info_once(
856+
"%s sent an empty control message without MSG_MORE.\n",
857+
current->comm);
851858
}
852859
ctx->init = true;
853860

0 commit comments

Comments
 (0)