Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Julius Bairaktaris <julius@bairaktaris.de>,
	 willemdebruijn.kernel@gmail.com
Cc: netdev@vger.kernel.org,  davem@davemloft.net,  kuba@kernel.org,
	 edumazet@kernel.org,  pabeni@redhat.com,  horms@kernel.org,
	 willemb@google.com,  stable@vger.kernel.org,
	 hassansultan@google.com
Subject: Re: [PATCH net v2 2/2] net: gso: fall back to skb_segment when fraglist cannot satisfy checksum
Date: Mon, 23 Nov 2026 19:55:50 -0500	[thread overview]
Message-ID: <willemdebruijn.kernel.609ac1383a60@gmail.com> (raw)
In-Reply-To: <20261122164204.4058652-1-julius@bairaktaris.de>

Julius Bairaktaris wrote:
> Willem de Bruijn wrote:
> > 1. Outer tunnel checksums. __skb_udp_tunnel_segment() and
> >    gre_gso_segment() compute these with gso_make_checksum(), which
> >    reads stale SKB_GSO_CB() state, and needs an inner payload sum that
> >    skb_segment_list() does not compute.
> 
> Patch 2/5 of my "ipmr: forward GSO multicast packets" v6 changes the
> same three conditions for this case. With this series on net, the case
> from 2/5 (TCP from a local udpcsum VXLAN device, CHECKSUM_PARTIAL
> aggregates, forwarded with rx-gro-list on) leaves no wrong outer
> checksum, 3 of 3 cases in 2 runs, so 2/5 is not needed on top of it.
> The other four patches apply unchanged on top of this series.
> 
> https://lore.kernel.org/netdev/cover.1795295554.git.julius@bairaktaris.de/

Good catch.

> > +	/* Tunnel headers and outer checksums are not rebuilt */
> > +	if (skb->encapsulation || skb_tnl_header_len(skb))
> > +		return false;
> 
> 1/5 is still needed: the fraglist branches of
> tcp4/tcp6/udp4/udp6_gro_complete() leave inner_transport_header unset
> for qdisc_pkt_len_segs_init() and skb_gso_transport_seglen(). VXLAN
> forwarded with rx-gro-list on, 20 cases of 1000 packets, 2 runs: 34 to
> 241 reach the receiver with this series, and with 1/5 and 3/5-5/5 on
> top every packet the router received, with valid checksums.
> 
> Is v7 without 2/5, based on net once this series is applied, how you
> want the two combined?

How about splitting into two series.

One that is not ipmr specific: patches 1 and 3. That is ready to be
merged I expect without major comments.

A few comments to Patch 4:

    > @@ -1948,6 +1952,15 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
    >      if (vif->flags & VIFF_TUNNEL) {
    > +        /* An encapsulated packet carries the inner headers of its
    > +         * own tunnel. Only IPXIP4 GSO packets nest: their IP headers
    > +         * are segmented by protocol field, while GRE and UDP tunnel
    > +         * segmentation read skb->inner_protocol, which ip_encap()
    > +         * sets for its own header.
    > +         */
    > +        if (skb_is_gso(skb) && skb->encapsulation &&
    > +            !(skb_shinfo(skb)->gso_type & SKB_GSO_IPXIP4))
    > +            return -1;

    [severity: high, confidence: high]
    Checking only !(gso_type & SKB_GSO_IPXIP4) lets compound tunnels with
    SKB_GSO_IPXIP4 set slip through: FOU/GUE over IPIP/SIT (both from GRO via
    udp_gro_complete() -> {ipip,sit}_gro_complete() and local ipip/sit devices
    with encap fou/gue) carry SKB_GSO_UDP_TUNNEL[_CSUM] | SKB_GSO_IPXIP4 (and
    esp4_offload.c can combine SKB_GSO_ESP | SKB_GSO_IPXIP4). ip_encap() then
    unconditionally overwrites skb->inner_protocol_type and skb->inner_ipproto
    to IPPROTO_IPIP, so skb_udp_tunnel_segment() dispatches SIT-over-FOU/GUE to
    ipip_gso_segment() on an IPv6 header, dropping/corrupting it after vif stats
    already counted it.

  The hidden assumption is that SKB_GSO_IPXIP4 is mutually exclusive with SKB_GSO_UDP_TUNNEL[_CSUM]. It isn't: FOU and GUE wrap IP-in-IP /
  SIT inside UDP, so a single skb carries both SKB_GSO_UDP_TUNNEL[_CSUM] and SKB_GSO_IPXIP4 in skb_shinfo(skb)->gso_type.

  The check tests the wrong sense of the bitmask: it asks "is IPXIP4 present?" rather than "are any non-IPXIP4 tunnel bits present?"

  Admittedly double encap is a bit niche. But something a fuzzer will find. I'd lower the severity to medium though.

    [severity: high, confidence: high]
    Even for pure SKB_GSO_IPXIP4 (IPIP/SIT without FOU/GUE), pushing a third IP
    header without segmenting first breaks the invariant enforced by real ipip
    devices (IPIP_FEATURES omits NETIF_F_GSO_ENCAP_ALL and hw_enc_features is 0,
    so validate_xmit_skb() segments any encapsulated GSO skb before ipip_tunnel_xmit()).
    NICs advertising full NETIF_F_GSO_IPXIP4 offload (i40e, ice, iavf, ionic)
    take the 3-header skb directly and only update skb_network_header() and
    skb_inner_network_header(), leaving the middle IPv4 header with the full
    aggregate tot_len and static id on every segment (and patch 5 widens this
    from DF=0 to DF=1 traffic). GSO_PARTIAL NICs (mlx5, bnxt, ixgbe, igb, igc)
    also replicate the middle header with a fixed id even when DF is clear.
    Either drop all skb_is_gso(skb) && skb->encapsulation here (as in v5) or
    segment already-encapsulated GSO skbs before ip_encap().


  struct sk_buff only has two sets of header pointers: outer (network_header, transport_header) and inner (inner_network_header,
  inner_transport_header). Every hardware TSO driver and NIC descriptor format is built around that 2-layer model.
  Normal ipip tunnel devices enforce this automatically. ipip_tunnel_setup:403-422 advertises NETIF_F_GSO_SOFTWARE (which excludes
  NETIF_F_GSO_ENCAP_ALL) and leaves dev->hw_enc_features = 0. When an already-encapsulated GSO skb (skb->encapsulation == 1) is transmitted
  to tunl0, __netif_skb_features:3998-3999 masks features with dev->hw_enc_features (0), so validate_xmit_skb() segments it first before
  ipip_tunnel_xmit() pushes the second IP header.
  VIFF_TUNNEL bypasses dev_queue_xmit() on dvmrp%d and calls ip_encap() directly inside ipmr_prepare_xmit(), so nothing segments an incoming
  IPIP/SIT GSO skb before ip_encap() wraps it in another IPv4 header.

  The root tension is that v6 added && !(gso_type & SKB_GSO_IPXIP4) solely to appease a review comment on v5 about preserving pre-existing
  DF=0 software-GSO IPIP/SIT behavior, but doing so violates the kernel's 2-layer GSO invariant and creates both Issue #1 and Issue #2.
  
  There are two clean ways out:
  
  1. Minimal net fix (revert to v5): if (skb_is_gso(skb) && skb->encapsulation) return -1; — drops all already-encapsulated GSO skbs on
  VIFF_TUNNEL in one line, avoids illegal 3-IP-header GSO skbs completely, and eliminates both Issue #1 and Issue #2.
  2. Full fix (matching ipip netdev semantics): Segment already-encapsulated GSO skbs (skb_gso_segment(skb, 0) / software GSO) before calling
  ip_encap() in ipmr_queue_{fwd,output}_xmit() — then all encapsulated GSO traffic (IPIP, SIT, GRE, VXLAN, FOU/GUE) works over VIFF_TUNNEL on
  both software and hardware TSO NICs, with zero drops and zero 3-header skbs (though slightly more invasive for net).

    > @@ -1982,6 +1995,17 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
    > +    if ((vif->flags & VIFF_TUNNEL) && skb->encapsulation &&
    > +        !skb_is_gso(skb) && skb->ip_summed == CHECKSUM_PARTIAL &&
    > +        skb_checksum_help(skb)) {
    > +        ip_rt_put(rt);
    > +        return -1;
    > +    }
  
    [severity: medium, confidence: high]
    A unicast SCTP packet inside VXLAN/GRE/IPIP with a multicast outer
    destination can reach here with skb->encapsulation && CHECKSUM_PARTIAL &&
    skb->csum_not_inet (unlike unencapsulated multicast SCTP). skb_checksum_help()
    writes a 16-bit 1's-complement checksum over the first 2 bytes of the 4-byte
    SCTP CRC32c field. Use skb_csum_hwoffload_help(skb, 0) instead, matching
    validate_xmit_skb() on an ipip device.

      reply	other threads:[~2026-11-24  0:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261120044733.222627-1-willemdebruijn.kernel@gmail.com>
2026-11-20  4:46 ` [PATCH net v2 1/2] net: gso: cow head on tcp fraglist fallback to skb_segment Willem de Bruijn
2026-11-20  4:46 ` [PATCH net v2 2/2] net: gso: fall back to skb_segment when fraglist cannot satisfy checksum Willem de Bruijn
2026-11-22 16:42   ` Julius Bairaktaris
2026-11-24  0:55     ` Willem de Bruijn [this message]

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=willemdebruijn.kernel.609ac1383a60@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hassansultan@google.com \
    --cc=horms@kernel.org \
    --cc=julius@bairaktaris.de \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --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