af_alg_get_rsgl() advances the receive iterator by the full RX scatterlist length. A non-final skcipher request then rounds that length down to a multiple of the cipher's chunksize without returning the unused suffix to the iterator. If the receive loop processes another request, it writes past that suffix even though the returned byte count includes only the processed lengths. The socket splice fallback can consequently publish uninitialized bytes from its newly allocated pages. Save the iterator before gathering the RX scatterlist. After processing the request and releasing its resources, restore the iterator and advance it only by the successfully processed length. This also leaves the iterator unchanged if gathering or processing the request fails. Keep the existing cipher request lengths, continuation flags and scatterlist cleanup unchanged. Fixes: e870456d8e7c ("crypto: algif_skcipher - overhaul memory management") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-6-astra Signed-off-by: Kyle Zeng --- crypto/algif_skcipher.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 1e61fe6e24b9..21d077a54dd5 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -107,6 +107,7 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg, struct alg_sock *pask = alg_sk(psk); struct af_alg_ctx *ctx = ask->private; struct crypto_skcipher *tfm = pask->private; + struct iov_iter saved_iter = msg->msg_iter; unsigned int bs = crypto_skcipher_chunksize(tfm); struct af_alg_async_req *areq; unsigned cflags = 0; @@ -193,6 +194,11 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg, free: af_alg_free_resources(areq); + /* The RX SGL may be longer than the request actually processed. */ + msg->msg_iter = saved_iter; + if (!err) + iov_iter_advance(&msg->msg_iter, len); + return err ? err : len; } base-commit: fd179f8a05be3ccae366b9b96e176b51fbe54aab -- 2.53.0