Article View: linux.kernel.netdev
Article #9644Re: [PATCH net v2 2/2] net: gro: invalidate frag0 after a pull
From: netdev-bot+sashiko
Date: Mon, 02 Nov 2026 13:00
Date: Mon, 02 Nov 2026 13:00
159 lines
14124 bytes
14124 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 0 · 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).
- [High] net: gro: packet corruption in gro_pull_from_frag0() after
failed pull
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
`napi_gro_frags()` (net/core/gro.c:783-794) never checks the result of…
--
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 slow pulls in
skb_gro_header_slow(), skb_gro_receive_list(), esp4_gro_receive(),
esp6_gro_receive() and udp_gro_receive_segment(). This keeps later GRO
header accesses from using a frag0 pointer that the pull may have
released or reallocated.
> diff --git a/include/net/gro.h b/include/net/gro.h
> index 00b49b6b9e74f..6f6affc8ab91c 100644
> --- a/include/net/gro.h
> +++ b/include/net/gro.h
> @@ -160,9 +160,19 @@ static inline bool skb_gro_may_pull(const struct sk_buff *skb,
> return likely(hlen <= NAPI_GRO_CB(skb)->frag0_len);
> }
>
> +/* A pull can release the page fragment frag0 points to, or reallocate
> + * skb->head, even if it fails. Call this before the pull, to make sure later
> + * skb_gro_header() and skb_gro_network_header() calls no longer use frag0.
> + */
> +static inline void skb_gro_frag0_invalidate(struct sk_buff *skb)
> +{
> + NAPI_GRO_CB(skb)->frag0_len = 0;
> +}
> +
> static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen,
> unsigned int offset)
> {
> + skb_gro_frag0_invalidate(skb);
> if (!pskb_may_pull(skb, hlen))
> return NULL;
[Severity: High]
Does clearing frag0_len here, while frag0 itself is left pointing at
the old location, break gro_pull_from_frag0() when the slow pull in
skb_gro_header_slow() fails?
Consider an skb that enters GRO with skb_headlen(skb) == 0. In that
case skb_gro_reset_offset() points frag0 at the start of frags[0],
which is packet offset 0.
Now add remote checksum offload nopartial: vxlan_gro_receive() or
vxlan_gpe_gro_receive() with VXLAN_F_REMCSUM_NOPARTIAL, or
gue_gro_receive() with FOU_F_REMCSUM_NOPARTIAL. There,
skb_gro_remcsum_process() records grc->offset and grc->delta through
the frag0 fast path. The inner eth_gro_receive() and
inet_gro_receive()/ipv6_gro_receive() handlers then advance
skb_gro_offset() through frag0 too, so skb_headlen() is still 0.
Suppose the next inner header does not fit in frag0_len, for instance
in tcp_gro_pull_header() or udp_gro_udphdr(). skb_gro_header_slow()
now sets frag0_len to 0 and calls pskb_may_pull(). On a truncated
packet where hlen > skb->len, this fails without pulling anything.
That leaves skb_headlen() at 0 and frag0_len at 0.
On the way out, skb_gro_flush_final_remcsum() calls
skb_gro_remcsum_cleanup(), which does:
ptr = skb_gro_header(skb, plen, grc->offset);
Before this patch that was served from frag0. Now skb_gro_may_pull()
fails, and pskb_may_pull(skb, plen) really copies plen bytes into the
linear area. Here plen = grc->offset + sizeof(u16), which is below
skb_gro_offset(skb) once the inner headers were pulled. frags[0] is
advanced by plen, but NAPI_GRO_CB(skb)->frag0 still points at packet
offset 0.
Since the skb is flushed, dev_gro_receive() ends up in
gro_try_pull_from_frag0(). That computes
grow = skb_gro_offset(skb) - skb_headlen(skb) > 0 and calls
gro_pull_from_frag0():
memcpy(skb_tail_pointer(skb), NAPI_GRO_CB(skb)->frag0, grow);
This copies packet bytes 0..grow to skb->data + plen, then advances
frags[0] by grow again. The skb handed up the stack as GRO_NORMAL
has its inner headers overwritten with outer header bytes, and the
real bytes at plen..skb_gro_offset() are lost. A remote sender can
trigger this with a short encapsulated packet.
gro_pull_from_frag0() assumes frag0 is the current start of frags[0],
which only holds while skb_headlen() is 0. Should it copy from
skb_frag_address(&pinfo->frags[0]) instead? Or should
skb_gro_remcsum_cleanup() and gro_try_pull_from_frag0() handle a
partially linearized skb in some other way?
[Severity: High]
This patch didn't introduce this, but since the failure path of
skb_gro_header_slow() is being changed here: what happens in
napi_gro_frags() when this pull fails for the Ethernet header?
In net/core/gro.c, napi_frags_skb() takes the slow path and returns
NULL when the pull fails:
net/core/gro.c:napi_frags_skb() {
...
if (unlikely(!skb_gro_may_pull(skb, hlen))) {
eth = skb_gro_header_slow(skb, hlen, 0);
if (unlikely(!eth)) {
net_warn_ratelimited("%s: dropping impossible skb from %s\n",
__func__, napi->dev->name);
napi_reuse_skb(napi, skb);
return NULL;
...
}
The caller doesn't check for NULL, though:
net/core/gro.c:napi_gro_frags() {
struct sk_buff *skb = napi_frags_skb(napi);
trace_napi_gro_frags_entry(skb);
ret = napi_frags_finish(napi, skb, dev_gro_receive(&napi->gro, skb));
...
}
dev_gro_receive() starts with skb_get_hash_raw(skb) and then reads
skb->protocol. Can this be a NULL pointer dereference in NAPI softirq
context? One way to reach it would be skb->len < ETH_HLEN, where
pskb_may_pull() fails with PKT_TOO_SMALL. Another would be
__pskb_pull_tail() returning NULL.
napi_gro_frags() used to have an "if (!skb) return GRO_DROP;" check.
Commit 1d11fa696733 ("net-gro: remove GRO_DROP") removed it on the
grounds that NULL could only come from a failed napi_get_frags()
allocation. That reasoning doesn't cover the header pull failure return
shown above.
The drivers checked so far (tun, r8152, e1000) all enforce a minimum
frame length before calling napi_gro_frags(). The other callers have
not been checked.
Should napi_gro_frags() check for a NULL skb again?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261030125955.3107383-1-edumazet%40kernel.org
Technical Details
Message-ID:
<179362441613.3131.6007536857643093308@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-354681-linux-kernel-netdev=dewy.ruReferences:
<20261030125955.3107383-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-354681-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 2/2] net: gro: invalidate frag0 after a pull Date: Mon, 02 Nov 2026 13:00:16 +0000 Organization: Usenet Network Message-ID: <179362441613.3131.6007536857643093308@kernel.org> References: <20261030125955.3107383-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="2930221"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ExNNIkcVQ+9wgCAyeQ7JHeuVCkU= sha256:P5zBB/OWg4WmQtNK9keJ3n3BA1TYkqXxTruH1Bg0SXA= sha1:Ajt9rLoR1BAcPXbH8y2/6KcqeLU= sha256:8lV5C3XDVZXLEdDUI0lWuCCn9a9fmwV0dS5dpK8O6vQ= 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 9E43011250D; Mon, 2 Nov 2026 16:22:57 +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 ICudlhxTiqEZ; Mon, 2 Nov 2026 16:22:54 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354681-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id A7D9E1124DC; Mon, 2 Nov 2026 16:22:45 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 8CDAB61991; Mon, 2 Nov 2026 13:00:19 +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=1793624418; b=GoF58yBmizYcpYeFxUPLUINEeMI4ugRX4DA+qwqghUNzbTXr4FT8eWrg6MhlgduF/vBq 7DZ8M05d5uAZ+CEus9u2edpDuNEO4U+D3eOKC2K8TCIBZp0ByPPhZFffY+nfFHPxUsC0t uWFITINwTW3Wasd0LUopvcFGO1S4ymj2sA0wZayjXLEeEwp9u+rOuR9dy1HWYQCIngWzv NcIR9puD+vVlIbreDwrFnsKEWhNvC2Co12hiFXjMT9YweVJM456IL76wiUQpBaLEAkUtm mh/wqlCL9M34+vOKAbGSeOyxkk+Z1tDKgqW1PnaQvhcwvKwe6wUaU/t8NwYykAh9PTw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793624418; 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=/P1RSqnLX+hUxtcb1KyjT/xNFMizKENJrUqr+CPPikU=; b=m8zFZ2WSnLXH5EyUEPYJWh6OApMkZIqiOv6AELIoY5Ckz7Tyk+Bs8o9WTye+l64JxYaP TVFvBBhLiiY64TE9N6ydv6HBdxtFU+fhR0EfqYzaJEfs4z2FWmUvSxUJE4v8FdBVu5278 ORepkDlLgEyJDDr6m5Y2nmO+B7XLYLRwvSozP3Xr4C+siAseu4Y7vX+8Sn9/pOdPyb7hN 9BKmzz/yFyHvekuQ2B0gUBXaurkB1pv5KkYNq/o+7jndC1ndtaIe9LY5ECUFPOPE04vLu jw4PAQu2riV1Kx0Z/7cXaWcMS4egh3m+OQszparKnwv9G2ZUTUk31hrjI4KW98X5Y4A== 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=RJX67fXI; 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 9A210606A33B; Mon, 2 Nov 2026 13:00:18 +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=RJX67fXI 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=1793624417; b=rmWbqifm6PanpDOvT3oBcujBCJ4K4nKns0jih8vGGmQ4oS+jMRtgFq6oEp7z796Qrt9u 0waumu6R0QdIM+j/V47Rz08tLAueFAb/7wwEWnmMBDUxfZ8e0cVGRXk5GBzwdxubcwyaV A0uQ2K7quq9Vxs2mO/k4GiFE8Degyh3CpxCoP8odYxuLu6VVLziPH3U0R5Z40N2pBtF4R eG2+ilTEFY4w/ceMWGH0Zi2avP21ikgkn3jDelmpXjDxc0SV7+07qOSx0QP4Ek6A40tov 99Orb2KuWCO2zqg5iSaTo1Dgm6BTx6JVOB6fOpa1QHN7XB+JSOpuAb19ryxwkT5UAMA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793624417; 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=/P1RSqnLX+hUxtcb1KyjT/xNFMizKENJrUqr+CPPikU=; b=KDrLQGPUJQc3H0ULx9rn+1YOYhLqR1cK+WcJGBQLuc7DChyQnn4gkqY9h/Wg6Y6HJSJi yElOGVhtcPoX7EmUMzF5xuplet5K9Q51Mi/2ienEr93trV8AZ/ZoXoCbhLIcVFXIYPaiw LwH4HOY3kUOubQR+iYrwTpkIZ4ktJaniZguQG82V6UWpWM+O5i5x53pkogLUt9dDrwxNb K4/F4PiDt0NSHd+9WJ0seuzQZAzFgMoNyiJCbWBnNSH0JdvKxilOk1X8yOXNgQ6PTtgwN fwftW8tIQL/wtGjDhOuVLKhw4W1jRTdtKeJY7I2jEWJEvLllmLY1scai1/+wDlScKZw== 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=RJX67fXI; 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 76231606A32D; Mon, 2 Nov 2026 13:00:17 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 894901F00A17; Mon, 2 Nov 2026 13:00:16 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793624417; bh=/P1RSqnLX+hUxtcb1KyjT/xNFMizKENJrUqr+CPPikU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=RJX67fXID/owlK0qA56Fw0euUY9+k76bvhdibm2v9xu2szC2t/tCJUpA/7hHFqblP wf1fICMMIWDqVV2qHwdclcQ3QRWXqP6P70QNaHX4yZXQRONzNQt+WEU7ihyNms0JlQ 1gNIqUfdtBQMsmgv1Q/hRPTeDPxnwt6cCFTVC9Ar95iVZhvyeVwUyHElTbeHFVBygx yuhfMJy4Te8k3nHPS7vi991/BK5itdL4xlY6JRjo6oWBB+rkOekFCpk/plA0wM6k2P 1dxy7jhZYmIiDgKkA+vVBCU57wZ2YlE44Okd4aCh49anjghpbNNusDRj9cCfA6wwLQ tzJMbbUWzrKOw== 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 X-In-Reply-To: <20261030125955.3107383-3-edumazet@kernel.org> X-sashiko-severity: High 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