Article View: linux.kernel.netdev
Article #18830Re: [PATCH v2 net 4/4] net: enetc: let core segment GSO skb when headers exceed TSO_HEADER_SIZE
From: Eric Dumazet
Date: Thu, 19 Nov 2026 00:03
Date: Thu, 19 Nov 2026 00:03
133 lines
14770 bytes
14770 bytes
Le jeu. 19 nov. 2026 ร 00:51, Vladimir Oltean
<vladimir.oltean@nxp.com> a รฉcrit :
>
> Like many other drivers, the software TSO path (enetc_map_tx_tso_buffs())
> copies the L2+L3+L4 headers of the skb into a fixed-size TSO_HEADER_SIZE
> (256 byte) slot of the per-ring dma_alloc_coherent() header area,
> without checking that they fit.
>
> Sashiko casually points out during review of an unrelated patch:
> https://lore.kernel.org/netdev/179294166520.3134.18097439321876673016@kernel.org/
> that TSO_HEADER_SIZE does not constitute the maximum size that packet
> headers can have for GSO skbs, but rather, an essentially arbitrary
> number.
>
> An example where headers can exceed TSO_HEADER_SIZE is with an IPv6
> extension named Segment Routing Header, set through setsockopt(IPV6_RTHDR),
> with a type 4 routing header. With 11 or more segments, the headers of a
> TCP/IPv6 packet exceed 256 bytes:
>
> Ethernet 14
> IPv6 40
> SRH, 12 segments 8 + 12 * 16 = 200
> TCP (with timestamps) 32
> ---
> 286 (30 bytes too many)
>
> No privileges are required to request this socket option (but it will
> cause driver writes outside allocated memory). A reproducer sketch can
> be found at:
> https://gist.github.com/vladimiroltean/7cecf636b788b29f361a2fbdae646010
>
> Bizarrely, enetc is the only affected driver, because the core
> accidentally protects most other drivers against this bug in
> gso_features_check(). There, we have this logic that saves the day:
>
> /* NETIF_F_IPV6_CSUM does not support IPv6 extension headers,
> * so neither does TSO that depends on it.
> */
> if (features & NETIF_F_IPV6_CSUM &&
> skb_has_ipv6_extension_hdr(skb))
> features &= ~(NETIF_F_IPV6_CSUM | NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4);
>
> enetc is the outlier because it only advertises the more complete
> NETIF_F_HW_CSUM, so for it, this fixup does not clear the NETIF_F_TSO6
> and NETIF_F_GSO_UDP_L4 bits.
>
> [ astute reviewers may ask: what if we disable NETIF_F_IPV6_CSUM at
> runtime, via ethtool -k, so as to bypass this fixup, don't we make
> all drivers vulnerable?
> No, because netdev_fix_features() will trigger the code path which
> also prints "Dropping TSO6 features since no CSUM feature.\n".
> So TSO skbs will now be segmented in the stack. ]
>
> Surveying every driver that uses TSO_HEADER_SIZE:
>
> Driver | TSO6 | Checksum feature | Core guard fires? | Verdict
> ---------------|---------------------|-------------------|---------
> enetc | yes | NETIF_F_HW_CSUM | no | vulnerable
> bnxt | yes | NETIF_F_IPV6_CSUM | yes | safe
> nicvf | yes | NETIF_F_IPV6_CSUM | yes | safe
> otx2 | yes | NETIF_F_IPV6_CSUM | yes | safe
> fec | no | NETIF_F_IPV6_CSUM | n/a | safe
> mvneta | no | NETIF_F_IPV6_CSUM | n/a | safe
> mvpp2 | no | NETIF_F_IPV6_CSUM | n/a | safe
> mv643xx | no | NETIF_F_IP_CSUM | n/a | safe
> dpaa2 | no | NETIF_F_IPV6_CSUM | n/a | safe (*)
>
> (*) dpaa2 also uses a fixed-size kmalloc(TSO_HEADER_SIZE) per segment,
> so the identical overflow would apply if it ever gained NETIF_F_TSO6.
>
> The above survey is what influenced the decision to make a localized
> patch in enetc_features_check() rather than create a huge disturbance in
> the core, even though, IMO, TSO_HEADER_SIZE is a huge foot gun.
>
> Note that the LSO path (enetc_lso_map_hdr()) also copies the header into
> the tso_headers buffers for a reason I don't quite understand. However,
> I've excluded it from the discussion because when the GSO header size
> grows to weird sizes, it never gets anywhere near TSO_HEADER_SIZE before
> hardware stops being able to support this offload. There's an earlier
> limit at ENETC_TX_CSUM_MAX_L4_OFFSET at which it stops being able to
> perform HW TX checksumming (a dependency feature).
>
> Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> v1->v2:
> - drop word "super" from "GSO super-skb"
> - subtract VLAN_HLEN from maximum permissible GSO header size
> - stop blaming LSO
> ---
> drivers/net/ethernet/freescale/enetc/enetc.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 6cc519eea5bd..2bc65cf6f508 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1138,7 +1138,19 @@ netdev_features_t enetc_features_check(struct sk_buff *skb,
> return features;
> }
>
> - if (!skb_is_gso(skb) || enetc_skb_uses_lso(priv, skb))
> + if (!skb_is_gso(skb))
> + return features;
> +
> + /* In case NETIF_F_HW_VLAN_CTAG_TX is disabled, validate_xmit_vlan()
> + * has not yet run and a VLAN may still be in the hwaccel area, so we
> + * need to be one step ahead
> + */
> + if (enetc_lso_get_hdr_len(skb) > TSO_HEADER_SIZE - VLAN_HLEN) {
> + features &= ~NETIF_F_GSO_MASK;
> + return features;
> + }
> +
> + if (enetc_skb_uses_lso(priv, skb))
> return features;
>
> if (enetc_tso_count_descs(skb) >= priv->tx_bd_count)
> --
> 2.53.0
I should probably rework my series :
https://lore.kernel.org/netdev/20260403043237.3909226-1-edumazet@google.com/
Technical Details
Message-ID:
<CAL4WiipQ_=cN2+F0wFiMy8Ji-d2tfd6ZuBo3HCYiTEQ6RxF29g@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366544-linux-kernel-netdev=dewy.ruReferences:
<20261118235055.1225115-1-vladimir.oltean@nxp.com> <20261118235055.1225115-5-vladimir.oltean@nxp.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366544-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v2 net 4/4] net: enetc: let core segment GSO skb when
headers exceed TSO_HEADER_SIZE
Date: Thu, 19 Nov 2026 01:03:16 +0100
Organization: Usenet Network
Message-ID: <CAL4WiipQ_=cN2+F0wFiMy8Ji-d2tfd6ZuBo3HCYiTEQ6RxF29g@mail.gmail.com>
References: <20261118235055.1225115-1-vladimir.oltean@nxp.com> <20261118235055.1225115-5-vladimir.oltean@nxp.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="2735194"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:s4Qb27gE1qSM7plyI31L8WC1d4E= sha256:AvOchy0MkhTEvwpcMq8EdoJerfCoHTHITt+8Bf89Mqs=
sha1:fO+k/aRH2d3av3H96UXMwgMrhWE= sha256:rW7TddKM+cuW5sDTrKqs3fTcrZBtyfrT0GxDFOh80u4=
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 C1F3A115435; Thu, 19 Nov 2026 03:03: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 1qWw3w7XN-G9;
Thu, 19 Nov 2026 03:03:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-366544-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 B7EA811542F; Thu, 19 Nov 2026 03:03:44 +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 09B781C291E; Thu, 19 Nov 2026 00:03:33 +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=1795046610;
b=Xqh7pLfS2RwvCjQ5nktCiCq9/+8G++MR0JZiivl1D3kl3tkhzWrU2abiUKp2SKYcQPP5
gBhFrAEHS8sx5H54OGB3j/XUEX8/Eq4AnDFOLRwBelr4C4Kzs+DsnYlPLFfJpmIAvxEMq
q4dlQDObcto+heOCxqUTa34e4GVqXCH9wlezEKvBeGBbZoyS1N6vqt1RvOIlLKsxhd2QS
VHjckdCLqEmkKKoG4laHk2ZfX5eq6B5RimQI3NX1KJs3P8NVNBKjfrVPZ6VPgdzTZq42A
A96jF7H0/WPGQKD+JOu/s5fF8uhqfnVAnsxfiq/O6VdMNOQVdgtfwidCY9Cq7BFVgSw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795046610;
h=X-Original-To:Received:Received:DKIM-Signature:Received:
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=wyfuj7NvvZbRNd5oi8oKRypq3whiMRjk+iKeQTsU3ew=;
b=hMhXRh7jVNKr3EA8PoX/uYKw5/RTcLAdA0uKxYSo1LDEifBMn4h2qYRyckkk6LTfuq/6
ieV0M6pzKeEMMA1hmtAVApZ8BgnYy8u2U1w5VJPRFjLzJ92u7ELqRdZpFGVXNcPntclgg
IbcCqlEjo5k2tUryaebvY18qs84jrWtn8Rd/owYe90wqyYpVi2D3teb1urNBN9mD3FQk0
yroXNFz4uy6dSTlFEnbUTsxrnQWzc391Fd50qhJMK8iiap3O/V4GmpHMqUKL77g92dVZQ
iOunH/T8sAfQ3MWGiM35+saxU1idY9XDzWTtqqmmlb4VCOjwnoumbj92sFaXyuVhV2w==
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="gJb/T9DJ";
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 1D84360A260B;
Thu, 19 Nov 2026 00:03:30 +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=gJb/T9DJ
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=1795046609;
b=oGRsctJfqom0OMeWIflthO2KpdKmxXLUzllmJd5bP7aF+49alO+0SylfUxpSGdCY++z7
j3knlBXbJDH7/kbwMWcb/IelrpfnUa0tYnUck/jXIVzDSAgaUis0yoyOroVi/Fnhlu/TP
meDUJMND5Tbc+wT8uhwNdR2Jry6ptXDAsW7UgyuMakU9lQGle/3mrGblUlzm080cpgMOo
AViy43wnzO5qQNEGS3DxK8q5OQ0DrcQncVSesYcqDQQwGmfU1WBnYn+CsWvMhKVnpeXdn
WoqXiqBFeM9QJzGEPIQuD7IU2uBl43Vvrg4Wg/dFsV7G9Tyvjd1j6NISA9U/9jHKmgw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795046609;
h=Received:DKIM-Signature:Received: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=wyfuj7NvvZbRNd5oi8oKRypq3whiMRjk+iKeQTsU3ew=;
b=FyqUIVi/s0VzcWxb6gTgChexRJC63rpd9Cu8OYaOK4rV1Mq/ztZj3bTxfz1xrWOUyoSW
338nDkI2SJyIyPCfu/QaW8T2Lz9Hz1dqm2+dS8fOsTAWx3poCjNxn58Sq18AXyYhvN5IU
W7AnG6FXr/OGxuxRdKw2pmImCW/c984lxMr1Sx9ZsID9G7OrWWWT/hsin2l590FMM9U4G
LT5k///ydlfZuOxSRT0RODK+B93zaxEEPWWdzEhW1+KPlFWSQ16HK1z7qI4TdQrjKbWKx
tCFxlbmKojGOU/RT0fX4vhkIceF6pSEgbYrY+pNnHiAm/us7BW5Nq5sRNOMangSELUA==
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="gJb/T9DJ";
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 3E655606A336
for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 00:03:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D04B31F000CD
for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 00:03:28 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1795046608;
bh=wyfuj7NvvZbRNd5oi8oKRypq3whiMRjk+iKeQTsU3ew=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=gJb/T9DJyAdLfSZdoqK6HPP1JWwTP7vlA4Yf/LleMFzTNRdrwX8NfOa6NHEJ9kGCD
E0jSXp1+ttsn9Q7HPZjX+L7FulXlDdEzB7Zt9lWjbBX3LFoCsHWjCdoTQ433vYmCe5
MsVfHrxNim6YFlGDPOwxPMVRbAoUF+/2qHKDWwUyEchRZ3ljZKuVHK1aErWp/ZIf1k
3xdyKdzOZNDNZzWmrhoocb/OKukFqa1LlGW/AF+y5nXPYI5xhZ3wul2f7uSCuFccxV
e+tSvlX+yJ1xjhQCWv7By8IwnypIH7u/5zu4AuRVUOwf7qweK3RsYI6OKjtB03quhS
BKHYEy1z6qN9A==
X-Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-70bf1671c21so1054980eaf.1
for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 16:03:28 -0800 (PST)
X-Gm-Message-State: APuU4Z9UcW61s5hVfvk3erzSj4Im83lenldjPjxr03PTwerVEVSan0FE
DsssIMI/c3fG65W6tJB2/dV9qdsbCAu/Llng+19aWSkr9k+rbJyvbz+enqbtsDahzG+WFRENk4M
oieXByRMV3OdaBqSrvvHU9CMfQ8AoLA8=
X-Received: by 2002:a05:6820:1517:b0:716:d3ac:6950 with SMTP id
006d021491bc7-71b18297a2emr3293454eaf.7.1795046608044; Wed, 18 Nov 2026
16:03:28 -0800 (PST)
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: <20261118235055.1225115-5-vladimir.oltean@nxp.com>
X-Gmail-Original-Message-ID: <CAL4WiipQ_=cN2+F0wFiMy8Ji-d2tfd6ZuBo3HCYiTEQ6RxF29g@mail.gmail.com>
X-Gm-Features: Aa3M54opHWuR9SlJEPohXbxMUMlaFEN9TxFaq4PW8CJ455fM-o3BKFzXrSMiZDQ
X-Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>, Wei Fang <wei.fang@nxp.com>,
Clark Wang <xiaoning.wang@nxp.com>, Ioana Ciornei <ioana.ciornei@nxp.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>, imx@lists.linux.dev,
linux-kernel@vger.kernel.org