🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13475

Re: [PATCH net-next 1/4] ipv6: fix transport header of forwarded GSO packets

#13475
From: netdev-bot+sashiko
Date: Mon, 09 Nov 2026 23:15
203 lines
15758 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] ipv6: unvalidated csum_start in ip6_forward() moves
  transport_header backwards
- [Medium] In ip6_forward() (net/ipv6/ip6_output.c), the new else-branch
  sets transport_header to whatever ipv6_skip_exthdr() returns.
- [Low] The commit fixes a user-visible bug: forwarded IPv6 GSO flows
  with destination-options or routing headers stall on Packet Too Big at…

--

ipv6: fix transport header of forwarded GSO packets

This patch resets transport_header in ip6_forward() for GSO packets before
the MTU check. CHECKSUM_PARTIAL packets without encapsulation take it from
csum_start, and other packets with extension headers walk the chain with
ipv6_skip_exthdr(). This keeps skb_gso_validate_network_len() from reading
a bogus TCP header length, which caused Packet Too Big stalls and
SKB_BAD_GSO drops.

> skb_gso_validate_network_len() then reads a bogus TCP header length. An
> overestimate makes ip6_forward() answer with Packet Too Big at the
> current MTU, and the flow stalls. Since commit 7fb4c1967011 ("net: pull
> headers in qdisc_pkt_len_segs_init()"), a bogus doff below 5 also makes
> __dev_queue_xmit() drop the packet as SKB_BAD_GSO.

[ ... ]

> Signed-off-by: Matt Vollrath <tactii@gmail.com>

[Severity: Low]
Should this patch carry a Fixes: tag and a stable Cc? The only pointer to
where the bug came from, fe6cc55f3a9a ("net: ip, ipv6: handle gso skbs in
forwarding path"), is in the notes below the --- separator, and git am
strips those.

Stable trees that pick up 7fb4c1967011 would start dropping these
forwarded packets as SKB_BAD_GSO. Nothing in the commit points the stable
tooling at this fix.

Would a trailer like this in the commit body work, along with a mention of
7fb4c1967011?

Fixes: fe6cc55f3a9a ("net: ip, ipv6: handle gso skbs in forwarding path")

> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
> index 25fe0ba98b1a6..60ac56afbd06b 100644
> --- a/net/ipv6/ip6_output.c
> +++ b/net/ipv6/ip6_output.c
> @@ -662,6 +662,23 @@ int ip6_forward(struct sk_buff *skb)
>  
>  	__IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
>  
> +	if (skb_is_gso(skb)) {
> +		if (skb->ip_summed == CHECKSUM_PARTIAL && !skb->encapsulation) {
> +			skb_set_transport_header(skb,
> +						 skb_checksum_start_offset(skb));
> +		} else if (ipv6_ext_hdr(hdr->nexthdr)) {
> +			u8 nexthdr = hdr->nexthdr;
> +			__be16 frag_off;
> +			int thoff;
> +
> +			thoff = ipv6_skip_exthdr(skb, skb_network_offset(skb) +
> +						 sizeof(*hdr), &nexthdr,
> +						 &frag_off);
> +			if (thoff >= 0)
> +				skb_set_transport_header(skb, thoff);

[Severity: High]
Can the CHECKSUM_PARTIAL branch move transport_header backwards, into
the fixed IPv6 header or even in front of skb->data?

csum_start is taken as is here. Nothing checks that
skb_checksum_start_offset(skb) is at least skb_network_offset(skb) +
sizeof(*hdr). Before this patch, the forwarding path kept the
transport_header set by ip6_rcv_core(), which never pointed inside the
fixed header.

For packets injected through tun/tap, macvtap or af_packet with
VIRTIO_NET_HDR_F_NEEDS_CSUM, csum_start comes from userspace. The check
in __virtio_net_hdr_to_skb() runs while skb->data still points at the
Ethernet header:

include/linux/virtio_net.h:__virtio_net_hdr_to_skb() {
    ...
		if (!skb_partial_csum_set(skb, start, off))
			return -EINVAL;
		if (skb_transport_offset(skb) < nh_min_len)
			return -EINVAL;
    ...
}

nh_min_len is sizeof(struct ipv6hdr) for VIRTIO_NET_HDR_GSO_TCPV6, so a
csum_start of 40 is accepted. After eth_type_trans() pulls the 14 byte
Ethernet header, that is offset 26 from the network header, in the
middle of the source address. A routed TCPV6 GSO packet built this way
takes this branch and gets transport_header set inside the IPv6
header. From there:

ip6_forward()
  ip6_pkt_too_big()
    skb_gso_validate_network_len()
      skb_gso_network_seglen()
        skb_gso_transport_seglen()
          thlen = tcp_hdrlen(skb);

This reads doff out of the address bytes. The network header length
comes out 14 bytes short and thlen is garbage, so the MTU checks here
and in ip6_finish_output_gso() use the wrong segment length.
qdisc_pkt_len_segs_init() later reads the same bogus doff.

It gets worse if the offset goes negative. bpf_prog_run_generic_xdp()
calls __skb_pull() after bpf_xdp_adjust_head() without adjusting
csum_start, so ip_summed can stay CHECKSUM_PARTIAL with csum_start
behind skb->data. A negative transport offset wraps the unsigned
arithmetic in skb_gso_network_seglen(), which lets the packet past the
MTU checks. Then, in qdisc_pkt_len_segs_init():

net/core/dev.c:qdisc_pkt_len_segs_init() {
    ...
		hdr_len = skb_transport_offset(skb);
    ...
		th = (const struct tcphdr *)(skb->data + hdr_len);
    ...
}

hdr_len is an unsigned int. With a transport offset between -20 and -1
the length passed to pskb_may_pull() wraps to a small value that
passes, and th ends up about 4 GiB past skb->data on 64-bit. Reading
th->doff there would oops.

Would it be enough to use csum_start only when
skb_checksum_start_offset(skb) >= skb_network_offset(skb) +
sizeof(*hdr), and fall back to the ipv6_skip_exthdr() walk otherwise?

[Severity: Medium]
Can this make tcp_hdrlen() read past the linear data of the skb?

For each extension header, ipv6_skip_exthdr() reads only the 2-byte
generic header through skb_header_pointer(). After the last one it adds
hdrlen without a bounds check, and for destination or routing options
hdrlen can be up to 2048 bytes:

net/ipv6/exthdrs_core.c:ipv6_skip_exthdr() {
    ...
		nexthdr = hp->nexthdr;
		start += hdrlen;
    ...
}

So thoff can point into the page frags or past skb->len. The only check
here is thoff >= 0.

Right after this, the MTU check reads the TCP header directly at the new
offset:

ip6_forward()
  ip6_pkt_too_big()
    skb_gso_validate_network_len()
      skb_gso_network_seglen()
        skb_gso_transport_seglen()
          thlen = tcp_hdrlen(skb);

tcp_hdrlen() reads tcp_hdr(skb)->doff with no pskb_may_pull() and no
skb_header_pointer().

The else branch runs for TCP GSO skbs that are neither CHECKSUM_PARTIAL
nor encapsulated. Two examples are fraglist GRO (CHECKSUM_UNNECESSARY) and
virtio_net_hdr GSO packets without NEEDS_CSUM.

On ingress, only the extension header chain that was actually parsed gets
linearized. Suppose the chain is rewritten before ip6_forward(), for
example by nftables payload mangling in PREROUTING or by a tc BPF
store_bytes. Then the new thoff can land far past skb_headlen(), possibly
past skb->end. Both of those need CAP_NET_ADMIN, which an unprivileged
user namespace has inside its own netns.

Before this patch, transport_header on this path pointed just past the
fixed header, or past a hop-by-hop header that ipv6_parse_hopopts() had
already pulled. Either way the read stayed inside the linear data.

Would a pskb_may_pull(skb, thoff + sizeof(struct tcphdr)) check for TCP
GSO cover this, keeping the old transport_header if the pull fails?

> +		}
> +	}
> +
>  	mtu = ip6_dst_mtu_maybe_forward(dst, true);
>  	if (mtu < IPV6_MIN_MTU)
>  		mtu = IPV6_MIN_MTU;

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261105201309.3182307-1-tactii%40gmail.com
Technical Details
Message-ID: <179426610333.994134.2644370589086394410@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359659-linux-kernel-netdev=dewy.ru
References: <20261105201309.3182307-2-tactii@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359659-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 1/4] ipv6: fix transport header of forwarded GSO packets
Date: Mon, 09 Nov 2026 23:15:03 +0000
Organization: Usenet Network
Message-ID: <179426610333.994134.2644370589086394410@kernel.org>
References: <20261105201309.3182307-2-tactii@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="471831"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:h1KGNkRncSUeWif3rRGUyBibqmk= sha256:orIZLHqziJooufIvxV6VY78ly2J811gq0gRW9e2fPgk=
	sha1:gfkxFGhzaEJpTwx6Am4dZ9sGzQw= sha256:Gt33HxJ3owG6HwFJOr2VV1ukxXRMQxdmnTBUsQqhAxo=
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 B9E3811396C; Tue, 10 Nov 2026 02:15:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 b_RjdxhLkFPC;
	Tue, 10 Nov 2026 02:15:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-359659-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id DBA531138DE; Tue, 10 Nov 2026 02:15:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 4FEA529FA9; Mon,  9 Nov 2026 23:15:07 +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=1794266106;
	b=n0zZN1O+a2KsHZ3LcQ0nLNm06YJpvSHOI6F74FIeGSx32DS0bOoePcvunsxpoEm7wY3m
	 zCPEqeD6tv1bX2df9fpLtpXXJwYpNljq+73TeB2AyH2jeZz3Nbc7Yp472Sdl5iKDSGbXR
	 rIiZ7ijf3jenlQcix21cPWjFF0MpT3hY6qH4MQ/oNMva67qW6Pn3PJ9tTlex26/iakrlr
	 bgtY4ZnJmduCJD6wnQv3s3ovIBF7pMb6KTB75kCnYVndHUafV6KPv5LJVJkTYklkpdtoc
	 kChN9Gnv/hkOicQgyhHDL6hBFYCfi9oa+ZQmnqScUjQMN+gLVd3/l0/T2+yXHdlVduQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794266106;
	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=g1aJkuxd0Ur2EcndcqLJniNjLXwxT7nR+FRcSV89gas=;
	b=b5T5VMadROVnzjrGnHbv3tTuRtnDIFAGuVJZeL3C0Cr4Si7NmbCULPPMi8St4fdLGZvU
	 ZNnNEgqZ/Zzhg279nSguQiNJ6GsafdIZezbUdybkTbX0tEezoDYgFSjlEb43DjitwNkaK
	 fXqLy3vOnzmfnsLh1BnQxaVcw5oAj1Cdhsu/OMwzWAsXo0hpkxCuwSySIZdCzj4BFh+dm
	 tN4uynrxxQh9e3cuiXSdnf502L1eLhb8VzzpNusP1LBNlnVlfo5Zla3xNM60tPWcDyQnA
	 SJNrUED+eZtRlVxJmmMj/2vCis36C+rStOwCHOblQnqtmcs1gPPIn01uo8J23q4zB9Q==
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=H2805Djz;
	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 A2559606A331;
	Mon,  9 Nov 2026 23:15:06 +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=H2805Djz
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=1794266105;
	b=s6F3bizRxWR7o8uJHxn9OQnduqbteTbbYrrT2PtGTbxk96D43vDpkH/WXb1O4+kuXxyf
	 BfBKBrgVQW2ffiGyyD5xdsJVVIpnFzBZZC4/MhCNoqeq/z+/pPYY36UzyxjlfV2/1hCU/
	 Lr9DeqmzpBlrWr3gCC022BuMvTPdnTyECyndfoFElcymK3fSaTQmpq3J6U6knkCpOi5SQ
	 A7SKHAYvfpQ6uLUO1FTNe80fTBdzOJ4Rcea33oOjV8l9nMNWzl8IDi7LDU6JiQEcUyCH3
	 6oILbUJg7YGc3EmSw0CWVznhQX3g23Z5wqteJr23ysNQYA4N3Fvl033iZzCMSYWD1Lg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794266105;
	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=g1aJkuxd0Ur2EcndcqLJniNjLXwxT7nR+FRcSV89gas=;
	b=md1HXnnCeleT2IFynkBeM8jvIooe8TVDVa11Ip6Hp/st5OTZQcoIddRnp5VPAusC4g2O
	 5rviKVCpBGBvEC5MU7po1ylxuPUMKxiWj388kI8gLKuPKDnK9h31h50mzuobhnrRqr7nx
	 MhssNYvxeZULm1s5ldIJ7XuTwdMJU/qgqRjd2qkcQ9LvZkhMjSU29MJkfZ3pRYR9N7Lw3
	 3VcmitJVc50yZUBGIXUIAHQJAy3HQAmDWu9tVd8JvvEIYjNGicUWJzo8D5iJClYplBB5x
	 9O25pApH7D8vONmS45wXQNTW+BZzUEbUfIGBqlIcH3sm+q1/mSkWwVd1L9VqZWmD7kQ==
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=H2805Djz;
	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 75281606A326
	for <netdev@vger.kernel.org>; Mon,  9 Nov 2026 23:15:04 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA12F1F0089F;
	Mon,  9 Nov 2026 23:15:03 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794266104;
	bh=g1aJkuxd0Ur2EcndcqLJniNjLXwxT7nR+FRcSV89gas=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=H2805DjznEqUoyd+zayJbfxuYKRIo4ucQvrxIIiG8S0NTI4VsMpXI1hnK9zaqQqE9
	 ceVVNvN+DY1mRPIwtWbfpmB71aRuo7+cDfFRJqzUiV0IQp6UHZxePKuLshXmRnD9O9
	 Ha13JLCbnWERz1Fh/iyGH+Cb8Lf/S0xjv5QOw+7Z7V/Yjy0ieWpYCzEhr4vqI3P+44
	 9Z3q4tSzdorDQpXxj9Ptv5S5ilgEvuOWs/Q4zvDrlrcK4V8UdG7Mxk9nsv+B3xzA18
	 6xg03CFmHRV9Af8gJlOAPqFPUCiawmG7VSZSyOZ+FIbT+bcndA3XCUVxvZNcNvC/F+
	 plpP3Wfd9bYtA==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, dsahern@kernel.org,
 idosch@nvidia.com, andrea.mayer@uniroma2.it, justin.iurman@gmail.com,
 aahringo@redhat.com, willemb@google.com, alexander.duyck@gmail.com
X-In-Reply-To: <20261105201309.3182307-2-tactii@gmail.com>
X-sashiko-severity: High
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