The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 5.10/5.15] crypto: af_alg - Set merge to zero early in af_alg_sendmsg
@ 2026-07-01 16:01 Mikhail Dmitrichenko
  2026-07-02  0:38 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Mikhail Dmitrichenko @ 2026-07-01 16:01 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Mikhail Dmitrichenko, Herbert Xu, David S. Miller, linux-crypto,
	linux-kernel, lvc-project, Muhammad Alifa Ramdhan,
	Bing-Jhong Billy Jheng

From: Herbert Xu <herbert@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@starlabs.sg>
Reported-by: Bing-Jhong Billy Jheng <billy@starlabs.sg>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Mikhail Dmitrichenko <mdmitrichenko@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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5.10/5.15] crypto: af_alg - Set merge to zero early in af_alg_sendmsg
  2026-07-01 16:01 [PATCH 5.10/5.15] crypto: af_alg - Set merge to zero early in af_alg_sendmsg Mikhail Dmitrichenko
@ 2026-07-02  0:38 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-07-02  0:38 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Sasha Levin, Mikhail Dmitrichenko, Herbert Xu, David S. Miller,
	linux-crypto, linux-kernel, lvc-project, Muhammad Alifa Ramdhan,
	Bing-Jhong Billy Jheng

> 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.

Queued for 5.15.y and 5.10.y, thanks.

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-02  0:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 16:01 [PATCH 5.10/5.15] crypto: af_alg - Set merge to zero early in af_alg_sendmsg Mikhail Dmitrichenko
2026-07-02  0:38 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox