🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10982

Re: [PATCH net v3 2/2] net: gro: invalidate frag0 after a pull

#10982
From: netdev-bot+sashiko
Date: Wed, 04 Nov 2026 14:00
121 lines
12030 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] The patch adds a fallback in gro_try_pull_from_frag0()
  (net/core/gro.c:465): when frag0_len is 0 it calls `pskb_may_pull(skb,…

--

net: gro: invalidate frag0 after a pull

This patch adds skb_gro_frag0_invalidate(), which clears
NAPI_GRO_CB(skb)->frag0_len. It is called before the pulls in
skb_gro_header_slow(), skb_gro_receive_list(), udp_gro_receive_segment(),
esp4_gro_receive() and esp6_gro_receive(). It also changes
gro_try_pull_from_frag0() so it copies from frag0 only while frag0_len is
not zero, and falls back to pskb_may_pull() otherwise.

> diff --git a/net/core/gro.c b/net/core/gro.c
> index 1b033855a20db..49e7f64f27756 100644
> --- a/net/core/gro.c
> +++ b/net/core/gro.c

[ ... ]

> @@ -454,8 +455,14 @@ static void gro_try_pull_from_frag0(struct sk_buff *skb)
>  {
>  	int grow = skb_gro_offset(skb) - skb_headlen(skb);
>  
> -	if (grow > 0)
> +	if (grow <= 0)
> +		return;
> +
> +	/* frag0 can only be used if no pull happened. */
> +	if (likely(NAPI_GRO_CB(skb)->frag0_len))
>  		gro_pull_from_frag0(skb, grow);
> +	else
> +		pskb_may_pull(skb, skb_gro_offset(skb));
>  }

[Severity: Medium]

Is it safe to ignore the return value of pskb_may_pull() here?

gro_try_pull_from_frag0() still returns void. Before calling it,
dev_gro_receive() has already incremented gro_list->count (or called
gro_flush_oldest()). After it returns, the skb is held unconditionally:

net/core/gro.c:dev_gro_receive() {
    ...
	if (unlikely(gro_list->count >= MAX_GRO_SKBS))
		gro_flush_oldest(gro, &gro_list->list);
	else
		gro_list->count++;

	/* Must be called before setting NAPI_GRO_CB(skb)->{age|last} */
	gro_try_pull_from_frag0(skb);
	...
	list_add(&skb->list, &gro_list->list);
	ret = GRO_HELD;
    ...
}

Before this patch, gro_pull_from_frag0() was the only thing done here,
and it could not fail because frag0_len is bounded by the tailroom.

One way to reach this point with frag0_len == 0 is through
esp4_gro_receive() and esp6_gro_receive(). With this patch they do:

	skb_gro_frag0_invalidate(skb);
	if (!pskb_pull(skb, offset))
		return NULL;

This returns without setting NAPI_GRO_CB(skb)->flush. For an ordinary
unfragmented IPv4 packet, inet_gro_receive() computes flush as 0, so
dev_gro_receive() takes the GRO_HELD path.

offset == skb_gro_offset(skb), so the retry in gro_try_pull_from_frag0()
is the same pull that just failed.

If the held skb's linear area does not reach skb_gro_offset(), later
packets in the same bucket would read stale tailroom bytes as headers:

net/ipv4/af_inet.c:inet_gro_receive() {
    ...
		iph2 = (struct iphdr *)(p->data + off);
    ...
}

The same applies to ipv6_gro_receive(), udp_gro_receive() and the
tcp_hdr(p)/udp_hdr(p) lookups.

If one of these bogus headers matches and a merge happens,
inet_gro_complete() writes tot_len and check through skb->data + nhoff.
Those writes would go into tailroom rather than the real header, and the
aggregated packet would keep its original single-segment tot_len.

The window looks narrow. The retry can only fail for an skb that entered
GRO with headlen == 0 and frags[0] mapped as frag0, and that skb must
also be either:

  - cloned, with pskb_expand_head(..., GFP_ATOMIC) failing, or
  - carrying unreadable frags while frags[0] is a normal page.

No concrete in-tree source of such skbs has been identified, but they
don't look impossible either.

Could gro_try_pull_from_frag0() return a bool? On failure,
dev_gro_receive() could undo the count change and take the normal path
instead of holding the skb.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261103105752.49542-1-edumazet%40kernel.org
Technical Details
Message-ID: <179380083773.488856.10057167003627471575@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-356467-linux-kernel-netdev=dewy.ru
References: <20261103105752.49542-3-edumazet@kernel.org>

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-356467-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 2/2] net: gro: invalidate frag0 after a pull
Date: Wed, 04 Nov 2026 14:00:37 +0000
Organization: Usenet Network
Message-ID: <179380083773.488856.10057167003627471575@kernel.org>
References: <20261103105752.49542-3-edumazet@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3403803"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:5uGaaWusTet9ZAJHh9xGkyXDiAs= sha256:RNB7pTwmeSHesrDEXsfcEtSZUXMr/Z8wVjJUTNnkulA=
	sha1:YVcN9eVwSSRsiM9aIJ367eBC5II= sha256:2hfSsphB4cQDKNxCUNz7VpHClC3HqfwVxIvtR092omI=
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 3B1AD112BE9; Wed,  4 Nov 2026 17:04:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 ussTQVxSW3z3;
	Wed,  4 Nov 2026 17:03:58 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-356467-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 83665112B88; Wed,  4 Nov 2026 17:03:50 +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 CC37930EF7; Wed,  4 Nov 2026 14:00:45 +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=1793800845;
	b=LpjB8O4EvXrhcUj1QRvoCpSDep2IDOk4tljCagq7xOH6HUbJLN+va5q8GNIxMy0bwVoj
	 1in7gdkFMxv+X2XJv8U1keuwfqgYfm8/oai5+36KmAqYaddYUVgF/4ji0zBe7DhSCuzao
	 2xWFUixqMWg8MVGwxrMa4deoQTwTE6aSII1B7BWxQkXUg3Dd3FQadqPOXPqlC8u1y0yS/
	 xB8lA30booV6nf/oeTzHN3eV6sTEVSSk1sE9mQnaPRiymx9k+UwAW4CV6Vy7mswYfIadx
	 eF++TCNeu1TCmr8UDXT7BZ41ZfGSQGznkxz23dUIMDTJldIPhRqtGLZfq1q+WFzClWw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793800845;
	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=yGD/A7wahWxDdc+IkOL3MU18AaU2I8e2m4Z/ARdxUgY=;
	b=DC2Q2aX9tQ7vT5Hmxh4E1PdZGkzrCox+n8eU6HpQFHMzfiLysRzJWSxoGZ4foFDZDlnN
	 kDVJ0o6cUmFDs9cD/O1cqNIFu1Rky41qkSJ6loqXmCR8KRHEJZ3PFEa2Rx30rpgntrUHn
	 3A7wMjgneolDS+gMddaGhmHWjod+CoQw+BbZZ/XdW67NTQ0C/JL0eE//VSQot671YEsXd
	 dSxb56e87Kg+iEt/vaJWWolQg8q+uAZb+j6+hsvwYFU5CVFmkb6y4ZbR33D/DXL85oZaj
	 uVizn1bUg4E7lOY25oSoCkSdUJA95d8IKz5X3YE4RPzpVpjc4MJMyo+Itv0pOiblhbA==
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=ghAQ5d2G;
	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 6390C606A31B;
	Wed,  4 Nov 2026 14:00:45 +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=ghAQ5d2G
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=1793800839;
	b=kHCX41fpYjgskvklhZzkmCjGXHOWUNYzLsrhYgzzMt5GNUR8ognETB9xLMN3NtjQia+u
	 u6o17P2CChD7iQZYcBg/HlepteAVkPusyS1hDo35pNMuFwhUapSzXwNuaGSgZyShikpHg
	 LmopddY2Z+y63W5VgvB0A6YtdXKteS2qI8qoTkuxYsD/SgUQzhKM5Sr95uex4z0KJ81sB
	 g0/596VT1nDn+3m8gD+qwmsMu31E5zV6YX8r1EwUZ9xYlm1aombWqHELDkenZPnyoZFmp
	 pwfpenFC/1z1dcx6o2Xvlj06jFxYEk7oxi0Y/oMXAblMhs6bMAcMDJp0axU575Je9tw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793800839;
	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=yGD/A7wahWxDdc+IkOL3MU18AaU2I8e2m4Z/ARdxUgY=;
	b=g0E15MGtzmmdzr4DaElAP4h2nmNeg9R9a77VC/qCC9QknD8sk3dMKL6xf70YCDtOb9wp
	 ZKQBhlJAOP70IYrmoePLSQZLIQCOMT/Iassz1swWdgFwnnGJ3ce9G6BWvSEWHD4hPS8Cr
	 xaVFmow7o3F3SM4LBe1nyteSudDYSCFTlOEFzKoDbY2xLYLkt7hAxBRU74vsZzba0YbM/
	 kyv2NLkS7jcru8wa5T+Stjy5CzBd/nOyD1iCE9cENci0mPXFPt5v6qXOmW67wz2aGdsUz
	 RMN46xp8LI67gpDWo+qht4b8HKFqbnRUSrYKvc5tconoF6ZYseviqX4w86Wg+DxPNsg==
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=ghAQ5d2G;
	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 411B5606A329;
	Wed,  4 Nov 2026 14:00:38 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 259EB1F00A15;
	Wed,  4 Nov 2026 14:00:38 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793800838;
	bh=yGD/A7wahWxDdc+IkOL3MU18AaU2I8e2m4Z/ARdxUgY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ghAQ5d2G7fy0GRrNGqDxEQmkxuM1RE2ZFFtUh2UuUYP341z2DrHB1odlOdI8Nv1Xb
	 hyGMYYJRy4EtBaiOBo1ywoVP6sIEeg6UOSqiyurnr1gpxIjreVnhMVmCMv8EWLIgjG
	 NK6vULPjJ9y/ZYRp64FmbF6qeNjF3sL1qOD7ItphmL6CNW8BHuU9V2fd0oPhM2IQ77
	 DDUcR9IyClg+OJEy+2PbTyGDLTPhS3jY/g6MENT9IQuSqa5QUX6AJf/MUUdarAhl5E
	 O4H98+0JFmFR4b+mEItpNlKei/UGjNFUnkDc/jL3r+91R+ZN29xsmuVjE4CGDVSZif
	 iuMS6P7JyjHdA==
X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 netdev@vger.kernel.org, willemb@google.com, steffen.klassert@secunet.com,
 tom@herbertland.com, cenzhang@linux.microsoft.com,
 AutonomousCodeSecurity@microsoft.com, stable@vger.kernel.org,
 tsgatesv@gmail.com
X-In-Reply-To: <20261103105752.49542-3-edumazet@kernel.org>
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