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/2026…%40purestorage.com