diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2026-07-01 19:01:21 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2026-07-04 13:38:39 +0200 |
| commit | 28f6f37abca7c5c9eb3959c66310f1d4d98b8aaf (patch) | |
| tree | e5fcdafb66a80e302fdbb4c49b58594ce476abd4 | |
| parent | 3462a3f0716d27af51896dc8688bcf0628fb17ee (diff) | |
| download | linux-stable-28f6f37abca7c5c9eb3959c66310f1d4d98b8aaf.tar.gz linux-stable-28f6f37abca7c5c9eb3959c66310f1d4d98b8aaf.zip | |
crypto: af_alg - Set merge to zero early in af_alg_sendmsg
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | crypto/af_alg.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 4983dd68578e..6acee8e0041a 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) |
