🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27558

Re: [PATCH net v3 3/9] tls: device: don't let the NIC encrypt fallback output again

#27558
From: netdev-bot+sashiko
Date: Sun, 06 Dec 2026 00:23
160 lines
14470 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] On its own, this patch does not fix the headline case it claims
  to fix: NIC re-encryption of tls_sw_fallback() output, e.g. after a…
- [Low] tls_is_skb_tx_device_offloaded() is also used for TX queue and
  bond-slave selection, not only to decide whether the NIC encrypts.
- [Low] This patch makes tls_is_skb_tx_device_offloaded() true only when
  skb->decrypted is set, but the in-tree descriptions of the helper were…

--

I found three low-severity issues in this patch. The code itself looks correct within the series. All three findings are about the commit message, tags and in-tree documentation, plus one change to how two drivers pick queues and bond slaves.

tls: device: don't let the NIC encrypt fallback output again

This commit adds a skb_is_decrypted() check to
tls_is_skb_tx_device_offloaded(). With it, skbs from an offloaded socket
that are not marked for device crypto skip the driver's TLS TX path. That
covers software fallback output and data queued before TLS_TX was enabled.

> Require skb_is_decrypted() in tls_is_skb_tx_device_offloaded().
> Fallback output then takes the ordinary TX path, as does data queued
> before TLS_TX was enabled. Backport the first three fixes together,
> in order.

[Severity: Low]
Does this change alone make fallback output take the ordinary TX path?

complete_skb() copies the headers group, which includes decrypted, from
the original skb:

net/tls/tls_device_fallback.c:complete_skb() {
    ...
	skb_copy_header(nskb, skb);
    ...
	/* Ciphertext now: don't encrypt it again */
	nskb->decrypted = 0;
    ...
}

The nskb->decrypted = 0 line comes from the previous patch in the series,
"tls: device: keep tls_sw_fallback() from encrypting its own output".
Without it, nskb keeps decrypted=1, so the new skb_is_decrypted() check
still returns true for fallback output. The macvlan reroute case would
then still go like this:

  macvlan xmit
    validate_xmit_skb()->tls_validate_xmit_skb()
      dev != ctx->netdev, so tls_sw_fallback() runs; nskb keeps decrypted=1
  lower NIC xmit
    validate_xmit_skb()->tls_validate_xmit_skb()
      dev == ctx->netdev, so the skb is returned unchanged
    the driver sees tls_is_skb_tx_device_offloaded() == true and encrypts
    the ciphertext again

Could the commit message name the prerequisite commit? It could also say
that this check depends on complete_skb() clearing the mark.

"Backport the first three fixes together, in order" will not mean much
once this is in git history. This patch has Fixes: e8f69799810c and a bare
Cc: stable. The prerequisite has a different tag, Fixes: c55dcdd435aa.
Would a prerequisite annotation help here, like the one the previous patch
uses?

  Cc: stable@vger.kernel.org # x.y.z: <prereq sha>

That would stop stable trees from picking this patch up without the
previous one.

> diff --git a/include/net/tls.h b/include/net/tls.h
> index 0b001b8ab1c3b..9998b55820919 100644
> --- a/include/net/tls.h
> +++ b/include/net/tls.h
> @@ -365,7 +365,8 @@ static inline bool tls_is_skb_tx_device_offloaded(const struct sk_buff *skb)
>  
>  	return sk && sk_fullsock(sk) &&
>  	       (smp_load_acquire(&sk->sk_validate_xmit_skb) ==
> -	       &tls_validate_xmit_skb);
> +	       &tls_validate_xmit_skb) &&
> +	       skb_is_decrypted(skb);

[Severity: Low]
tls_is_skb_tx_device_offloaded() is not only used to decide whether the
NIC encrypts. It also drives TX queue selection and bond slave selection.
Is the change in those callers intended?

After this patch, every unmarked skb of an offloaded socket goes a
different way at these two call sites. That includes pure ACKs, bare FINs,
pre-offload data and retransmits, and fallback output.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:cxgb4_select_queue() {
    ...
		if (xfrm_offload(skb) || is_ptp_enabled(skb, dev) ||
		    skb->encapsulation ||
		    tls_is_skb_tx_device_offloaded(skb) ||
		    (proto != IPPROTO_TCP && proto != IPPROTO_UDP))
			txq = txq % pi->nqsets;
    ...
}

When netdev_get_num_tc(dev) != 0, every skb of a TLS offloaded socket used
to be kept on the normal NIC queues. Now only decrypted=1 skbs are. The
unmarked segments of the same flow can end up on the mqprio ETHOFLD queues
and be shaped there.

drivers/net/bonding/bond_main.c:__bond_start_xmit() {
    ...
	if (tls_is_skb_tx_device_offloaded(skb))
		return bond_tls_device_xmit(bond, skb, dev);
    ...
}

Only marked skbs are now pinned to the TLS lower device. After an
active-backup failover, or a slave array change in xor mode, unmarked skbs
can leave on a different slave from the one carrying the TLS records.

Can this split one TCP flow across hardware queues or ports? That could
reorder ACKs, FINs and pre-offload retransmits relative to the TLS data.

This may be harmless, since none of these skbs need device crypto. The
commit message mentions the "ordinary TX path", but not the queue
selection or bond steering changes.

[Severity: Low]
Should the in-tree descriptions of this helper be updated as well?

tls_set_device_offload() in net/tls/tls_device.c still says:

	/* following this assignment tls_is_skb_tx_device_offloaded
	 * will return true and the context might be accessed
	 * by the netdev's xmit function.
	 */
	smp_store_release(&sk->sk_validate_xmit_skb, tls_validate_xmit_skb);

After this patch the helper returns true only for skbs built with
MSG_SENDPAGE_DECRYPTED. Pre-offload skbs and fallback output now return
false.

Documentation/networking/tls-offload.rst still tells driver authors:

  TX offload being fully initialized does not imply that all segments passing
  through the driver and which belong to the offloaded socket will be after
  the expected sequence number and will have kernel record information.
  In particular, already encrypted data may have been queued to the socket
  before installing the connection state in the kernel.

Those segments still reach the driver. However, the shared helper now
keeps them out of the TLS TX handlers in mlx5e_accel_tx_begin(),
nfp_net_tls_tx(), fun_tls_tx() and the cxgb4 ULD tx_handler path.

Neither the comment nor the documentation says that the helper now
requires the skb mark as well as the socket state.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204235642.36653-1-rjethwani%40purestorage.com
Technical Details
Message-ID: <179651658560.3148.13961391786370944844@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378193-linux-kernel-netdev=dewy.ru
References: <20261204235642.36653-4-rjethwani@purestorage.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378193-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 3/9] tls: device: don't let the NIC encrypt
 fallback output again
Date: Sun, 06 Dec 2026 00:23:05 +0000
Organization: Usenet Network
Message-ID: <179651658560.3148.13961391786370944844@kernel.org>
References: <20261204235642.36653-4-rjethwani@purestorage.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3150548"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:uZ+szV0jMPbEAKAoXr9kjv/myDo= sha256:9rC0xlSB2/sfvqPBw+7sTgSJ+mmxq5gJQOY2/ULsLQw=
	sha1:VYKbg4pGSCPb7MH6pvJfTRWN9rc= sha256:YnXqMMCqaKHIBg5FgimdRXpW+a/Qc5PXeI5nX2Yyi6w=
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 514BE117F05; Sun,  6 Dec 2026 03:23:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.14, 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]
	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 LtyAxSNVuXGR;
	Sun,  6 Dec 2026 03:23:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-378193-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 DBC71117EF3; Sun,  6 Dec 2026 03:23:09 +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 5847D279EF; Sun,  6 Dec 2026 00:23:08 +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=1796516588;
	b=pldyjIlLyF+hUITd95pbjccFIOzs4vkpQPANngN3zUU2vxrvKzjHCRsf5/zOO8wxU6mH
	 KP15oHlYlwMOa/jfu/KQCLhK27CIeFpZvHY2dU50steKg+MDzFjTwArvMRzSHJhLX/8x7
	 6i7N0oWxrlHZ309Pp9yTb0RhnYviWIGXjY8qDlzZ3L3VJ+sJTLZjNmfC4QjFqi/E3v60/
	 WF1gyRHhVqUbfz/lp/jDs9STXwARlI0NHPa7VtHUvsY1ZtIXAm0hq6pADoDZByB3mADpI
	 UG3WI8G9Tbuv1RDfoTdKwRrRBkMaIP6/UbWTMbUV49qhZJfEPHM5XUoxtaRKWt/tcAg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796516588;
	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=ZMS+UzxPnlXXPcW91DSBic6tFiIjN7mjZq9s7xq0vvI=;
	b=osKGca7GjdokVQy9dpj1aEGqAo4ADBG/QH9LnEWV6ALhJ0hv68/Gd1mEbqDoZOJyLjbG
	 IjfYzMFW5voUzTfj5GTb0+oNB8mw959FYdwOwuU5PLhW4+vZkyYTKPecBQRLLw/DimQxH
	 JNVu7T9ULwYRilYy227tn0VP+So5LJ7HdpmB0LkG5lXsOzxGMidpGNzmUrJ2pllMx63eA
	 PF/+uVUQHx7Eo28p/9DzGmCDOVrrIVLEunjF04Y0iFvwAtc4B11FDAfqb3vCXXC6Y6xGz
	 fb9+HKR9+krTi6czFf7y3FOeiw5+/74t+lCc2iTpOzyFBKMJePqwneY/HFcC6k5A2IA==
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=L+T1zglg;
	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 EEBDD606A336;
	Sun,  6 Dec 2026 00:23:07 +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=L+T1zglg
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=1796516587;
	b=nRKnrVIGyu/ooYod1/JTb3MsgHgChOElzhYvDoIm7dIknxpqf/jQRGK6X6DtTJV4cPFY
	 GMJ6/O61Eb7YsvpxBYIl9gzL3aG4EcvVfnCw7Cq1mWC7GHmR4ikTMRbiSAytuwpXaNw7a
	 2iaeaujE6tPEtiM64h9yNRHqwS6/oT7WFfBQzweZIbWEskQERUQwL4Vh+0yyUD8XckiE1
	 48eK9bIQtTkEseoGLz4UuSSluzGkbiRWSHH3KD+Xp76wGiYBr50UxSJzGeOvjGOsuidMh
	 dv3dUF6UwVvuGhfMWMe2QabtsR5VPm/3uzdXhEId4mPvN2aSV36gYFzPBhECJ7PI3Ng==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796516587;
	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=ZMS+UzxPnlXXPcW91DSBic6tFiIjN7mjZq9s7xq0vvI=;
	b=V8NTnFniAUd11aXOdy4AeS/clTDd1KYoDN7TBg5xibbdE76fGrZth1MENBdXicrP0rsy
	 Dj1RRrERz8xo02wVAYt5q5c7PndU5UvC14WhVlO5Jz4Lx3RI3WCVpxpTjXVCliwBPUKZA
	 OmvgZgrhkz99Qqe/xV19yx/EBqJi4rqvVxlu4IQNJajUWJMYuxJ7Mvh4TfaSnk/LtuQCV
	 lQwPWz2HWu/8dCuWdMuTJNIBO0FgGYrcrYQqMVJV3zywZbTz8Y6bJLeFvCV6b8OM+y1PI
	 wpDmdj3Nfg27DD7Te2uqayl/fKtb47CRZYBc+92ArNWbYBS4BNkbepRU7cXdYWqY9Ww==
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=L+T1zglg;
	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 1B5E9606A31F;
	Sun,  6 Dec 2026 00:23:06 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EC501F0093B;
	Sun,  6 Dec 2026 00:23:06 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796516586;
	bh=ZMS+UzxPnlXXPcW91DSBic6tFiIjN7mjZq9s7xq0vvI=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=L+T1zglgGH72Hgp+RNfk7C5qGPmKbIX+OXnIdxvuh924WkCXCQAc/ykDhDLoWKfQL
	 VmSKA1K67IaispSl5ePEcdtz+mJYryhu8zl0dFAT5v1onYczt+zPXIk/twcVzIdGSM
	 5DiJ2dE4dtAl8zMeni4BhLXOEkRPsiZFV3ttdUlwXryKARDPwQly4HSAc4a5zyxZup
	 v1d+bJkOyyEDro17ceCW16Pt383SFF7MLJhAnP/3Xojla0w29jH6LWATr4hAkBPmKF
	 p/2kT+iZDL+HTx6BDBRzPo5Imm1OQzckl1MMu8xacc/IFO2ZBrCV+Ho1H2jCcc7EJe
	 Zg31XF1Mh09Jw==
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, willemb@google.com, horms@kernel.org,
 alice.kernel@fastmail.im, tariqt@nvidia.com
X-In-Reply-To: <20261204235642.36653-4-rjethwani@purestorage.com>
X-sashiko-severity: Low
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