Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Mon, 23 Nov 2026 20:39
Re: [PATCH net v2 1/3] tls: device: keep tls_sw_fallback() from encrypting its own output
Author: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 20:39
Date: Mon, 23 Nov 2026 20:39
133 lines
12571 bytes
12571 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch makes skb->decrypted the marker for 'still needs TLS
encryption': tls_sw_fallback() now skips skbs with…
- [Low] The new early return in tls_sw_fallback()
(net/tls/tls_device_fallback.c:377-379, '/* Already encrypted, e.g. by…
--
tls: device: keep tls_sw_fallback() from encrypting its own output
This patch makes tls_sw_fallback() pass through skbs that do not have the
decrypted bit set, and clears that bit on the output of complete_skb(). The
aim is to keep a second software fallback pass (for example at the bond
master and then again at the slave) from re-encrypting ciphertext with the
same rcd_sn and IV.
> diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c
> index b547027cc879f..57d8f6b50e4dd 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;
> +
[Severity: High]
Does this also cover the hardware offload path?
complete_skb() keeps nskb->sk = sk. The driver side check for hardware
encryption does not look at skb->decrypted:
include/net/tls.h:tls_is_skb_tx_device_offloaded() {
...
return sk && sk_fullsock(sk) &&
(smp_load_acquire(&sk->sk_validate_xmit_skb) ==
&tls_validate_xmit_skb);
}
So drivers still treat software fallback ciphertext as offloaded.
Take a TLS_HW socket offloaded on mlx5 eth0 whose route later moves to
vlan@eth0:
vlan@eth0:
tls_validate_xmit_skb()
dev != netdev, not a bond master
tls_sw_fallback()->complete_skb() /* ciphertext, decrypted = 0 */
vlan_dev_hard_start_xmit()
dev_queue_xmit(eth0)
eth0:
tls_validate_xmit_skb()
dev == netdev, skb returned unchanged
mlx5e_accel_tx_begin()
tls_is_skb_tx_device_offloaded() returns true
mlx5e_ktls_handle_tx_skb()
state->tls_tisn = priv_tx->tisn; /* in-order seq */
In that case, would the NIC encrypt the software ciphertext a second time
with the same record keystream and put plaintext on the wire?
mlx5e_ktls_handle_tx_skb() only checks skb->decrypted in the
MLX5E_KTLS_SYNC_SKIP_NO_DATA branch. nfp_net_tls_tx() also decides only
through tls_is_skb_tx_device_offloaded(), and it attaches ntls->fw_handle
when ntls->next_seq == seq.
This path existed before this patch. However, the commit message says the
bit is cleared "so its output is not encrypted again", and that doesn't
seem to hold for the hardware path.
Should tls_is_skb_tx_device_offloaded() also require skb_is_decrypted(skb)
so that it follows the same rule?
[ ... ]
> @@ -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;
> +
[Severity: Low]
This isn't a bug, but is this comment accurate for every skb that takes
this return?
Data written before setsockopt(TLS_TX) also has decrypted = 0, because
tcp_sendmsg_locked() does:
skb->decrypted = !!(flags & MSG_SENDPAGE_DECRYPTED);
Only tls_push_data() and tls_device_write_space() pass that flag, so that
data was never encrypted by kTLS.
Also, the existing bypass further down in tls_sw_fallback() no longer
seems reachable for the packets it describes:
if (fill_sg_in(sg_in, skb, ctx, &rcd_sn, &sync_size, &resync_sgs)) {
/* bypass packets before kernel TLS socket option was set */
if (sync_size < 0 && payload_len <= -sync_size)
nskb = skb_get(skb);
goto put_sg;
}
Three things make it unreachable for those packets:
- Only decrypted = 1 skbs reach fill_sg_in() now.
- Those skbs are created after the start marker set in
tls_set_device_offload().
- tcp_skb_can_collapse() refuses merges across a decrypted mismatch.
Should the new comment also mention pre-offload plaintext? And should the
start marker bypass, along with the matching start marker handling in
fill_sg_in(), be updated or removed?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119191341.4089157-1-rjethwani%40purestorage.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads