🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8319

[PATCH net] gro: do not GRO GSO packets with inconsistent payload

#8319
From: Eric Dumazet
Date: Wed, 28 Oct 2026 17:13
79 lines
10741 bytes
From: Kyle Zeng <kylebot@openai.com>

tcp_gro_receive() excludes empty non-GSO packets with the unsigned
len - 1 check, but its GSO branch only checks that gso_size matches
the held packet's MSS. A trusted TCP GSO skb can reach GRO again with
no payload after TC pedit increases its TCP data offset.

If the skb is fully linear, skb_gro_receive() then enters its fragment
transfer path with nr_frags == 0. The do-while loop copies skb_frag_t
entries backwards beyond both fragment arrays. An unprivileged process
using its own user and network namespaces can trigger a KASAN
slab-out-of-bounds write and panic through veth, pedit and GRE.

More generally, the payload of such a packet can be shrunk to any
value, making it inconsistent with its gso_segs, and a GSO packet
with gso_segs == 0 contributes no segment to the GRO packet.

Do not aggregate GSO packets with gso_segs == 0, and require the
payload of GSO packets to be consistent with gso_segs and gso_size,
the last segment being allowed to be short. This rejects the empty
skb before either TCP merge helper, and covers both IPv4 and IPv6.

Fixes: 5eddb24901ee ("gro: add support of (hw)gro packets to gro stack")
Signed-off-by: Kyle Zeng <kylebot@openai.com>
[edumazet: check payload against gso_segs, refuse gso_segs == 0]
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
 net/core/gro.c         |  5 +++--
 net/ipv4/tcp_offload.c | 12 +++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/net/core/gro.c b/net/core/gro.c
index ff828a3dce3ca649e149a840bd6e3dfd9ddaf0c4..1b033855a20db6b8b996179f0b81e38393d3864a 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -513,9 +513,10 @@ static enum gro_result dev_gro_receive(struct gro_node *gro,
 	NAPI_GRO_CB(skb)->count = 1;
 	if (unlikely(skb_is_gso(skb))) {
 		NAPI_GRO_CB(skb)->count = skb_shinfo(skb)->gso_segs;
-		/* Only support TCP and non DODGY users. */
+		/* Only support TCP and non DODGY users, with a sane gso_segs. */
 		if (!skb_is_gso_tcp(skb) ||
-		    (skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
+		    (skb_shinfo(skb)->gso_type & SKB_GSO_DODGY) ||
+		    !NAPI_GRO_CB(skb)->count)
 			NAPI_GRO_CB(skb)->flush = 1;
 	}
 
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index e74d99ca9face6ecb853e928b538bd66a377038c..b84fcd07c7230fc3230fdbc3a79d68d1e79b058e 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -315,14 +315,20 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
 
 	mss = skb_shinfo(p)->gso_size;
 
-	/* If skb is a GRO packet, make sure its gso_size matches prior packet mss.
+	/* If skb is a GRO packet, make sure its gso_size matches prior packet
+	 * mss, and that its payload is consistent with its gso_segs
+	 * (the last segment can be short).
 	 * If it is a single frame, do not aggregate it if its length
 	 * is bigger than our mss.
 	 */
-	if (unlikely(skb_is_gso(skb)))
+	if (unlikely(skb_is_gso(skb))) {
+		unsigned int segs = NAPI_GRO_CB(skb)->count;
+
 		flush |= (mss != skb_shinfo(skb)->gso_size);
-	else
+		flush |= len <= (segs - 1) * mss || len > segs * mss;
+	} else {
 		flush |= (len - 1) >= mss;
+	}
 
 	flush |= (ntohl(th2->seq) + skb_gro_len(p)) ^ ntohl(th->seq);
 	flush |= skb_cmp_decrypted(p, skb);
-- 
2.53.0
Technical Details
Message-ID: <20261028171350.2205175-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-352963-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-352963-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] gro: do not GRO GSO packets with inconsistent payload
Date: Wed, 28 Oct 2026 18:13:50 +0100
Organization: Usenet Network
Message-ID: <20261028171350.2205175-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1822326"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Vvg9Dg6qx+6iIxBnCk+wd6McoiQ= sha256:A16eATvc1RGS0sMtTihVRQZHjSgHEuvb6U3QkVjZ0U0=
	sha1:DSy6jmBHsixxzXkH/6/GHS1iuB8= sha256:Gnq8qJVogqTIB6F2s+iDnMP3vZRvMI7RcnfhY6cSVDA=
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 0D47F125C43; Wed, 28 Oct 2026 20:16:59 +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 CUgm1hRyaF7H;
	Wed, 28 Oct 2026 20:16:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-352963-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 332D0125C3F; Wed, 28 Oct 2026 20:16:48 +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 7D9002DD9D; Wed, 28 Oct 2026 17:13:57 +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=1793207636;
	b=U/1FkOsk9rifjL1MWuLbhxZjSSScP1bMA6PCqxf598Bzo61p5/T/oXBMoSqUN4Y9tGNh
	 LqNy0gfV39jQhraTJHUuHENNv+v/4mmBytcFcH55uQFWu56n3+rXzSHF+bZclCg/Nb5yT
	 KaYMJ1Nmo2fsdRNpJ+uHFbo2hvuCyHIjRGfYywAw/UdkxaJIecuAON+Ht+jS4uwkPom4E
	 nZU3EfIgGWLCSTHE0FqJUFkXHqfo326d8kcB40jGt+zKcJu4SsNZhMfyawkmc3Tf7p9mW
	 s783ooiMXCrfgitTXFjyv2BBJwf82De9BQZ3CtORAVna33DdeJfvcYm+n5etlS4ooNg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793207636;
	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=8ygq7n7ygg1HJ4wA7Hep+kUYmpc7u7VZNcY/7P4cm0k=;
	b=lVXVdpAFDE23PWhWacRdO2t4vLQCKSSaLroKQNaEFOKTEsdAr2YN6TVySFFV5YzD+Ilf
	 8HIImOd0NWQQ/WPqXICBbEE+MXaYpgu5i7An2oYMhF5wfxx4x6eG0WXwWyQ8/zBQyl0Wv
	 avS4bCvv5ByDgGOoz0bvP8+o7p29EaWw+UBTkCbW57R+fDOSI7uigfX/v5jb4vHdf1XIC
	 CNWHuDgPSEAGVhzpinQm/4JI2TDX6Kl6Y08zlVC9kG3XQs1onG/8MEjPQWVn7XeVBIeCi
	 es167TMrQ0QmtrjBMz3FKyZrhjP8UWsNJx/kdmeZGB0osYjtOPUJmzjTwqD2K3PYukQ==
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=EMe9zc88;
	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 E9A55606A31C;
	Wed, 28 Oct 2026 17:13:55 +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=EMe9zc88
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=1793207635;
	b=F3YZt0cmHqJTfc0F3FAB6FULYH/9OgwYIMpSfKz5/WCevnHdhBXRm+kVS8VPjt3G80ye
	 zQtrJd79jtfa4BZ+dJTV280n1nBWawG58SPN+aAkWCfIvz1cFE6Ib/8J7EkF5R/3wrTaW
	 RIPlbWc6Q343htnscfVVdt9gFbH5egkJ0A27KLjL79l7p92iazHRYcZihHpLMDMwVd99R
	 ZltwOUOCjA7+4afrvbgAksSQ60NCzaYdgzjL+MvB6nQ1IZnTvoWcs9oXQOB9cV49MN7x9
	 3THsdtWcj9FFyCKpjpO3ScGnlEH8sL5MLnCvK7uMzPGkWHwAhYj7PCnbSeZOnVdrBsQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793207635;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding;
	bh=8ygq7n7ygg1HJ4wA7Hep+kUYmpc7u7VZNcY/7P4cm0k=;
	b=wclyMuoWGCMv/EsQyNZZP0DZE4fJ52crHLb6sBROA1CWcQ49Envfx3oqslpFiuOVcZcS
	 Qg73z5c21oPym+HZ1xIEO66oIPhOx9EuZhLaD6amrvgbku8oon/BPRg/vll9+tdFGc8bJ
	 rtdt6hhUF/RntzlxbFtpQzjQYP/2PDpdUNvDIGsQR8+kozdebUhW9phzJfUJdfzh5mPZu
	 /3sjU0zr5U1U72EZHztPNxrI9Arm7dDEQyRTrsMoNsUDh0Kis5GL/cVWtXaQsHqzHnRim
	 OMDi/ILc0TRdM8CTglB6Wmth0UUP91hjjxjpHlu180jpOOTHhfYxUOGe1q5UKruOkDw==
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=EMe9zc88;
	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 C9661606A320
	for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 17:13:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 989BD1F01828;
	Wed, 28 Oct 2026 17:13:52 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793207634;
	bh=8ygq7n7ygg1HJ4wA7Hep+kUYmpc7u7VZNcY/7P4cm0k=;
	h=From:To:Cc:Subject:Date;
	b=EMe9zc88uObPMB/EGrnlhFtTZgC24YsFW3tpYy2+uonHXL0Jc7lb6/JuO4KAr+GQ7
	 gkHch+dxkvRSSYllrkXmrqT45w9xCkiQJ2Ce1MX/Fd7acDFu0iQ6F3ijY6B9NOIL+V
	 XhFCbrL0pTuikPglqgcGnWZodsrD4xVHIToOoPU2Tj133zyLDoqI1Bzhz4Mgn4sFew
	 stv1x2SpMoacRiOXU9dJ+E8PXDhVbubn+ua+VwZPnH4GyHHMlPuEQa3wm3cYZqwx59
	 Nq8Frz2aRKzWDgsMZ0d+/FD4C+8v/E9/NX4ep+PG/pL7JcJtZA8kwXT31BilTaIyql
	 oI9Bb6ryyJSNQ==
X-Cc: Simon Horman <horms@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	netdev@vger.kernel.org,
	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