BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Julius Bairaktaris" <julius@bairaktaris.de>
Cc: linux-rdma@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH net-next v5 1/2] net: keep the TCP fixed-ID flags on the header they describe
Date: Sat, 05 Dec 2026 22:45:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-251969@kernel.org> (raw)
In-Reply-To: <1b35c02798f3e7c08bf0dda52cc2078161fa85e4.1796423663.git.julius@bairaktaris.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] xfrm: missing skb_header_unclone() before gso_type write in
  xfrm_output()
--

commit 7dbada5cb7d60d1b2e2e417d84df7662ed0b13cc
Author: Julius Bairaktaris <julius@bairaktaris.de>

net: keep the TCP fixed-ID flags on the header they describe

This commit reassigns SKB_GSO_TCP_FIXEDID to the innermost IPv4 header
and replaces SKB_GSO_TCP_FIXEDID_INNER with SKB_GSO_TCP_FIXEDID_OUTER
for the outermost header of encapsulated packets.  It updates GRO, GSO,
tunnel, BPF, xfrm, and driver paths to set, propagate, or clear the
outer flag accordingly.

[ ... ]

> diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
> index 60ffe9549c094..00a1f69cf9cc0 100644
> --- a/net/xfrm/xfrm_output.c
> +++ b/net/xfrm/xfrm_output.c

[ ... ]

> @@ -807,7 +808,26 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
>  		sp->xvec[sp->len++] = x;
>  		xfrm_state_hold(x);
>  
> +		/*
> +		 * inner_protocol is only valid on an encapsulated skb: a tunnel
> +		 * that decapsulated the packet leaves it set, and so does
> +		 * iptunnel_handle_offloads() on a packet without offloads.
> +		 * Clear it, so that the mode output records this packet's
> +		 * inner headers.
> +		 */
> +		if (!encap)
> +			skb->inner_protocol = 0;
>  		xfrm_get_inner_ipproto(skb, x);
> +		/*
> +		 * Transport and BEET mode keep the IPv4 header and its ID, so
> +		 * the header that SKB_GSO_TCP_FIXEDID describes is the outer
> +		 * one as well.
> +		 */
> +		if (!encap &&
> +		    (x->props.mode == XFRM_MODE_TRANSPORT ||
> +		     x->props.mode == XFRM_MODE_BEET) &&
> +		    (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID))
> +			skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_FIXEDID_OUTER;
>  		skb->encapsulation = 1;
>  
>  		if (skb_is_gso(skb)) {

[Severity: Medium]
Can this mutate skb_shinfo(skb)->gso_type on a header-cloned skb without
calling skb_header_unclone() first?

An xfrmi device advertises NETIF_F_GSO_SOFTWARE, so a TCPv4 GRO packet
with SKB_GSO_TCP_FIXEDID reaches xmit_one() unsegmented.  If an
AF_PACKET tap is attached, dev_queue_xmit_nit() clones it before
xfrmi_xmit() -> xfrm_output(), leaving both skbs sharing skb_shared_info.

CPU0                                  CPU1
xmit_one()
  dev_queue_xmit_nit()
    skb_clone() -> packet_rcv()
  xfrmi_xmit() -> ...
    xfrm_output()                     packet_recvmsg()
      skb_shinfo(skb)->gso_type |=      virtio_net_hdr_from_skb()
        SKB_GSO_TCP_FIXEDID_OUTER         reads skb_shinfo(skb2)->gso_type
                                          <-- data race

Modifying gso_type in place causes a data race with concurrent readers
on the clone and leaks the flag into sibling clones sharing
skb_shared_info.

Calling skb_header_unclone(skb, GFP_ATOMIC) before updating gso_type
(as iptunnel_handle_offloads() does) avoids this for both
SKB_GSO_TCP_FIXEDID_OUTER and the SKB_GSO_ESP write just below.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796423662.git.julius@bairaktaris.de?part=1

  reply	other threads:[~2026-12-05 22:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 22:45 [PATCH net-next v5 0/2] net: keep the TCP fixed-ID flags on the header they describe Julius Bairaktaris
2026-12-04 22:45 ` [PATCH net-next v5 1/2] " Julius Bairaktaris
2026-12-05 22:45   ` sashiko-bot [this message]
2026-12-04 22:45 ` [PATCH net-next v5 2/2] selftests: net: check TCP IP IDs across tunnels after GRO and GSO Julius Bairaktaris
2026-12-05 22:45   ` sashiko-bot

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=sashiko-outbox-251969@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=julius@bairaktaris.de \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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