๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8470

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

#8470
From: Eric Dumazet
Date: Thu, 29 Oct 2026 06:08
79 lines
12364 bytes
Le jeu. 29 oct. 2026 ร  00:33, Willem de Bruijn
<willemdebruijn.kernel@gmail.com> a รฉcrit :
>
> Eric Dumazet wrote:
> > 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)
>
> Or make tc_pedit set SKB_GSO_DODGY? BPF already does.
>
> In pedit_l4_skb_offset and pedit_l4_skb_offset.

Good idea, this would also make sure gso_segs is recomputed if
such packets are later segmented.

I would still keep the !count check: ixgbe and libwx RSC packets reach
GRO with gso_segs == 0, and the payload check in tcp_gro_receive()
relies on count being non zero.

pedit is also not the only way to change the TCP header of a GSO
packet (nft payload on older kernels, NFQUEUE with
NFQA_CFG_F_GSO, bpf_skb_store_bytes()), so I prefer GRO to stay
robust anyway.

pedit can be changed later in net-next to set SKB_GSO_DODGY on
GSO packets it modifies. Note this needs skb_unclone(), which can
fail. pedit does not drop packets on allocation errors today, so
it would probably leave the packet unmarked, another reason for
GRO to not trust these packets.

Thanks.
Technical Details
Message-ID: <CAL4WiiqgTTAD_j_Djkec1RJj_wT4bE2V2=Wrk+a=FJ34cyA0vQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353174-linux-kernel-netdev=dewy.ru
References: <20261028171350.2205175-1-edumazet@kernel.org> <willemdebruijn.kernel.207a67bdeedc5@gmail.com>

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-353174-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] gro: do not GRO GSO packets with inconsistent payload
Date: Thu, 29 Oct 2026 07:08:34 +0100
Organization: Usenet Network
Message-ID: <CAL4WiiqgTTAD_j_Djkec1RJj_wT4bE2V2=Wrk+a=FJ34cyA0vQ@mail.gmail.com>
References: <20261028171350.2205175-1-edumazet@kernel.org> <willemdebruijn.kernel.207a67bdeedc5@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1946971"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Yp7qvI6Fdr1cyi7NaGrdqZZlANE= sha256:m+T1TffS9SwcYgqoKuHV8eSmhq2gciLrFgERkxWSiaw=
	sha1:947ahhhDCaxVCDblsyz9uXeDkuA= sha256:TfoJXnYMl7g6DzyFLR3bE/rt9a86BF89/Cn+kJqACtw=
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 D4AE3125C58; Thu, 29 Oct 2026 09:10:27 +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 3r3_ov08A8s1;
	Thu, 29 Oct 2026 09:10:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353174-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 8BA58125C44; Thu, 29 Oct 2026 09:10:15 +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 146AD280B3; Thu, 29 Oct 2026 06:08:48 +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=1793254128;
	b=Hx83DVFwOP702L5Fdwa22zbhOmnIbwNMS9FWCghDcHux++fO5rlyH9G2lqJ+FpwAExyg
	 ADawefUBuUrYk9C3hLe1pSdAp9oniU2Tk5oW/u/CYlAP1H+gIVeaRMfu/7izYydbHxFNC
	 Z692t0aismn709CNi6K7XrXz1uos0KCeQR7SKNtZvDv5XBOV9upxeEltowxAswew651l6
	 LyGURY88gxnaqyILiBUSO/KC027/ED2UL7fzH2onXAK5ds3OBgJBKZUXtyYJQWsb9vdOv
	 tgCqk/iUVWkwHiPWmaqaydkUaHZ2U5dfWpyxL0TQAeux0+D9bGD30tKvr18o9/ed6HA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793254128;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=y2XNmKanTGTkW27e2r5d5GXVy0nZhgqPRVdw1F7k67A=;
	b=o3vT4ZhhD2v1ocuwnYgMb2OusOLD659bTw4MqVlLOGb0Hq8Sn65k2htgrkkjnxzz5lgn
	 RUW4NJY+DFsfQXPicrhOsIBq57hhmuDaoW0I5KpVsfBp0OVI74VaMed8LEUYJs1kqLgt3
	 nXyJKWFJEj8r6TxQk6O35e+rDo6b79S772NDY4ztnRSyvaKmgPCV9kad41yJx19AmpA4u
	 W7DihJDaqgQlzJOdKyFMYmnki9+Tcw6JSunq+eKrPR7kYS3CwB+CFH/Y0yUBc4DeRB/Po
	 JITgZHjV1YiTbsvhJ0RmWNx2/F+hwfnEVEF9xvLKDlzQWdU/o9IsQRCKym8Ukc8G3CQ==
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=nmSyFLWH;
	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 DEBCB606A322;
	Thu, 29 Oct 2026 06:08:47 +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=nmSyFLWH
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=1793254127;
	b=bFLJaTgNV5N25cSVfBbwwjzoI3IDcsAmbOTyo953TWCfPghAe1emBayBgHUJuUE+PNfQ
	 M3MFVqxyWrbGun1nuxkZfcFQ8VgsCy0mtnZqBumz/kEF0pATycrXKmrBKoe7rNEk+ZYpi
	 D8KitKqrMALNZf0DB+ow8ADqpAaKuaJFYYGOdW9EEd3tNFUauhrdpfW6fiWa5fBypVqG1
	 k9BygrdLn9PHRr4fGDuvXTG7GBrSb3SLeo8NpX4YzRFmMmZcr7KtyKrfk/0YtvPA8wxJ9
	 zwBdG6qOAfmo0Z8ACcPoObW1ALyQPe5ar/Ng+g5ayV+FzEGfHrUQnh8BrLZZTLrA6hg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793254127;
	h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
	 X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To:
	 From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:
	 Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
	bh=y2XNmKanTGTkW27e2r5d5GXVy0nZhgqPRVdw1F7k67A=;
	b=qH4pWNTMvN0PBVE70E8zUxBagccWRs6LZF07Up0S8EIFquFzQiQN0L8CNvC4FGjkbdH9
	 Fm4NJTXGuNDcXoOEdZp1LKn7+Og9osvByuXgI2cHAPP6b1RI1jQuR/qo38K88Crb/ilyV
	 XHjohzlYyqqVsLmO/usfpnOJKc6wqMwnXJaL7w3hNc1Oex7mWUTIcKsiYxzVp5ZBwr0oQ
	 CYbMiJW/Pzq2xMnvD341AGGLimsoLTZJw7tEQKxEjUhwH+RecpNr+pMEfpmyKT1DQ0T5Z
	 wPYCws2OwYPVN57GLKiziib1UqS3GiCAPHsD8zJjmmePcLUuet7Jrk9k/VmREzsPY8Q==
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=nmSyFLWH;
	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 BF64E606A31A
	for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 06:08:46 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 511001F01825
	for <netdev@vger.kernel.org>; Thu, 29 Oct 2026 06:08:46 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793254126;
	bh=y2XNmKanTGTkW27e2r5d5GXVy0nZhgqPRVdw1F7k67A=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=nmSyFLWHNTvjCZV8/Cpdmeua+RYItxgnSSkmZoE/zhLIFt0AEBQGZXcaCYoRiideG
	 2T4z6dyctpmnqYLTB9SDvNG8cPFpGfBMLM8p9EXceKXAlIi8LSmwNUu7/3xFq62y+7
	 hQL/xIfprQP5ybmQHK6kF6owOggOMto4w5laZiv61P1uhvksarCNtR1GYWQZBrgdhC
	 hFcrm+WeCNQEjZqJenxTVJZ/TvBbhWr1it9kJT8TiztuXdnYhL8q3SWycmVMFqXrkv
	 sgfPUjSfNqcNTzWuhdvAK+K0qHyPtRqQ/VqSb8WPEwi79elAz8TW+7LH2cY4HxuI+p
	 8kos4tEt8rZNA==
X-Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-4a6fb4040cfso596659fac.3
        for <netdev@vger.kernel.org>; Wed, 28 Oct 2026 23:08:46 -0700 (PDT)
X-Forwarded-Encrypted: i=1; AKwUvBztVrWU1pjkPBaTGunMk42fKpcsRptTxFU3N8700n0DuVeX4SDUPyuilfjK5eZZ601xpzPlLaA=@vger.kernel.org
X-Gm-Message-State: AFq9FYKYLRdRHWps5s9a9S9OaffyNeIbBvfoqjVpxW14kDgzQiKcIS9D
	fbtAUqpywbv2X48KII0CPkHSKHg31nnKvq5KRB/AUa7pug+KJ1yRlq7dOaQxIdyKCIdDDG5/wxY
	TnCWya730CS98YN4/WDtZ45RizOR3F1s=
X-Received: by 2002:a05:6870:1714:b0:494:9c66:77a0 with SMTP id
 586e51a60fabf-4a8bb48cd97mr3242621fac.34.1793254125006; Wed, 28 Oct 2026
 23:08:45 -0700 (PDT)
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
X-In-Reply-To: <willemdebruijn.kernel.207a67bdeedc5@gmail.com>
X-Gmail-Original-Message-ID: <CAL4WiiqgTTAD_j_Djkec1RJj_wT4bE2V2=Wrk+a=FJ34cyA0vQ@mail.gmail.com>
X-Gm-Features: AclHuK9NRTr0SjCkbISMZE8VhnOeq0ZwYH4TjrWlZCPMVu3Ithpp6wBLvVJSXJM
X-Cc: "David S . Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, 
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, 
	Willem de Bruijn <willemb@google.com>, netdev@vger.kernel.org, Kyle Zeng <kylebot@openai.com>