* FAILED: patch "[PATCH] crypto: algif_skcipher - rewind rounded output bytes" failed to apply to 6.1-stable tree
@ 2026-11-07 10:45 Sasha Levin
2026-11-10 12:50 ` [PATCH 6.1.y] crypto: algif_skcipher - rewind rounded output bytes Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2026-11-07 10:45 UTC (permalink / raw)
To: 4ncienth, herbert; +Cc: stable
The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 2f90facc7b94934653eb7ebfadcc25d503b89196
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '20261107054535-failed-6.1-2f90facc7b94@kernel.org' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 2f90facc7b94934653eb7ebfadcc25d503b89196 Mon Sep 17 00:00:00 2001
From: Daehyeon Ko <4ncienth@gmail.com>
Date: Sun, 4 Oct 2026 14:09:46 +0900
Subject: [PATCH] crypto: algif_skcipher - rewind rounded output bytes
af_alg_get_rsgl() advances the receive iterator by the unrounded RX
scatterlist length. For a continuing skcipher request,
_skcipher_recvmsg() then rounds its local length down to a whole chunksize
without restoring the iterator.
A later chunk starts after bytes which the provider never wrote, while the
syscall returns only the processed length. When copy_splice_read()
supplies non-zeroed pages and publishes that return as a dense prefix, the
gap exposes stale bytes from a previous page lifetime.
With unprivileged xts(aes), a 31-byte MSG_MORE request followed by one
final byte advances a 47-byte destination while returning 32 bytes. A
hardened v7.2-rc5 image retained all 15 seeded stale bytes in 4,829 of
4,829 records. With init_on_alloc enabled, all 72,345 gap bytes observed
were zero.
Rewind the iterator by the tail excluded during rounding, before rejecting
a zero processed length. The crypto request uses only the rounded length;
af_alg_free_resources() releases the entire RX list before another receive
iteration.
The fixed target-like kernel returned byte-identical dense 48-byte output
in 4,771 of 4,771 rounds. The unmodified kernel returned the vulnerable
32-byte short record in 2,409 of 2,409 rounds.
Fixes: e870456d8e7c ("crypto: algif_skcipher - overhaul memory management")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Daehyeon Ko <4ncienth@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
crypto/algif_skcipher.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 1e61fe6e24b99..291dbd6989325 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -135,12 +135,16 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
* full block size buffers.
*/
if (ctx->more || len < ctx->used) {
- if (len < bs) {
+ size_t excess = len % bs;
+
+ len -= excess;
+ iov_iter_revert(&msg->msg_iter, excess);
+
+ if (!len) {
err = -EINVAL;
goto free;
}
- len -= len % bs;
cflags |= CRYPTO_SKCIPHER_REQ_NOTFINAL;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 6.1.y] crypto: algif_skcipher - rewind rounded output bytes
2026-11-07 10:45 FAILED: patch "[PATCH] crypto: algif_skcipher - rewind rounded output bytes" failed to apply to 6.1-stable tree Sasha Levin
@ 2026-11-10 12:50 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-10 12:50 UTC (permalink / raw)
To: stable; +Cc: Daehyeon Ko, Herbert Xu, Sasha Levin
From: Daehyeon Ko <4ncienth@gmail.com>
[ Upstream commit 2f90facc7b94934653eb7ebfadcc25d503b89196 ]
af_alg_get_rsgl() advances the receive iterator by the unrounded RX
scatterlist length. For a continuing skcipher request,
_skcipher_recvmsg() then rounds its local length down to a whole chunksize
without restoring the iterator.
A later chunk starts after bytes which the provider never wrote, while the
syscall returns only the processed length. When copy_splice_read()
supplies non-zeroed pages and publishes that return as a dense prefix, the
gap exposes stale bytes from a previous page lifetime.
With unprivileged xts(aes), a 31-byte MSG_MORE request followed by one
final byte advances a 47-byte destination while returning 32 bytes. A
hardened v7.2-rc5 image retained all 15 seeded stale bytes in 4,829 of
4,829 records. With init_on_alloc enabled, all 72,345 gap bytes observed
were zero.
Rewind the iterator by the tail excluded during rounding, before rejecting
a zero processed length. The crypto request uses only the rounded length;
af_alg_free_resources() releases the entire RX list before another receive
iteration.
The fixed target-like kernel returned byte-identical dense 48-byte output
in 4,771 of 4,771 rounds. The unmodified kernel returned the vulnerable
32-byte short record in 2,409 of 2,409 rounds.
Fixes: e870456d8e7c ("crypto: algif_skcipher - overhaul memory management")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Daehyeon Ko <4ncienth@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[ sashal: Adjusted context to account for the missing CRYPTO_SKCIPHER_REQ_NOTFINAL assignment. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
crypto/algif_skcipher.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 0fe62be7470f2..c037c3969e9d6 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -83,12 +83,15 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
* full block size buffers.
*/
if (ctx->more || len < ctx->used) {
- if (len < bs) {
+ size_t excess = len % bs;
+
+ len -= excess;
+ iov_iter_revert(&msg->msg_iter, excess);
+
+ if (!len) {
err = -EINVAL;
goto free;
}
-
- len -= len % bs;
}
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-10 12:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 10:45 FAILED: patch "[PATCH] crypto: algif_skcipher - rewind rounded output bytes" failed to apply to 6.1-stable tree Sasha Levin
2026-11-10 12:50 ` [PATCH 6.1.y] crypto: algif_skcipher - rewind rounded output bytes Sasha Levin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.