Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: rjethwani@purestorage.com
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
Subject: Re: [PATCH net v3 4/9] tls: device: remove the dead start marker bypass in TX fallback
Date: Sun, 06 Dec 2026 00:23:06 +0000	[thread overview]
Message-ID: <179651658685.3148.5418160875152343674@kernel.org> (raw)
In-Reply-To: <20261204235642.36653-5-rjethwani@purestorage.com>

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] The comment this patch adds in tls_sw_fallback()
  (net/tls/tls_device_fallback.c:393), "Its record was acked and freed:…
- [Low] This patch edits the '*sync_size < 0' branch of fill_sg_in()
  (net/tls/tls_device_fallback.c:239-252) and removes the…

--

tls: device: remove the dead start marker bypass in TX fallback

This removes the start marker bypass in tls_sw_fallback() and its special
case in fill_sg_in(). The reasoning is that pre-offload skbs now return
early from tls_sw_fallback() before record lookup, and TCP will not merge
them with decrypted data across the start marker. The commit message says
there is no functional change.

> diff --git a/net/tls/tls_device_fallback.c b/net/tls/tls_device_fallback.c
> index 42afbe7e60b56..da875fdf5b546 100644
> --- a/net/tls/tls_device_fallback.c
> +++ b/net/tls/tls_device_fallback.c
> @@ -237,8 +237,6 @@ static int fill_sg_in(struct scatterlist *sg_in,
>  
>  	*sync_size = tcp_seq - tls_record_start_seq(record);
>  	if (*sync_size < 0) {
> -		int is_start_marker = tls_record_is_start_marker(record);
> -
>  		spin_unlock_irqrestore(&ctx->lock, flags);
>  		/* This should only occur if the relevant record was
>  		 * already acked. In that case it should be ok

[ ... ]

> @@ -250,8 +248,6 @@ static int fill_sg_in(struct scatterlist *sg_in,
>  		 * on TCP to retransmit a packet that doesn't contain
>  		 * already acked payload.
>  		 */
> -		if (!is_start_marker)
> -			*sync_size = 0;
>  		return -EINVAL;
>  	}

[Severity: Low]
This isn't a bug, but should the comment above be updated along with this
change?

As far as I can tell, tls_get_record() can only produce a negative
sync_size by returning the start marker record. The marker has len == 0,
so it skips the between() range check:

net/tls/tls_device.c:tls_get_record() {
    ...
		/* send the start_marker record if seq number is before the
		 * tls offload start marker sequence number. This record is
		 * required to handle TCP packets which are before TLS offload
		 * started.
    ...
}

Records are contiguous, because tls_push_record() sets each end_seq to
tp->write_seq + record->len. A seq inside a record that was already acked
and removed by tls_tcp_clean_acked() fails the between() check, so
tls_get_record() returns NULL. The earlier !record branch handles that
case.

Before this patch, the is_start_marker check showed in the code that this
branch covered the pre-offload case. With the check gone, the branch can
only be reached through the start marker, but the comment still says it
is the "already acked" case.

Would it be clearer to rewrite the comment to describe the start marker
invariant, or to replace it with something like DEBUG_NET_WARN_ON_ONCE()?

[ ... ]

> @@ -394,12 +390,9 @@ static struct sk_buff *tls_sw_fallback(struct sock *sk, struct sk_buff *skb)
>  	sg_init_table(sg_in, sg_in_max_elements);
>  	sg_init_table(sg_out, ARRAY_SIZE(sg_out));
>  
> -	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);
> +	/* Its record was acked and freed: drop it */
> +	if (fill_sg_in(sg_in, skb, ctx, &rcd_sn, &sync_size, &resync_sgs))
>  		goto put_sg;

[Severity: Low]
This isn't a bug, but is this new comment accurate for every way
fill_sg_in() can fail?

fill_sg_in() returns -EINVAL from three places. Only the !record case from
tls_get_record() matches "acked and freed".

The *sync_size < 0 case can only be reached through the start marker
record. That record is live, not acked and freed.

The last case happens after a live record has been found and its frags
referenced with netmem_inc_ref():

fill_sg_in() {
    ...
	if (skb_to_sgvec(skb, &sg_in[i], tcp_payload_offset, payload_len) < 0)
		return -EINVAL;
    ...
}

__skb_to_sgvec() can return -EMSGSIZE when the sg table runs out or the
recursion is too deep, or -EINVAL when the length is short. In that case
the packet of a live record is dropped because the scatterlist conversion
failed, not because of an ACK.

The drop and the put_sg cleanup are fine for all three paths. Could the
comment say something like "drop the skb on lookup or sg setup failure"
instead?

>  
>  	nskb = tls_enc_skb(tls_ctx, sg_out, sg_in, skb, sync_size, rcd_sn);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204235642.36653-1-rjethwani%40purestorage.com

  reply	other threads:[~2026-12-06  0:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 23:53 [PATCH net v3 0/9] tls: device: don't put offload plaintext on the wire Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 1/9] net: don't fragment skbs that still need device crypto Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 2/9] tls: device: keep tls_sw_fallback() from encrypting its own output Rishikesh Jethwani
2026-12-04 23:53 ` [PATCH net v3 3/9] tls: device: don't let the NIC encrypt fallback output again Rishikesh Jethwani
2026-12-06  0:23   ` netdev-bot+sashiko
2026-12-04 23:53 ` [PATCH net v3 4/9] tls: device: remove the dead start marker bypass in TX fallback Rishikesh Jethwani
2026-12-06  0:23   ` netdev-bot+sashiko [this message]
2026-12-04 23:53 ` [PATCH net v3 5/9] selftests: net: py: reap commands that fail to report ready Rishikesh Jethwani
2026-12-06  0:23   ` netdev-bot+sashiko
2026-12-04 23:53 ` [PATCH net v3 6/9] selftests: net: py: add a timeout argument to bkg() Rishikesh Jethwani
2026-12-06  0:23   ` netdev-bot+sashiko
2026-12-04 23:53 ` [PATCH net v3 7/9] selftests: net: add TLS offload over bond tests Rishikesh Jethwani
2026-12-06  0:23   ` netdev-bot+sashiko
2026-12-04 23:53 ` [PATCH net v3 8/9] selftests: net: test TLS fallback after rerouting to an upper device Rishikesh Jethwani
2026-12-06  0:23   ` netdev-bot+sashiko
2026-12-04 23:53 ` [PATCH net v3 9/9] selftests: net: verify that IP refuses to fragment TLS offload data Rishikesh Jethwani
2026-12-06  0:23   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179651658685.3148.5418160875152343674@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alice.kernel@fastmail.im \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rjethwani@purestorage.com \
    --cc=sd@queasysnail.net \
    --cc=stable@vger.kernel.org \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox