๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26136

Re: [PATCH net-next v7 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family

#26136
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 03:59
92 lines
11499 bytes
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 commit "erspan: take the COS from the mirrored frame, not
  from the tunnel family" fixes two old bugs in erspan_build_header()โ€ฆ

--

erspan: take the COS from the mirrored frame, not from the tunnel family

The patch adds a helper, erspan_frame_tos(). erspan_build_header() and
erspan_build_header_v2() now use it to read the TOS for the ERSPAN COS
field from the mirrored frame, not from the tunnel family. The helper
reads the two bytes with skb_header_pointer(), and the patch drops the
is_ipv4 argument and the stale forward declaration in ip_gre.c.

> erspan: take the COS from the mirrored frame, not from the tunnel family
>
> erspan_build_header() and erspan_build_header_v2() take the TOS for
> the COS field from ip_hdr(skb)->tos when the tunnel is IPv4 and from
> the IPv6 traffic class when the tunnel is IPv6. But is_ipv4 describes
> the tunnel, not the mirrored frame, so

[ ... ]

>  - a frame that is neither gets its COS from whatever lies at the
>    network header offset, which for a short frame is past its end.

[ ... ]

>  - a 14 byte non-IP frame gives a KMSAN report when the packet is
>    received on the other side; with the patch it does not.
>
> Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>

[Severity: Low]
Should this patch have Fixes: tags?

It fixes two old problems in erspan_build_header() and
erspan_build_header_v2() in include/net/erspan.h:

- For short non-IP frames, the ip_hdr(skb)->tos / ipv6_hdr(skb) read at
  the network header is unbounded, and KMSAN reports it.
- The COS is wrong when the mirrored frame's family differs from the
  tunnel's.

The previous patch in the series, "erspan: bound the VLAN tag read in
erspan_build_header{,_v2}()", has these tags:

    Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
    Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
    Reported-by: syzbot+9e27778c0edc62cb97d8@syzkaller.appspotmail.com
    Closes: https://syzkaller.appspot.com/bug?extid=9e27778c0edc62cb97d8

Its message also says it depends on this patch:

    With this patch and the next one, which bounds the remaining
    read of this kind, the same frames give no report on erspan.

Without Fixes: tags here, stable selection could take only the first
patch. Stable kernels would then keep the uninitialized TOS read and the
wrong COS.

The old read can be reached on existing kernels. erspan_xmit() checks the
length only through pskb_inet_may_pull_reason(), and that pulls nothing
for a non-IP skb->protocol:

include/net/ip_tunnels.h:pskb_inet_may_pull_reason() {
    ...
	default:
		nhlen = 0;
	}

	return pskb_network_may_pull_reason(skb, nhlen);
}

Blame on the baseline shows where the two reads came from:

- the one in erspan_build_header() with a3222dc95ca7
- the one in erspan_build_header_v2() with f551c91de262

Would it work to use the same two Fixes: tags as the previous patch,
plus the commit that added the ip6erspan callers that pass is_ipv4 as
false? A note saying that this patch completes the syzbot fix could
also help.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201005941.1536429-1-littlesmilingcloud%40gmail.com
Technical Details
Message-ID: <179627037924.3146.7104138756725327763@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!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-376276-linux-kernel-netdev=dewy.ru
References: <20261201005941.1536429-3-littlesmilingcloud@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!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-376276-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v7 2/5] erspan: take the COS from the mirrored
 frame, not from the tunnel family
Date: Thu, 03 Dec 2026 03:59:39 +0000
Organization: Usenet Network
Message-ID: <179627037924.3146.7104138756725327763@kernel.org>
References: <20261201005941.1536429-3-littlesmilingcloud@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2136470"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CVmnLN0wws2cJZv+/C16QOtNqcA= sha256:4yVOOekdZre4yUqqIXEFhGifAKzP4XvRwI8JT38WNuc=
	sha1:8lr8Ohz3mkxlM9kxdPqTzWrg8Kg= sha256:MJt1FuhPEocUTTtptwUy0idKH2bGpUTKkCHpFBo4uKk=
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 D242C117811; Thu,  3 Dec 2026 06:59:56 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[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 OC0zbL2Fd888;
	Thu,  3 Dec 2026 06:59:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376276-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 24F481174ED; Thu,  3 Dec 2026 06:59:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id B8665265C9; Thu,  3 Dec 2026 03:59:42 +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=1796270382;
	b=xJGOkWWIvoLAaB9YO7aqNDXEWJpJBN57OjnyhfrOFWs94X06R78Jqr7QAznubvwh35LJ
	 jLZTyXTem2W5ao2R8zl/Wa/y7mxfhpVnrhTbL5OJTcCnlzUEjM4Re9pbQiSZlfSsdx0lT
	 y3rv6JNwCFEVZ2NH/ug6RMMDOK7fK7cuj/tUWcV+hrow01bWsuj7OxMJdUesXE6EXsB6D
	 fSmKQw+w7QsI66OF8NE0OoiIqlS6L41wI2TjHzmP7tgj04BIv7K8O+VhPCaCIjgExx2Gl
	 HdHpMzs+stahpVcb5WXv3KiyeNEZrulgANw/sfBwF24/IE2BfPx/PKKsRg9UvmnTt5Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796270382;
	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=yxyurfhNplXDYNzEX/ejfJMkAVWGC6OvjxA8Trm0AMw=;
	b=2AYKmGYQpHqwm39PHhz+JxvN1eswFFUFyQM3SLgT0kjtUQDoY4jxQE4RVu4WwUlxTC8K
	 8Vo2RTj/3ePGNq6d9r+9INpk8GBGSsB4tPHBiCmLAqqS32tjETDGaaR8KH7NifPF5DvS5
	 3fFxV4cabm7vRavH+w3wydxgr16OSG6t3PVF5AziU1DY9YlBRYyfd2QKz2K2hb8P+iRCk
	 JhOOxJoFhN8IwN2807c1XygAKHmfwe7PM9Io/I7heabXmIcw3sWD/DuLmfKae2s4UvXA+
	 u2IWjy2sZOjbs+7RyhbFz0Td2+KwzQrD1pxkrxPYXvykfeNa//E+yeGqUHCcFjRJB1g==
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=NomIh3rz;
	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 EDEE9606A337;
	Thu,  3 Dec 2026 03:59:41 +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=NomIh3rz
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=1796270381;
	b=LeHi/4VssuGWIPL5tLjP/FK/nTsv3adKQhNLVa1tZnRzi56FM0gtnEEOiz5uV6OVLIEZ
	 r4zQr0lEp3cdtr2AnI3h5HIBt52RHw/mTl2XuWqcSozAfjxf1km9+hpAYtzJ2+2E6aobR
	 avKLxFPtQm8YwedPseH9gulMCIt7exbK7csFuivXnEJ5uQPAzXtf5yzQvZfxDlt1oh3Hp
	 EATwoAnHb6Q8ICeJRIkRU98lg4ZxdvDfL1lpl+pHXINodJwVQ51fnkYCbLmxEkRVUgbnQ
	 w0TWbIdNwaJ5pGwCdpBg/KSPmRgvA5JNj0WDVkAaKgbtpUlFWGoXHDSLXVBiKt2FXCQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796270381;
	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=yxyurfhNplXDYNzEX/ejfJMkAVWGC6OvjxA8Trm0AMw=;
	b=rUwaRJRwUs4NE0SImhLY+OgKpD/XhgiOjIxOP+1Q+twvwnFmoHDlgoWj/p4oISrWIcqV
	 o0tTsf3DLnJmwqhSGX6In9UQhbDq+byB1jJ7mjke9HxJpanrnkjfW2s+pEJP1f2LG490I
	 o6pwUlU5Gp6cbH6rbNZTfr5U2IbTFZLNXR+Ajt8LzEOUVE/PTdf/6vKCJKCaqK8Cocjkv
	 9/9nMvmpznNDQrWEcWUt5f3Qml7LKpBHgkSNBJumTolavU3v4qMbPge1lzENNgZ47ImnX
	 weSrhdyb49hBinKUuoNNUEYRl/f6jk50HUsHh4BiiCmOFxshisjWEN60F3xRzWJHdPw==
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=NomIh3rz;
	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 19E8E606A322;
	Thu,  3 Dec 2026 03:59:40 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B56EC1F00893;
	Thu,  3 Dec 2026 03:59:39 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796270380;
	bh=yxyurfhNplXDYNzEX/ejfJMkAVWGC6OvjxA8Trm0AMw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=NomIh3rzrbZklG93D3eGUmijOzLSRNN+nm12Y7CMzggswzBS3TCA9qQKGVomOFThI
	 3KKMolsCtsTHRd3ZRz3WbSlALk1xJO/MWTRTqfo81jMPAxUcm49Ava4oFmG+tBvgnA
	 OzVKQZywbZSegzfgP5E8fSzNy59cGoujExkfF6m5xCoukExkDmuutDFzrukET2r0W2
	 tyWsSj5CaKqjrU5Sdbnh7wQBqMw2b/m7lGBTdpMLuXQIa5r5/inH8KpgxXKmbS3IG8
	 70LCLqbebayp/REnRQjzPwV+BcXsznG8Jzlj1wvuiVOznYG3kiFAijxGpFvWpJt3Cc
	 6SkgCEgC3nkmg==
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: <20261201005941.1536429-3-littlesmilingcloud@gmail.com>
X-sashiko-severity: Low
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