🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21288

Re: [PATCH net v2 1/3] tls: device: keep tls_sw_fallback() from encrypting its own output

#21288
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 20:39
133 lines
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
Technical Details
Message-ID: <179546636707.3135.15103841065368039377@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369747-linux-kernel-netdev=dewy.ru
References: <20261119191341.4089157-1-rjethwani@purestorage.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369747-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 1/3] tls: device: keep tls_sw_fallback() from
 encrypting its own output
Date: Mon, 23 Nov 2026 20:39:27 +0000
Organization: Usenet Network
Message-ID: <179546636707.3135.15103841065368039377@kernel.org>
References: <20261119191341.4089157-1-rjethwani@purestorage.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3979257"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xhUd0mBHA8PQxfdFIUQQ/SCGJqc= sha256:Ym9nBKMXufTCWjX4pvwFuH33iE/mtMcdECwn4i3E/Ag=
	sha1:LO8w3yd1kQ9uahLtnisxWKCdVkM= sha256:OjCrJFTJdsXajUNlMbi35DTXay30h8eSzvbpN2QiNSk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id F2840125DC7; Mon, 23 Nov 2026 23:39:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id jiYENOFZerQx;
	Mon, 23 Nov 2026 23:39:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-369747-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 67F30125DB9; Mon, 23 Nov 2026 23:39:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 19DEE260E6; Mon, 23 Nov 2026 20:39:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795466369;
	b=hw2ehEXtXOQrxmNoxOR89BEN5Ez7CFhva/4KLRK+kPJTUdGKobOb8YNthLEvbxYO2Knl
	 yRrAC58RW2PvEEnDBT36hlLW4Ypxy+245tnSkdaisfPzhIR/Dbpc3bO3jrqHTH9Jpg6W1
	 xAonZDle6idpLzMlI8Ku2E5Yz7H6qKFCCyvOfJXT02wO8FSrfF0Xoa83LJChKI84mUsW2
	 wHzsGD3FIxbkWqdohfE2ysGsOOrlUerw5gLUWLcujaDbcJDCeNppz0ely5hf4mUe29t+d
	 Iz0TR4kF3p1yAOqRtQJm9JVJgpWIWMgiG2IvtUIry3cJj3v6sirg5oWrVVIvvkYKF3g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795466369;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=uYHZ9xBPT+FC2JvbmkS0mkpOSIDYPq7bEQsGc7x1jrs=;
	b=Av+yX0C/EdfLcOBsjpjH4h95bEJpnvG8IMKFujovAogU1wK13DEr9Hrc3eozuAOzs9rB
	 IMB+wi7Z4af4dKHI7dZS+HNCSpB8Zfu1oVL1L7Ys8X2D1mpbwo8hPdorKO1fFqnrZAIT4
	 I8DtGn11d+/ty4RK2mar2dfjmSC4L8TCCiwRmhnAfcLRspBd3l0LOi3EAvjDTHYEm8d5j
	 V9YUyak/F/cKqGey8VdOVLwKb0SocAIhZxsxtiQnEROFsaNgqZjds302UQze6g21LagZ5
	 H4PCOobZYo6CVMeU3yrgK297P85Hy/+rTqKECm7l2Ir8WqWUOHZ/pZq8eWba/kNGC9w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Y1cOvA/3";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C091606A330;
	Mon, 23 Nov 2026 20:39:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Y1cOvA/3
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795466368;
	b=hbpIUnH6ZRnRg9gg7SDcAGSLGNgf5lFeeeOh91iLAzYJLtPeHwFoOt+KSdM6LhywnWw9
	 9wk/UCIooCeMc/bKkcupxE9W8KdwVKPgi7aviOFcCgDZGJEWCktfyuqOF1cQhGtzVq5PB
	 6grRFgzf351jicknMB31kppjVO/4P6+6I3QmsAZqO7rTE0s0cp4sIBgY3qSN47WynOeIt
	 V+qBtipQulyXxcwAlFVuXgi45HdbHVMgpszQG9qkm+bhKn0+HrxzZcaaTKy+W3dT+1ri/
	 CJzvuFxorDidHMnm+ZqluUcCtj2l8Lo1hS+8evbkgJAG9s+AVDMA4iQqo6HIjZoY1ZQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795466368;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=uYHZ9xBPT+FC2JvbmkS0mkpOSIDYPq7bEQsGc7x1jrs=;
	b=UwLj+6rU6Y23rFCJm0qmOWfKkoqYW0cQxNpxuYRdssujfWlTFO5yFjAS9OlPXq2rHau/
	 Wc9sd7To+tOSJIOTmzx4XQMrNGLHXwroF42VeQj1jEWUPhOpErOBjixvokUNeuNZY0xrQ
	 bGgUrTEca5ibJB575pr03pgi/8GZ60O1e+cSCLYxzEsqSiS0lOODGOgUAo7kKlOb0m6xx
	 1DdrA9W6P40L/a0s5LlhXL3ISx1z3wPgDE2xHMuEpru1hNJZ2ryiTn8yT3CB/+hB7ChuE
	 l4X0ZS+rVMXBABU6tCKreMS7PqBRXtXONCguIlON5F3crHkliIXBXH9kAAYr1timcyg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Y1cOvA/3";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9574606A31E;
	Mon, 23 Nov 2026 20:39:28 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BCC91F000CF;
	Mon, 23 Nov 2026 20:39:27 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795466368;
	bh=uYHZ9xBPT+FC2JvbmkS0mkpOSIDYPq7bEQsGc7x1jrs=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Y1cOvA/3nz30UZogGyFzZjrVjryx7oc7wKW6obzWqBB3TWb4RMIOg0Ao6mc8e2gpm
	 Omgs8pdxzANnqA1L6RAKqzsNzpJLetu/IFHidIpD/zWuu21tuNhSuc0pYFwM0ermHx
	 lqxuBsU6oU2sZmmNF97TqkRHMXq6w9UF0g+QPYbUQ74SKmAXzWFoWo01G8h4L11i6e
	 RjPBNuOeWAGVwlFtHn+yzgnI/K5Ers+K1ki0vCqQ8HuyTJjrXGSM5a/131eFH89ZAo
	 zCCD2DoH+oTc5O6MXUm9b9k3r92G11RhMWp606G6mkEhChpZ5TmUH60gsmk0m6foTo
	 69TECRTRKapeQ==
X-Cc: netdev@vger.kernel.org, stable@vger.kernel.org, john.fastabend@gmail.com,
 kuba@kernel.org, sd@queasysnail.net, davem@davemloft.net, edumazet@kernel.org,
 pabeni@redhat.com, horms@kernel.org, tariqt@nvidia.com,
 alice.kernel@fastmail.im
X-In-Reply-To: <20261119191341.4089157-1-rjethwani@purestorage.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list