* [PATCH 6.1.y 0/2] tls: fix data disappearing from under the TLS ULP (CVE-2025-38616)
@ 2026-08-22 0:00 Artem Dinaburg
2026-08-22 0:00 ` [PATCH 6.1.y 1/2] tls: fix lockless read of strp->msg_ready in ->poll Artem Dinaburg
2026-08-22 0:00 ` [PATCH 6.1.y 2/2] tls: handle data disappearing from under the TLS ULP Artem Dinaburg
0 siblings, 2 replies; 3+ messages in thread
From: Artem Dinaburg @ 2026-08-22 0:00 UTC (permalink / raw)
To: stable
Cc: Sabrina Dubroca, Jakub Kicinski, Eric Dumazet, William Liu,
Savino Dicanosa, Boris Pismenny, John Fastabend, linux-kernel,
Artem Dinaburg
Please queue these two commits for 6.1.y.
Patch 2/2 is the fix for CVE-2025-38616. It is already present in every
other supported stable tree: 6.6.y since 6.6.103, 6.12.y since 6.12.43,
and 6.18.y and 7.1.y inherit it from v6.17. 6.1.y is the only supported
affected tree still missing it. The upstream commit carries no Cc: stable
trailer, which is why 6.1.y was left behind.
Patch 1/2 is a prerequisite. In 6.1.y strp->msg_ready is still a
bitfield, so the WRITE_ONCE() added by 2/2 does not compile there:
./include/asm-generic/rwonce.h:55:32: error: cannot take address of
bit-field 'msg_ready'
Backporting 0844370f8945 first converts the field to a bool, which lets
2/2 apply and build unmodified. 0844370f8945 also fixes a real bug that
6.1.y still has on its own: a lockless read of msg_ready in ->poll. It
is present in 6.6.y and later, so no newer stable tree regresses.
Both patches are verbatim upstream cherry-picks with no adaptation.
Verified on v6.1.183: both apply with no conflict, and net/tls builds
clean, including with CONFIG_DEBUG_NET=y.
CVE-2025-38616 was reproduced on a KASAN v6.1.182 build; the patched
kernel survived 1,000 rounds of the reproducer.
Jakub Kicinski (1):
tls: handle data disappearing from under the TLS ULP
Sabrina Dubroca (1):
tls: fix lockless read of strp->msg_ready in ->poll
include/net/tls.h | 3 ++-
net/tls/tls.h | 4 ++--
net/tls/tls_strp.c | 17 +++++++++++------
net/tls/tls_sw.c | 3 ++-
4 files changed, 17 insertions(+), 10 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 6.1.y 1/2] tls: fix lockless read of strp->msg_ready in ->poll
2026-08-22 0:00 [PATCH 6.1.y 0/2] tls: fix data disappearing from under the TLS ULP (CVE-2025-38616) Artem Dinaburg
@ 2026-08-22 0:00 ` Artem Dinaburg
2026-08-22 0:00 ` [PATCH 6.1.y 2/2] tls: handle data disappearing from under the TLS ULP Artem Dinaburg
1 sibling, 0 replies; 3+ messages in thread
From: Artem Dinaburg @ 2026-08-22 0:00 UTC (permalink / raw)
To: stable
Cc: Sabrina Dubroca, Jakub Kicinski, Eric Dumazet, William Liu,
Savino Dicanosa, Boris Pismenny, John Fastabend, linux-kernel,
Artem Dinaburg
From: Sabrina Dubroca <sd@queasysnail.net>
[ Upstream commit 0844370f8945086eb9335739d10205dcea8d707b ]
tls_sk_poll is called without locking the socket, and needs to read
strp->msg_ready (via tls_strp_msg_ready). Convert msg_ready to a bool
and use READ_ONCE/WRITE_ONCE where needed. The remaining reads are
only performed when the socket is locked.
Fixes: 121dca784fc0 ("tls: suppress wakeups unless we have a full record")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://lore.kernel.org/r/0b7ee062319037cf86af6b317b3d72f7bfcd2e97.1713797701.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Assisted-by: Codex:GPT-5
Signed-off-by: Artem Dinaburg <artem@trailofbits.com>
---
Prerequisite for 2/2, applied verbatim with no source adaptation. This
also fixes a real lockless read of msg_ready in ->poll that 6.1.y has
on its own.
include/net/tls.h | 3 ++-
net/tls/tls.h | 2 +-
net/tls/tls_strp.c | 6 +++---
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/net/tls.h b/include/net/tls.h
index 037049def..b5856a280 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -122,7 +122,8 @@ struct tls_strparser {
u32 stopped : 1;
u32 copy_mode : 1;
u32 mixed_decrypted : 1;
- u32 msg_ready : 1;
+
+ bool msg_ready;
struct strp_msg stm;
diff --git a/net/tls/tls.h b/net/tls/tls.h
index 8304afbe0..9fd5867a3 100644
--- a/net/tls/tls.h
+++ b/net/tls/tls.h
@@ -167,7 +167,7 @@ static inline struct sk_buff *tls_strp_msg(struct tls_sw_context_rx *ctx)
static inline bool tls_strp_msg_ready(struct tls_sw_context_rx *ctx)
{
- return ctx->strp.msg_ready;
+ return READ_ONCE(ctx->strp.msg_ready);
}
static inline bool tls_strp_msg_mixed_decrypted(struct tls_sw_context_rx *ctx)
diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c
index 850146ed2..32b57e574 100644
--- a/net/tls/tls_strp.c
+++ b/net/tls/tls_strp.c
@@ -366,7 +366,7 @@ static int tls_strp_copyin(read_descriptor_t *desc, struct sk_buff *in_skb,
if (strp->stm.full_len && strp->stm.full_len == skb->len) {
desc->count = 0;
- strp->msg_ready = 1;
+ WRITE_ONCE(strp->msg_ready, 1);
tls_rx_msg_ready(strp);
}
@@ -533,7 +533,7 @@ static int tls_strp_read_sock(struct tls_strparser *strp)
if (!tls_strp_check_queue_ok(strp))
return tls_strp_read_copy(strp, false);
- strp->msg_ready = 1;
+ WRITE_ONCE(strp->msg_ready, 1);
tls_rx_msg_ready(strp);
return 0;
@@ -585,7 +585,7 @@ void tls_strp_msg_done(struct tls_strparser *strp)
else
tls_strp_flush_anchor_copy(strp);
- strp->msg_ready = 0;
+ WRITE_ONCE(strp->msg_ready, 0);
memset(&strp->stm, 0, sizeof(strp->stm));
tls_strp_check_rcv(strp);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.1.y 2/2] tls: handle data disappearing from under the TLS ULP
2026-08-22 0:00 [PATCH 6.1.y 0/2] tls: fix data disappearing from under the TLS ULP (CVE-2025-38616) Artem Dinaburg
2026-08-22 0:00 ` [PATCH 6.1.y 1/2] tls: fix lockless read of strp->msg_ready in ->poll Artem Dinaburg
@ 2026-08-22 0:00 ` Artem Dinaburg
1 sibling, 0 replies; 3+ messages in thread
From: Artem Dinaburg @ 2026-08-22 0:00 UTC (permalink / raw)
To: stable
Cc: Sabrina Dubroca, Jakub Kicinski, Eric Dumazet, William Liu,
Savino Dicanosa, Boris Pismenny, John Fastabend, linux-kernel,
Artem Dinaburg
From: Jakub Kicinski <kuba@kernel.org>
[ Upstream commit 6db015fc4b5d5f63a64a193f65d98da3a7fc811d ]
TLS expects that it owns the receive queue of the TCP socket.
This cannot be guaranteed in case the reader of the TCP socket
entered before the TLS ULP was installed, or uses some non-standard
read API (eg. zerocopy ones). Replace the WARN_ON() and a buggy
early exit (which leaves anchor pointing to a freed skb) with real
error handling. Wipe the parsing state and tell the reader to retry.
We already reload the anchor every time we (re)acquire the socket lock,
so the only condition we need to avoid is an out of bounds read
(not having enough bytes in the socket for previously parsed record len).
If some data was read from under TLS but there's enough in the queue
we'll reload and decrypt what is most likely not a valid TLS record.
Leading to some undefined behavior from TLS perspective (corrupting
a stream? missing an alert? missing an attack?) but no kernel crash
should take place.
Reported-by: William Liu <will@willsroot.io>
Reported-by: Savino Dicanosa <savy@syst3mfailure.io>
Link: https://lore.kernel.org/tFjq_kf7sWIG3A7CrCg_egb8CVsT_gsmHAK0_wxDPJXfIzxFAMxqmLwp3MlU5EHiet0AwwJldaaFdgyHpeIUCS-3m3llsmRzp9xIOBR4lAI=@syst3mfailure.io
Fixes: 84c61fe1a75b ("tls: rx: do not use the standard strparser")
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250807232907.600366-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Assisted-by: Codex:GPT-5
Signed-off-by: Artem Dinaburg <artem@trailofbits.com>
---
The CVE-2025-38616 fix, applied verbatim with no source adaptation.
Patch 1/2 supplies the bool msg_ready that this patch's WRITE_ONCE()
requires.
net/tls/tls.h | 2 +-
net/tls/tls_strp.c | 11 ++++++++---
net/tls/tls_sw.c | 3 ++-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/net/tls/tls.h b/net/tls/tls.h
index 9fd5867a3..c1be90019 100644
--- a/net/tls/tls.h
+++ b/net/tls/tls.h
@@ -147,7 +147,7 @@ void tls_strp_msg_done(struct tls_strparser *strp);
int tls_rx_msg_size(struct tls_strparser *strp, struct sk_buff *skb);
void tls_rx_msg_ready(struct tls_strparser *strp);
-void tls_strp_msg_load(struct tls_strparser *strp, bool force_refresh);
+bool tls_strp_msg_load(struct tls_strparser *strp, bool force_refresh);
int tls_strp_msg_cow(struct tls_sw_context_rx *ctx);
struct sk_buff *tls_strp_msg_detach(struct tls_sw_context_rx *ctx);
int tls_strp_msg_hold(struct tls_strparser *strp, struct sk_buff_head *dst);
diff --git a/net/tls/tls_strp.c b/net/tls/tls_strp.c
index 32b57e574..be8a79960 100644
--- a/net/tls/tls_strp.c
+++ b/net/tls/tls_strp.c
@@ -481,7 +481,7 @@ static void tls_strp_load_anchor_with_queue(struct tls_strparser *strp, int len)
strp->stm.offset = offset;
}
-void tls_strp_msg_load(struct tls_strparser *strp, bool force_refresh)
+bool tls_strp_msg_load(struct tls_strparser *strp, bool force_refresh)
{
struct strp_msg *rxm;
struct tls_msg *tlm;
@@ -490,8 +490,11 @@ void tls_strp_msg_load(struct tls_strparser *strp, bool force_refresh)
DEBUG_NET_WARN_ON_ONCE(!strp->stm.full_len);
if (!strp->copy_mode && force_refresh) {
- if (WARN_ON(tcp_inq(strp->sk) < strp->stm.full_len))
- return;
+ if (unlikely(tcp_inq(strp->sk) < strp->stm.full_len)) {
+ WRITE_ONCE(strp->msg_ready, 0);
+ memset(&strp->stm, 0, sizeof(strp->stm));
+ return false;
+ }
tls_strp_load_anchor_with_queue(strp, strp->stm.full_len);
}
@@ -501,6 +504,8 @@ void tls_strp_msg_load(struct tls_strparser *strp, bool force_refresh)
rxm->offset = strp->stm.offset;
tlm = tls_msg(strp->anchor);
tlm->control = strp->mark;
+
+ return true;
}
/* Called with lock held on lower socket */
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 5eec7c10a..c923b7dc6 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1510,7 +1510,8 @@ tls_rx_rec_wait(struct sock *sk, struct sk_psock *psock, bool nonblock,
return sock_intr_errno(timeo);
}
- tls_strp_msg_load(&ctx->strp, released);
+ if (unlikely(!tls_strp_msg_load(&ctx->strp, released)))
+ return tls_rx_rec_wait(sk, psock, nonblock, false);
return 1;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-22 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-22 0:00 [PATCH 6.1.y 0/2] tls: fix data disappearing from under the TLS ULP (CVE-2025-38616) Artem Dinaburg
2026-08-22 0:00 ` [PATCH 6.1.y 1/2] tls: fix lockless read of strp->msg_ready in ->poll Artem Dinaburg
2026-08-22 0:00 ` [PATCH 6.1.y 2/2] tls: handle data disappearing from under the TLS ULP Artem Dinaburg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox