🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26376

Re: [PATCH net-next v8 3/5] ip6_gre: classify the inner packet once on transmit

#26376
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 12:39
123 lines
12591 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

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

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).

- [Medium] In this commit, ip6erspan_tunnel_xmit() (net/ipv6/ip6_gre.c)
  passes the classified payload_protocol only to ip6_tnl_xmit() (line…

--

ip6_gre: classify the inner packet once on transmit

This commit adds ip6gre_xmit_classify(). It works out the inner protocol
once, on entry to ip6gre_tunnel_xmit() and ip6erspan_tunnel_xmit(). On
Ethernet devices it looks through VLAN tags and pulls the inner IP header.
The result is passed down to ip6_tnl_xmit() as a new payload_protocol
argument. That replaces the skb_protocol(skb, true) calls, which parsed the
frame again after the GRE and ERSPAN headers were pushed.

Closes: https://syzkaller.appspot.com/bug?extid=6023ea32e206eef7920a

> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 51f4311bebfa4..c413e47c6ceb0 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c

[ ... ]

> @@ -950,7 +1005,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
>  	__u32 mtu;
>  	int nhoff;
>  
> -	if (!pskb_inet_may_pull(skb))
> +	if (ip6gre_xmit_classify(skb, dev, &payload_protocol))
>  		goto tx_err;
>  
>  	if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))

[ ... ]

> @@ -1073,7 +1128,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
>  			 htonl(atomic_fetch_inc(&t->o_seqno)));
>  
>  	err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
> -			   NEXTHDR_GRE);
> +			   NEXTHDR_GRE, payload_protocol);
>  	if (err != 0) {
>  		/* XXX: send ICMP error even if DF is not set. */
>  		if (err == -EMSGSIZE) {

[Severity: Medium]
payload_protocol is passed to ip6_tnl_xmit() here. Does the rest of
ip6erspan_tunnel_xmit() still go by skb->protocol? In this commit the
truncate checks, the native mode dispatch and the choice of ICMP family
are unchanged:

net/ipv6/ip6_gre.c:ip6erspan_tunnel_xmit() {
    ...
	nhoff = skb_network_offset(skb);
	if (skb->protocol == htons(ETH_P_IP) &&
	    (ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff))
		truncate = true;

	if (skb->protocol == htons(ETH_P_IPV6)) {
    ...
	} else {
		switch (skb->protocol) {
		case htons(ETH_P_IP):
    ...
		if (err == -EMSGSIZE) {
			if (skb->protocol == htons(ETH_P_IP))
				icmp_ndo_send(skb, ICMP_DEST_UNREACH,
					      ICMP_FRAG_NEEDED, htonl(mtu));
			else
				icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
    ...
}

ip6_tnl_xmit() now takes payload_protocol as an argument, but its MTU
floor still checks skb->protocol:

net/ipv6/ip6_tunnel.c:ip6_tnl_xmit() {
    ...
	mtu = max(mtu, skb->protocol == htons(ETH_P_IPV6) ?
		       IPV6_MIN_MTU : IPV4_MIN_MTU);
    ...
}

Take a VLAN-tagged IPv4 or IPv6 frame on a native ip6erspan device.
ip6gre_xmit_classify() sets payload_protocol to ETH_P_IP or ETH_P_IPV6, so
the hop limit is inherited from the inner header.

The switch on skb->protocol still takes the default branch, though. That
skips prepare_ip6gre_xmit_ipv4() and prepare_ip6gre_xmit_ipv6(), so the
traffic class, flow label and encap_limit do not come from the inner
header. The truncate bit is not set from the inner length either.

On -EMSGSIZE, a tagged IPv4 frame would be passed to icmpv6_ndo_send()
with an IPv4 header at the network header. icmp6_send() bounds-checks that
read, so the result is a bogus PKT_TOOBIG, not memory corruption.

These sites behaved the same way before this patch. Even so, the
behaviour doesn't seem to match the new comment above
ip6gre_xmit_classify():

  Nothing below parses the frame again: the answer is passed down, also to
  ip6_tnl_xmit().

The next patch in the series, "ip6_gre: go by the inner protocol behind
VLAN tags in ip6erspan", appears to switch all four sites to
payload_protocol and to send icmpv6_ndo_send() only for ETH_P_IPV6. Could
that change be folded into this one? If not, could the comment and the
commit message be adjusted so this commit is accurate on its own?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202123613.1708463-1-littlesmilingcloud%40gmail.com
Technical Details
Message-ID: <179630154116.3146.4207161011188835860@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376602-linux-kernel-netdev=dewy.ru
References: <20261202123613.1708463-4-littlesmilingcloud@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376602-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v8 3/5] ip6_gre: classify the inner packet once
 on transmit
Date: Thu, 03 Dec 2026 12:39:01 +0000
Organization: Usenet Network
Message-ID: <179630154116.3146.4207161011188835860@kernel.org>
References: <20261202123613.1708463-4-littlesmilingcloud@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2489524"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pLUqG+5u3qUgAE036v48s/6kR/Q= sha256:WAmo+GgrSSgRWGF5nAwpHXrSlMRyeLLKK5PtmB6esQo=
	sha1:ktt2dcNjCUGLlcvQ2rsYXQY4LTw= sha256:G5Fv7N+WeiihM41WeJ3h/RU/QBFlLd5EFHPR+e/0iYI=
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 0A794117942; Thu,  3 Dec 2026 15:39:29 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, 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 wG-x85wgi3BG;
	Thu,  3 Dec 2026 15:39:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376602-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 A7FC611793A; Thu,  3 Dec 2026 15:39:15 +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 B3F4E28AB2; Thu,  3 Dec 2026 12:39:10 +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=1796301543;
	b=RMmAMCpTwNP8Gaq7guEIIXhDC2Pf2YGU2euOqR3wO8tnXPP/ULDAkw1+2A5N6zvrkWW9
	 z9bp739TskfmcUYetE2XHKXQ4IBVLjTSJv7OOouJsEfP2hkFkCX+tpvFc8ef8AYz85bL2
	 ZO3ZK1iMNmsmdKoO7ypAVEet1V/HGy+QoeRjed65UXkhnBjc5KwDKK5TLXl/2+PITacTE
	 C4dBcAlRtAHWGxeXZo4TK0YubXBCjn7cfowql23lvL4HxqVt0YbLHlp/gbrXRd90WVkK8
	 BBKK+LEoOluprtXYeiFNcF8qQJNl/hZGCGYDwFxpVLnmWkhu3N6CVa5uFn87GtSxdBg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796301543;
	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=fDxBz/5enP1IYxcTmSGaDq5DAcrHP+LoNvZMIBDW+QY=;
	b=zsZv0P5+5/k0qklUwhxa37ZSklXuWDcfF8COtID76taYZFlzqC6a3m0HwsLEiwNVQmY6
	 RIWCc3yR7nxL6hT09YKO1aTvn8PTKojNuKezHmAKskpwZbPb7v0LctWt3sIDRCTeY5rgL
	 vmwc0Fn6HVmsU1eEXqSZJmCHKVdHQGb4ztd6C2dvK1uyRDZzaK8IhrcG05g67vu3XrKQJ
	 HSzcZ7UHxh8Q9AOyt2bxT7FoNjZpZAodJTbp2sGHF5Si844JtLo7pL1Z3bgNzqlN9blR0
	 4J84R3Rf02xN7+8nPw53jDZFTa2kW7dZlAS/ZOgdBwIjoHBWutMYaBjqKnMvE1gTN0g==
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=ksJn0dPf;
	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 A9561606A6BC;
	Thu,  3 Dec 2026 12:39:03 +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=ksJn0dPf
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=1796301542;
	b=mMrQ/v28+jQurnH+tsH+TCiIkHOBZWPStymRv2mvNJdrRFtwKW6oYKHaBAqUX3YuHG+A
	 cHNTQW1EYZuwy2U+EgFuGEo8XWJzm/MxaddDmjzlTagokwNVbyWnTLnt9voMnLOd352F0
	 60Ea4afZ7AR9PHV0PkEu1y15rLoXrAHET8S36tIto25L9VrNyxlm3zYRECBQ7nAL61LzQ
	 kPCOrYyr7uOlu4BUhrtUJqW+Om5f1VDVM8b5pv9N1qRDXT4FtOaTOL5Bq7s21RDPVl7m3
	 Az43WvqoqVCY3Ah5HL7wEVHbZclcoYaJ3HYn3q/DcHJTTO1h9xfqj4SSRTSsnTKVfjQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796301542;
	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=fDxBz/5enP1IYxcTmSGaDq5DAcrHP+LoNvZMIBDW+QY=;
	b=obCI7+WvM8r+zwSEpUICM9yYt13uF5oE3tt3+ycQ/LGWlf4YpCs92/Zpipat8giBk2Vz
	 00Jo/jwwexBAqDrUOEevNQ2QsVBNhnNhlVXPYg5HL77+k1TjN3kqp3W8EU+7L7jwoA4HM
	 MLMgF4L9Mjn5w3ILSlx+LXJmZTXUebCbPovoa1OMV+AbqP9PWtPJKZEu6bl2U6gxR7o+c
	 fGPigjZFlj+RlHLmnotXTGRNvuaa/oWEnX3y7ySydNzked19AEpwk7kloUuX5i7yz4B6A
	 jmoHIpZB5iPULqS+4Jvl+LG2CAF9uwAz2KPO4hceuMeXkptc3s0RomWYDlMOy8axVDg==
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=ksJn0dPf;
	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 CBA85606A6A8;
	Thu,  3 Dec 2026 12:39:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 952B11F000C1;
	Thu,  3 Dec 2026 12:39:01 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796301542;
	bh=fDxBz/5enP1IYxcTmSGaDq5DAcrHP+LoNvZMIBDW+QY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ksJn0dPfsDk93VOGix9zYpAXeUFov+3ex82P0C76B33dSH9I0M+YNVR3080eDtkeK
	 hyBN1ZAU3TsmAneBw6piLOg7Xhg6nrXLiSGu6QBO4olJdmgLeSgowm5MQAKSwcrC+q
	 bENQ2/Mx18AUSzQPPyqsNGrxdn0oXVMDr+o5qZDhtbPjv3D2AfPcgfYOhLxNcwH+pO
	 1vGeMatNOuyN9N8uQAkyU683IyiqljCiyWEfccSuEZ3qyJJDE4UMAQi5wiT0O2Oj45
	 umenLGxmRZvnFgPRYQG4weFhid0MOd9Bs133A+nX6B7YArGjdQncEzOOj/gJg3Q/vA
	 ew2ixO7AYb1oA==
X-Cc: netdev@vger.kernel.org, edumazet@kernel.org, kuba@kernel.org,
 pabeni@redhat.com, davem@davemloft.net, horms@kernel.org, dsahern@kernel.org,
 willemb@google.com, idosch@nvidia.com, fw@strlen.de, u9012063@gmail.com,
 mvohra@vmware.com, matthias.may@westermo.com, mazin@getstate.dev,
 shuah@kernel.org, linux-kselftest@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261202123613.1708463-4-littlesmilingcloud@gmail.com>
X-sashiko-severity: Medium
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