🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13315

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

#13315
From: Eric Dumazet
Date: Mon, 09 Nov 2026 16:45
62 lines
9970 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.

The VLAN, GRE, IPv4 and IPv6 GRO handlers compare the next-protocol
field of their own header, so once the outer protocol matches, the
inner layers are checked too. Only the outermost protocol was not
compared.

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

GUE direct IP encapsulation has a similar issue, but there both packets
have the same outer protocol, so it is fixed separately in
gue_gro_receive().

Fixes: 60769a5dcd87 ("ipv4: gre: add GRO capability")
Reported-by: Kyle Zeng <kylebot@openai.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
v2:
 - Fix Signed-off-by typo (Sashiko).
 - Mention that the GUE direct IP case is fixed separately (Sashiko).
 - Add Willem's Reviewed-by.
v1: https://lore.kernel.org/netdev/20261106195136.2496777-1-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: <20261109164540.3104392-1-edumazet@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359458-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359458-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v2 net] net: gro: compare skb->protocol in gro_list_prepare()
Date: Mon,  9 Nov 2026 17:45:40 +0100
Organization: Usenet Network
Message-ID: <20261109164540.3104392-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="404359"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:uBJcY+mCgcRJQTZB4OB6EVW7a7g= sha256:+uIiovq0HSalda8hTStH6tfMNCbmumeVqCJgVgVVl5s=
	sha1:9SczzDKuL8XhSLKTewvKG8DCmT8= sha256:O1HoMhhAJ0SGtt7UZHoCGWUHPN1YBDeV9WCEPEi9yZI=
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 B3101113894; Mon,  9 Nov 2026 19:52:24 +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 oZ9Yl6Qmd7zI;
	Mon,  9 Nov 2026 19:52:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-359458-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id BDDCE113891; Mon,  9 Nov 2026 19:52:06 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id E3F4D626BAD; Mon,  9 Nov 2026 16:46:47 +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=1794242757;
	b=Uw5ZsuZw6fgDGEoCAAbFcUx3gIH18KmHQ+2fZFT+haFKqCofxx5DiZH+9QEWk8LfmaPP
	 Yhu77Xc0xxMLR6Mt9pItGP8tGPvnqtCpNpVEgsc9a8X1xTPj4M2YngCaKtBWjsYM7afsZ
	 qUObLW1PMj73TT8ab+Xb0wMfHTZDmfVx5hMNZJr4qg64mERapPu2Kp+IPrBee237V2zwe
	 FJl+m/MCjzUtxcnea66Zftbi4wS0zhvSaCs/NcOFuIbFatwDB3MMVgHwgyRDDxaJK1MQZ
	 DUTQ4l0x60Ip8D5vwtujHhXREAahrHyeNTfNU0FfO6mpUZL7k5ovkh7cNpkoUmyZsOA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794242757;
	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=glHxRHGLGburtlVRhRiEZ8wZhPoTMq0AfgvHYwC5Rek=;
	b=xjToSwwMD41+I4XrvDiMBjfqWYqrLbGeX8Ty+nkD6MZRaJgsZvVHrjTeSjps0H2PDuEg
	 tXdMa6Ns1HE5v7bc2vkXIinp3+/s93kPCL2eLk6C/ZNCDvADA1vyrauMuXVIseWoAaay4
	 3Zr9NPDoDLaEA8zpHYksRIzRvPKZShphsSHgsXekGAIM1unxE8gmblXoC7hoHvXFnV4wv
	 swqGiVdZ9biBB0GxzZ7qqHdlHFZzng9rP6KG1gCQh6Szie1vDuaIG9MrLEzC3f4qP060s
	 zK8GPxxz+s+dFzsi363kNOgswRH1Rz6Dj+YsZ0Kz9uuLWT+1KKT9WufM11x7MTTg+Rw==
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=k+Grw9ex;
	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 932BF60A261E;
	Mon,  9 Nov 2026 16:45:57 +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=k+Grw9ex
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=1794242756;
	b=0RHMYOKFz3Ge0oxKaQtv+nOuRvFStbLwpTYYS92yZfOYqYK2gQ28S5VasKgnSMkSJyEN
	 JiXFzeIMeMYgdP67VZdhBDHrMS5OU1CXG0mNwJRRYqW5Ajr2+5OkIsnnY+Mlv5Eek5m/Z
	 dYDEhYA1t3d/XBgf7ZXaCEtCuzjVATMqDA6BA/LDJdRS9GHqF03npfZ/5MJhTMYX0/Jah
	 JxpSHbinYHwtqlzkTxqMKgiCqD5cTUq57N5TKJ+L37MYXqfsoyJNr1qEW8MnQD6mkNzn/
	 7OCnEVzBstq+WM63m2l7SOfnPm5sOtF8j69EKmrA7wQwz8OwyV05iYrYl4lI3V6SfvQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794242756;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=glHxRHGLGburtlVRhRiEZ8wZhPoTMq0AfgvHYwC5Rek=;
	b=XVyfPDbG1lYJG0gjbdXkBax6XBJl+uvzeNICCEBdM787f7Mqyf+3k88jrA5CSyF9b9GO
	 7MivGfjjLDQTRsLQ4YFvfI6PA7TEAlWASBWAEP9LJO5di8H1dvsEC/Ymozke3Now/psbN
	 Vy6Gd2I0uyFfwasp1mOz4jq8Cc2DQHr6jgmhePbRFEBxU6phhaC+ACPxry+I39om7y7rt
	 Mch2shtnfjjOtgVYGuLHZW/vnHUcS0ePVv1tHjCo0fqdPE+X09reGiWBAyBHnHuuf9OeW
	 e++UFa0s2Ey1i0eS8rvIo6AwMQNxYujwiUtauWMF8AkNVvRWhE1gXkgb3mf9gTE51bQ==
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=k+Grw9ex;
	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 78614606EEA3
	for <netdev@vger.kernel.org>; Mon,  9 Nov 2026 16:45:56 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4179F1F008A1;
	Mon,  9 Nov 2026 16:45:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794242756;
	bh=glHxRHGLGburtlVRhRiEZ8wZhPoTMq0AfgvHYwC5Rek=;
	h=From:To:Cc:Subject:Date;
	b=k+Grw9exyxqBA5rlN5UUjPeFiBhPPqkbonQSHguvyJWXJrJCLbuwvakQmFZcZOMLy
	 svDgwG9RtFw5lxUL6gyitBTe2UQLa36mNieNbqJLZoungIYjTnMU+zB99EYlqeWAGG
	 0CKzVuKCPhMh2iozu3ANb/5NxSEdcu1iUP+S4l0+q2vHa+WUrxTDo6dmp1PJQRr8aE
	 PqS7dG+Tk2yqOifdSKH3e5brB/0Vk7x7gapMmW4uDfjBGkhBVIDHnfNPkUlDIVBD8V
	 PPHS8DFHeGZkSh1PuJcuzCjbXrwqVzR1Czo1eOmoN7Jp5CQBr97iJca/zoJD6JXRav
	 Py/JBRo+ncqbw==
X-Cc: Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org,
	Eric Dumazet <edumazet@kernel.org>,
	Kyle Zeng <kylebot@openai.com>,
	Willem de Bruijn <willemb@google.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