From 37ddd6862db24d6c890992223dd52e3205cc9e38 Mon Sep 17 00:00:00 2001 From: Sabrina Dubroca Date: Tue, 25 Nov 2025 20:39:43 +0800 Subject: [PATCH] tls: wait for pending async decryptions if tls_strp_msg_hold fails stable inclusion from stable-v6.6.114 commit c61d4368197d65c4809d9271f3b85325a600586a category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/ID6BBY CVE: CVE-2025-40176 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c61d4368197d65c4809d9271f3b85325a600586a -------------------------------- [ Upstream commit b8a6ff84abbcbbc445463de58704686011edc8e1 ] Async decryption calls tls_strp_msg_hold to create a clone of the input skb to hold references to the memory it uses. If we fail to allocate that clone, proceeding with async decryption can lead to various issues (UAF on the skb, writing into userspace memory after the recv() call has returned). In this case, wait for all pending decryption requests. Fixes: 84c61fe1a75b ("tls: rx: do not use the standard strparser") Reported-by: Jann Horn Signed-off-by: Sabrina Dubroca Link: https://patch.msgid.link/b9fe61dcc07dab15da9b35cf4c7d86382a98caf2.1760432043.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Signed-off-by: Dong Chenchen --- net/tls/tls_sw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index bf445a518883..d7c1b7c1b1db 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1612,8 +1612,10 @@ static int tls_decrypt_sg(struct sock *sk, struct iov_iter *out_iov, if (unlikely(darg->async)) { err = tls_strp_msg_hold(&ctx->strp, &ctx->async_hold); - if (err) - __skb_queue_tail(&ctx->async_hold, darg->skb); + if (err) { + err = tls_decrypt_async_wait(ctx); + darg->async = false; + } return err; } -- Gitee