[lvc-project] [PATCH 5.10/5.15] crypto: af_alg - Set merge to zero early in af_alg_sendmsg
Mikhail Dmitrichenko
mdmitrichenko at astralinux.ru
Wed Jul 1 19:01:21 MSK 2026
From: Herbert Xu <herbert at gondor.apana.org.au>
commit 9574b2330dbd2b5459b74d3b5e9619d39299fc6f upstream.
If an error causes af_alg_sendmsg to abort, ctx->merge may contain
a garbage value from the previous loop. This may then trigger a
crash on the next entry into af_alg_sendmsg when it attempts to do
a merge that can't be done.
Fix this by setting ctx->merge to zero near the start of the loop.
Fixes: 8ff590903d5 ("crypto: algif_skcipher - User-space interface for skcipher operations")
Reported-by: Muhammad Alifa Ramdhan <ramdhan at starlabs.sg>
Reported-by: Bing-Jhong Billy Jheng <billy at starlabs.sg>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Mikhail Dmitrichenko <mdmitrichenko at astralinux.ru>
---
Backport fix for CVE-2025-39931
crypto/af_alg.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index b66a1681692d6..bbd47d04f89dc 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -892,6 +892,8 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
continue;
}
+ ctx->merge = 0;
+
if (!af_alg_writable(sk)) {
err = af_alg_wait_for_wmem(sk, msg->msg_flags);
if (err)
--
2.47.3
More information about the lvc-project
mailing list