FAILED: patch "[PATCH] tcp: prevent collapsing skbs across boundary in rtx queue" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-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 <[email protected]>.
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-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x fc6d80eb504458d6416b75a94188b268c95c6533
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092928-skewer-abiding-df9a@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From fc6d80eb504458d6416b75a94188b268c95c6533 Mon Sep 17 00:00:00 2001
From: Willem de Bruijn <[email protected]>
Date: Thu, 24 Sep 2026 11:44:12 -0400
Subject: [PATCH] tcp: prevent collapsing skbs across boundary in rtx queue
tcp_write_collapse_fence() sets TCP_SKB_CB(skb)->eor = 1 on tcp_write_queue_tail(sk) to prevent skbs queued after a switch to device encryption from being collapsed into earlier skbs.
The fence is a no-op if all earlier data has already been transmitted when the switch happens: sk->sk_write_queue is empty. The not yet acknowledged earlier skbs wait in sk->tcp_rtx_queue with eor 0.
On a subsequent retransmit or SACK shift, tcp_retrans_try_collapse() or tcp_shift_skb_data() can then merge an skb queued after the switch into one queued before it.
Both users of the fence are affected:
- psp: devices only encrypt skbs with skb->decrypted set. The merged skb keeps decrypted = 0 from the earlier skb, so merged data sent after psp_sock_assoc_set_tx() is retransmitted in cleartext.
- tls device offload: the merged skb straddles the start marker set in tls_set_device_offload(). The software fallback (fill_sg_in() returns -EINVAL) and the mlx5, nfp and funeth drivers cannot handle such an skb and drop it. Every retransmit rebuilds the same skb, so the connection stalls.
Fix this in two places, for defense in depth:
1. Fall back to tcp_rtx_queue_tail(sk) in tcp_write_collapse_fence() when tcp_write_queue_tail(sk) is NULL.
2. Check !skb_cmp_decrypted(to, from) in tcp_skb_can_collapse(), as tcp_skb_can_collapse_rx() does on receive. skb_shift(), which both collapse paths call, already has a DEBUG_NET_WARN_ON_ONCE() for this condition.
include/net/tcp.h +2 -2
@@ -1232,9 +1232,9 @@ static inline bool tcp_skb_can_collapse_to(const struct sk_buff *skb)static inline bool tcp_skb_can_collapse (const struct sk_buff *to,const struct sk_buff *from) { -/* skb_cmp_decrypted() not needed, use tcp_write_collapse_fence() */ return likely (tcp_skb_can_collapse_to (to) &&mptcp_skb_can_collapse (to, from) && + !skb_cmp_decrypted (to, from) &&skb_pure_zcopy_same (to, from) &&skb_frags_readable (to) ==skb_frags_readable (from)); }
@@ -2327,7 +2327,7 @@ static inline void tcp_rtx_queue_unlink_and_free(struct sk_buff *skb, struct socstatic inline void tcp_write_collapse_fence (struct sock *sk) { -struct sk_buff *skb =tcp_write_queue_tail (sk); +struct sk_buff *skb =tcp_write_queue_tail (sk) ?:tcp_rtx_queue_tail (sk);if (skb)TCP_SKB_CB (skb)->eor =1 ;
Sasha Levin
maintainerPATCH 1/1 tcp: prevent collapsing skbs across boundary in rtx queue
From: Willem de Bruijn <[email protected]>
[ Upstream commit fc6d80eb504458d6416b75a94188b268c95c6533 ]
tcp_write_collapse_fence() sets TCP_SKB_CB(skb)->eor = 1 on tcp_write_queue_tail(sk) to prevent skbs queued after a switch to device encryption from being collapsed into earlier skbs.
The fence is a no-op if all earlier data has already been transmitted when the switch happens: sk->sk_write_queue is empty. The not yet acknowledged earlier skbs wait in sk->tcp_rtx_queue with eor 0.
On a subsequent retransmit or SACK shift, tcp_retrans_try_collapse() or tcp_shift_skb_data() can then merge an skb queued after the switch into one queued before it.
Both users of the fence are affected:
- psp: devices only encrypt skbs with skb->decrypted set. The merged skb keeps decrypted = 0 from the earlier skb, so merged data sent after psp_sock_assoc_set_tx() is retransmitted in cleartext.
- tls device offload: the merged skb straddles the start marker set in tls_set_device_offload(). The software fallback (fill_sg_in() returns -EINVAL) and the mlx5, nfp and funeth drivers cannot handle such an skb and drop it. Every retransmit rebuilds the same skb, so the connection stalls.
Fix this in two places, for defense in depth:
1. Fall back to tcp_rtx_queue_tail(sk) in tcp_write_collapse_fence() when tcp_write_queue_tail(sk) is NULL.
2. Check !skb_cmp_decrypted(to, from) in tcp_skb_can_collapse(), as tcp_skb_can_collapse_rx() does on receive. skb_shift(), which both collapse paths call, already has a DEBUG_NET_WARN_ON_ONCE() for this condition.
--- include/net/tcp.h | 4 ++++ net/tls/tls_device.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
include/net/tcp.h +4 -0
@@ -988,6 +988,10 @@ static inline bool tcp_skb_can_collapse_to(const struct sk_buff *skb)static inline bool tcp_skb_can_collapse (const struct sk_buff *to,const struct sk_buff *from) { +#ifdef CONFIG_TLS_DEVICE +if (from->decrypted != to->decrypted) +return false; +#endif return likely (tcp_skb_can_collapse_to (to) &&mptcp_skb_can_collapse (to, from)); }
net/tls/tls_device.c +2 -2
@@ -225,7 +225,7 @@ static void tls_device_resync_tx(struct sock *sk, struct tls_context *tls_ctx,int err =0 ;u8 *rcd_sn; - skb =tcp_write_queue_tail (sk); + skb =tcp_write_queue_tail (sk) ?:tcp_rtx_queue_tail (sk);if (skb)TCP_SKB_CB (skb)->eor =1 ;
@@ -1118,7 +1118,7 @@ int tls_set_device_offload(struct sock *sk, struct tls_context *ctx)* SKBs where only part of the payload needs to be encrypted. * So mark the last skb in the write queue as end of record. */ - skb =tcp_write_queue_tail (sk); + skb =tcp_write_queue_tail (sk) ?:tcp_rtx_queue_tail (sk);if (skb)TCP_SKB_CB (skb)->eor =1 ;
Signature · 1 line
2.53.0