Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2 1/3] tls: device: keep tls_sw_fallback() from encrypting its own output
@ 2026-11-19 19:13 Rishikesh Jethwani
  2026-11-19 19:13 ` [PATCH net v2 2/3] selftests: net: py: add a bkg() timeout and kill the child when it expires Rishikesh Jethwani
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rishikesh Jethwani @ 2026-11-19 19:13 UTC (permalink / raw)
  To: netdev
  Cc: Rishikesh Jethwani, stable, John Fastabend, Jakub Kicinski,
	Sabrina Dubroca, David S. Miller, Eric Dumazet, Paolo Abeni,
	Simon Horman, Tariq Toukan, Alice Mikityanska

With a bond, each skb is validated at both the master and the slave.
tls_validate_xmit_skb() skips the master, but tls_validate_xmit_skb_sw(),
installed by tls_device_down(), runs tls_sw_fallback() both times. The
second pass re-encrypts the ciphertext with the same rcd_sn and IV,
cancelling the keystream and putting plaintext on the wire; for a
complete record it also computes a valid tag, so the peer accepts it.

Offload plaintext always has the decrypted bit set (tls_push_data() and
tls_device_write_space() send with MSG_SENDPAGE_DECRYPTED). Have
tls_sw_fallback() pass through skbs without it, and clear the bit in
complete_skb() so its output is not encrypted again.

This needs commit fc6d80eb5044 ("tcp: prevent collapsing skbs across
boundary in rtx queue"): otherwise a retransmit collapse can merge
offloaded data into a pre-offload skb with decrypted = 0, which would
now be sent in plaintext rather than dropped.

Tested over a single-slave mlx5 bond, bouncing the slave under an open
TLS 1.2 AES-GCM-128 socket.

Fixes: c55dcdd435aa ("net/tls: Fix use-after-free after the TLS device goes down and up")
Cc: <stable@vger.kernel.org> # 5.13.x: fc6d80eb5044: tcp: prevent collapsing skbs across boundary in rtx queue
Signed-off-by: Rishikesh Jethwani <rjethwani@purestorage.com>
---
 net/tls/tls_device_fallback.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c
index b547027cc879..57d8f6b50e4d 100644
--- a/net/tls/tls_device_fallback.c
+++ b/net/tls/tls_device_fallback.c
@@ -192,6 +192,9 @@ static void complete_skb(struct sk_buff *nskb, struct sk_buff *skb, int headln)
 	skb->destructor = NULL;
 	skb->sk = NULL;
 
+	/* nskb is encrypted now */
+	nskb->decrypted = 0;
+
 	update_chksum(nskb, headln);
 
 	/* sock_efree means skb must gone through skb_orphan_partial() */
@@ -371,6 +374,10 @@ static struct sk_buff *tls_sw_fallback(struct sock *sk, struct sk_buff *skb)
 	s32 sync_size = 0;
 	u64 rcd_sn;
 
+	/* Already encrypted, e.g. by the bond master */
+	if (!skb_is_decrypted(skb))
+		return skb;
+
 	/* worst case is:
 	 * MAX_SKB_FRAGS in tls_record_info
 	 * MAX_SKB_FRAGS + 1 in SKB head and frags.
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-19 19:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:13 [PATCH net v2 1/3] tls: device: keep tls_sw_fallback() from encrypting its own output Rishikesh Jethwani
2026-11-19 19:13 ` [PATCH net v2 2/3] selftests: net: py: add a bkg() timeout and kill the child when it expires Rishikesh Jethwani
2026-11-19 19:13 ` [PATCH net v2 3/3] selftests: net: add TLS offload over bond tests Rishikesh Jethwani
2026-11-19 19:18 ` [PATCH net v2 1/3] tls: device: keep tls_sw_fallback() from encrypting its own output netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox