🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12290

[PATCH net] net: gro: compare skb->protocol in gro_list_prepare()

#12290
From: Eric Dumazet
Date: Fri, 06 Nov 2026 19:51
49 lines
9540 bytes
gro_list_prepare() checks whether a held packet may belong to the same
flow as the incoming one by comparing the device, VLAN tag, metadata
and the link-layer header, using dev->hard_header_len as its length.

On devices without a link-layer header (hard_header_len == 0), such as
L3 GRE tunnels, no compared byte carries the outer protocol:
skb->protocol comes from the tunnel header. Packets of different
protocols can then stay eligible, and the GRO handler selected from the
incoming skb->protocol parses the held packet with the wrong layout.

For example, take an IPv4/UDP packet held by UDP GRO and a
VLAN/IPv4/TCP packet received on the same ipgre device.
vlan_gro_receive() reads the first four bytes of the held IPv4 header
as a VLAN header. With crafted values, the held packet survives up to
tcp_gro_receive(), which uses its UDP header as a TCP header. With a
short linear part, the FIN/PSH update of the held packet's TCP flags
can then write into skb_shared_info.

Nested GRO handlers (VLAN, GRE, IPv4, IPv6) already compare their own
next-protocol field. Only the outermost protocol was not checked.

Compare skb->protocol too. On Ethernet devices this is redundant with
compare_ether_header(), but it is cheap.

Fixes: 60769a5dcd87 ("ipv4: gre: add GRO capability")
Reported-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Eric Dumaze <edumazet@kernel.org>
---
This issue was discovered by an AI code review agent. It has not been
triggered, and the fix was only compile-tested.

 net/core/gro.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/gro.c b/net/core/gro.c
index 1b033855a20db6b8b996179f0b81e38393d3864a..08e4731ddb7e6e371790d70a97db2cedad420706 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -374,6 +374,7 @@ static void gro_list_prepare(const struct list_head *head,
 		}
 
 		diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
+		diffs |= p->protocol != skb->protocol;
 		diffs |= p->vlan_all ^ skb->vlan_all;
 		diffs |= skb_metadata_differs(p, skb);
 		if (maclen == ETH_HLEN)
-- 
2.53.0
Technical Details
Message-ID: <20261106195136.2496777-1-edumazet@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358141-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358141-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net: gro: compare skb->protocol in gro_list_prepare()
Date: Fri,  6 Nov 2026 20:51:36 +0100
Organization: Usenet Network
Message-ID: <20261106195136.2496777-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3961850"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8ok3pC1n2w2/ncdxxrXDDIl8yig= sha256:Bq6rC7toKtzm/geDXpAJ1Kxj8RhzBhgjXr+y+3JokX0=
	sha1:+jULBlTXqNUKeRu7qzIqtcw4DVs= sha256:rFLH154lIm4UHJe85q/4Mr1MaY24jrhzGGPM7Jk3tJY=
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 5BE8111330D; Fri,  6 Nov 2026 22:52:28 +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 P7MuS8-9I9JU;
	Fri,  6 Nov 2026 22:52:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358141-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 586DC1132DD; Fri,  6 Nov 2026 22:52:12 +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 9E8E328AE2; Fri,  6 Nov 2026 19:51:44 +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=1793994701;
	b=nIRtRhmzwdFwGBNtEAZHZIPMrIvPrOVqgaKJAi+KlOySmP8fyIlGACBg2IzoNbNNstCo
	 M6HQfogMZad4RU1i1xMm1kmfNOZ8caxRVTZzQlT+ZaYNMWVrkOVdb61NHj4CGlWo4x6H+
	 gaM6vm/BPQqxJ/YTzxCEh6k6UqeijJ6o++3CVOrxboRS+/xg2GRLuDo339cTvurMbkKxc
	 g4VHwOC30JVxdw6Vo9Zd3I0RaxDmB7zpHqWSGqgaVb1agByvnhDPSMzjdkU2ewt/pzVKr
	 3WG2nqe6EKqIoGxALTbZWeDVFBFbXAjBaJ1YiofQuune5aPFbciVhUHoQg6VUF88dwA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793994701;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=RDKsoNr2jJ1IMKU8z1NYqPXUJQ7ll2AvH1O+SQHtBh4=;
	b=tphCeQYqwjvCwLWTTM/HF8raRYKGLUPAfBHpJ+Ln0LlXptdY3IzVLEMTYL8Be3sE2bHo
	 g2jfLdupHYFAL/XOybrMWFCO1CzutklWMYagpZek2W6YrjBJWeAwFqVi/tFmtnWCqWx29
	 mtfwZy0AjlEEY69hDRk5OuwgbPOuhpzyfBCoyH7n+0f636QkCCRW8fQTmghCHNpisHl4m
	 sioQzhzz06Hv9woS9m6jbpzjz8El7n/sYefx7dMW67SVYoTcMMbD3EncfNfj2KBTvjx/Q
	 Lpo4GQLomKrPHMEhOPWY0+bLSc6ny14WV9iAfQKpFsSigbkVORDFg1QsgGwchz7/4Ig==
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=Vf8ezrG+;
	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 8DFC5606A337;
	Fri,  6 Nov 2026 19:51:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Vf8ezrG+
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=1793994700;
	b=OGWwRggOpxSXarQkwD+SMb2mC/TjHTmzbYNocgshpi3ucqfhAtXtttp72i7n1kUd1xY/
	 IFviE12imwtw86EGhgik5jwsIgu5Ij4iwxCcAuM94pT3/jphT/bW1zMDZqZbVC0HVeZil
	 Zagv0bqaKY+xZX5p1tR6bORxxZjrF35bSJNbfw2HLqn5ns3GfNljd9jtTZ8GgI+GbLSbo
	 DMnFg0ISbDa09x82i6/fQEDxg+AMirEAWGcapvd4c6CeYRvygueGeZdheitB9l3QUwjB4
	 5Kh3k59mILc8BYIm3VaCZNaFMopx8I3dm2kxP+m3qvu54ChGLmbqkfelD+sYb7/styw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793994700;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=RDKsoNr2jJ1IMKU8z1NYqPXUJQ7ll2AvH1O+SQHtBh4=;
	b=fB9tlg+P56CrdwByPRnGCs+gt6HVrV2kzjW4Yse3S4xwWj6B2BaWVzvR/wDBkSQu3yrI
	 pv5uLalURO2Mh4i4onwME/LI7n6bXc1yM4JZ1+bwThIEoC6QKepyAzlOP1/GbGAOrMhCY
	 PSiSLjWRIG6z+6hjXj75JJ7mOrkavALNKRbWHbvmtqNHa6x9sGuS/FCfAazJ88uCQ9dtS
	 wUeq+uwP1jWCYh7qJhfijTS71wg6d7hw4CUgGjI8oswFl4gGr463SilT46K1MPoMj+rQ/
	 pXr5rkd0ixeLhfafDdv6/yJ7nldZGsNAPhOmAD3/KRRl48n/yrryGqL8hSzxzpKV/Kg==
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=Vf8ezrG+;
	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 71F16606A32C
	for <netdev@vger.kernel.org>; Fri,  6 Nov 2026 19:51:40 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C051F008A4;
	Fri,  6 Nov 2026 19:51:37 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793994700;
	bh=RDKsoNr2jJ1IMKU8z1NYqPXUJQ7ll2AvH1O+SQHtBh4=;
	h=From:To:Cc:Subject:Date;
	b=Vf8ezrG+u1nx4JuHzfyKNxU4FpRYa1EoH+nr+NZvdNnQzS5ugDhzJ/tpQyBINxR4N
	 MKYhLBwDHYunS6tVkxL5PD3Q9tYFolJCeZYGjPBRoNH/RxACOUF8ze2GoaOrIo9Ysl
	 f7Uah+xiA6jK/14O6tpP95cz9yufJXK26oprqBy/HpZbV2aEAEf29AJi9fsW9diMYh
	 NShLakFgB2yJKseqlw5XlqLRa82rJ6i0+GUcbth3oqVyv6u0DfkwnykMmaFmytyDl1
	 tv6o7AUtMSsBnldTmDX4dbJIrhumFJHxTrsnAU+5qN/Oz+byswtGIgW6u3yhOkkuAW
	 sJbPXnXqRheTA==
X-Cc: Kuniyuki Iwashima <kuniyu@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,
	Eric Dumazet <edumazet@kernel.org>,
	Kyle Zeng <kylebot@openai.com>
X-Mailer: git-send-email 2.53.0
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