Article View: linux.kernel.netdev
Article #6560Re: [PATCH net 2/5] net/sched: act_mpls: reject short linear Ethernet headers after pop
From: Eric Dumazet
Date: Thu, 22 Oct 2026 17:52
Date: Thu, 22 Oct 2026 17:52
103 lines
12682 bytes
12682 bytes
Le jeu. 22 oct. 2026 ร 11:22, Jamal Hadi Salim <jhs@mojatatu.com> a รฉcrit :
>
> The issue:
> act_mpls POP can leave fewer than ETH_HLEN linear bytes after
> skb_mpls_pop(), either standalone on an Ethernet device or chained after
> act_vlan POP_ETH. A subsequent eth_type_trans() can then BUG in
> __skb_pull().
>
> The Fix:
> After the pop, when the skb started as MPLS, drop it if the linear head
> is shorter than ETH_HLEN. Non-MPLS pops and pushes are unaffected.
>
> Conditions to recreate the bug:
> - egress tc filter on lo: action mpls pop (standalone), or
> action vlan pop_eth action mpls pop (chained).
> - AF_PACKET SOCK_RAW with PACKET_VNET_HDR, hdr_len=28, and a non-linear
> eth / mpls / inner-eth frame.
> - The pop leaves skb_headlen(skb) < ETH_HLEN; a following
> eth_type_trans() can BUG in __skb_pull().
skb_mpls_pop() calls skb_ensure_writable(skb, mac_len + MPLS_HLEN),
then memmove()s the mac header and pulls MPLS_HLEN.
So after the pop we still have at least mac_len bytes in the linear part.
If mac_len >= ETH_HLEN, the new check can never trigger.
It only matters when mac_len < ETH_HLEN, ie after POP_ETH
or on an L3 device.
Do you have a standalone repro? If yes, which path ends up with
mac_len < ETH_HLEN on an Ethernet device?
>
> Fixes: 040b5cfbcefa ("Fixed updating of ethertype in function skb_mpls_pop")
This commit only added the @ethernet parameter to fix the ethertype update.
The pop leaving a short linear part dates back to act_mpls introduction:
Fixes: 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")
> Reported-by: Vega <vega@nebusec.ai>
> Link: https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/
> Cc: stable@vger.kernel.org
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
> ---
> net/sched/act_mpls.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c
> index 4ea8b2e08c3a..4d375033400b 100644
> --- a/net/sched/act_mpls.c
> +++ b/net/sched/act_mpls.c
> @@ -57,6 +57,7 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,
> struct tcf_mpls *m = to_mpls(a);
> struct tcf_mpls_params *p;
> __be32 new_lse;
> + bool was_mpls;
> int mac_len;
>
> tcf_lastuse_update(&m->tcf_tm);
> @@ -76,9 +77,12 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,
>
> switch (p->tcfm_action) {
> case TCA_MPLS_ACT_POP:
> + was_mpls = eth_p_mpls(skb->protocol);
> if (skb_mpls_pop(skb, p->tcfm_proto, mac_len,
> skb->dev && skb->dev->type == ARPHRD_ETHER))
> goto drop;
> + if (was_mpls && unlikely(skb_headlen(skb) < ETH_HLEN))
> + goto drop;
Same remark as Willem's on patch 1: please pull instead of dropping.
skb_mpls_pop() only guarantees the popped label was in the linear part.
On an L3 device (mac_len == 0) with a label stack, the next label and
the following headers can legitimately sit in a frag.
These packets work today, and this patch would silently drop them.
Something like:
if (mac_len < ETH_HLEN && !pskb_may_pull(skb, ETH_HLEN))
goto drop;
This would also remove the need for @was_mpls: if the packet
was not MPLS, skb_mpls_pop() did not change anything, and pulling
only drops packets shorter than ETH_HLEN.
Thanks.
> break;
> case TCA_MPLS_ACT_PUSH:
> new_lse = tcf_mpls_get_lse(NULL, p, !eth_p_mpls(skb_protocol(skb, true)));
> --
> 2.43.0
>
Technical Details
Message-ID:
<CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@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-350737-linux-kernel-netdev=dewy.ruReferences:
<ACT-N6N4.v1.r0.20261022051412@mojatatu.com> <ACT-N6N4.v1.r0.20261022051412-1@mojatatu.com> <ACT-N6N4.v1.r0.20261022051412-2@mojatatu.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-350737-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/5] net/sched: act_mpls: reject short linear Ethernet
headers after pop
Date: Thu, 22 Oct 2026 19:52:16 +0200
Organization: Usenet Network
Message-ID: <CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com>
References: <ACT-N6N4.v1.r0.20261022051412@mojatatu.com> <ACT-N6N4.v1.r0.20261022051412-1@mojatatu.com>
<ACT-N6N4.v1.r0.20261022051412-2@mojatatu.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="284126"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:GMmzC822AiDk2EohDkoRDAvn+ZQ= sha256:Nck6ceMMtS3cDiNCV+dzFNCq9Z/i27HJdZWidnlN6i8=
sha1:24Ml+2d0ONKJeGHpnk9Tnhhq9+o= sha256:Tchc8RhvGKGeeXGnb7WRoj3e2F/Hl/6SNnXGP9LdNTo=
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 F28E9111329; Thu, 22 Oct 2026 20:58:19 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, 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 axH2ydz-2urP;
Thu, 22 Oct 2026 20:58:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350737-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 DE95A11128A; Thu, 22 Oct 2026 20:58:07 +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 E39F63FFAC; Thu, 22 Oct 2026 17:52: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=1792691553;
b=EQ9LnRH/+RwbVFsK1WkHr/hX/er9Cv6i/EOxj/inaspxKxbz9UGvXC/eEBH73AA2KRPy
b5VzOxtYgqP3EAJI0O3NGvRIl+XB7GRTnEjq4wHZCeEfagaYzOhuRs01zg1661BsZAc6V
QEsB5eH3ml9lIqOb/YPYQpaKqpdrg82yQ/wsqDY8WM6VOqn4P3bKdh5WG5nr7gaL7r9zN
qYCNDP2GFP+vaWtFMsWkiXSm9SN5eJbEvDxtOjlJW0DiwsW4/+zj6mkUiCLHA9rH8cela
5T+odXhwZ37+nkNTvXlK7sSwHtQFRinQpEB/7vGmcDarBwzusPkf8ulOaZOaauXxBkQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792691553;
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=sVf47aEsd+XkYlW1t6M73q5BRuGgvCqtUM6WXvYFTSA=;
b=32/1R4y/c6EOUdrfOb7/60pMWAvg8suSvmuXiDIS7v6607HpurVMlU8ozoCM3bXpvKTh
b9srKazEzgvucDLtGhquhFd25Rv5MZNckiiDwG7nbUs+o7C+8U4GUQg9Il5nEC7JXj5IV
bwqrMSODoaQw+QiZMwxT01+PhJJYhO1MNkI/xSwkjWrTQ4MisCoRImF6p4a4pk/yAN5zn
EylXSVhLvGOXoxxtVw/M6C5FsV9dtyvhm4GCr7oJUbJf1hZh8Wm+xAToI5ZAUZkkP/zLl
mGO8I0Ds2Qry4ba+EL6iwCVPcYctEYyT6qC6H75wTYSkMLapOmfY5ldyx+VB7RLz+dQ==
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=bT3YR+nh;
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 2BF2D606A323;
Thu, 22 Oct 2026 17:52:33 +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=bT3YR+nh
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=1792691552;
b=LqbpZEIQWf0gMbsi/yi3SPSd/ffAh6QvHAf6buYfRJF4FP6bKmr1fqHJ4SS0QlICEU5m
cLeHHE0suOsFxagydi81UEkH/+paM6KlB9eDtZulil3P/4Ql3twCHDvB/g/+aOrC1AX0f
Jy4uQbUVRHHQ5X1+SP+jb1FqzgbWqppKemRYKFpakTHxY/Fuydd1WxtEmPUW5dAPr6sCP
ZPqIzE+gEzXD8evdeoMtoH/04JmgMKy1vaP4eoXKmi05X06K07dZABkwNEwlU1vXw0QJm
HaPGKyJWtDPayWjpjankiTVDB5nfbHqpINCBcFZYhmkssFHS7Dg6eL4K2zcAMzWGXyQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792691552;
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=sVf47aEsd+XkYlW1t6M73q5BRuGgvCqtUM6WXvYFTSA=;
b=OqEKbtyAF9KT/nycY1b3xIcXgQJa+R2M/9xugN++WWQ740FmXq6LyPLUF00w3WXZ/gjg
toDB9nlVZgAWE2HeWDbDPfcEeyjNJL15aJLJVHNfRXldHtiYzZFzR41GifODneg1W0J3o
9Hm2mriNVeZYjxUtKw9qCXarT1SD2Ex9o32zeFBb3RwlvgZnKs2QF0H9gvXjr097cl8Ds
666wIlAVw9a4VOTZ5D8WQX+dwDpmzDN2eecvtv2ET8XlmO5Xs8onvtlmlDBDFH1Zx+s89
aZ0eBNKTQESxRSNJQuoZxSB1twQlEeR5DMmZdpOYiXSsIVRzaPrPFDTzANZipqFLhLg==
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=bT3YR+nh;
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 0845E606A31A
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 17:52:31 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C00B81F031E5
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 17:52:31 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1792691551;
bh=sVf47aEsd+XkYlW1t6M73q5BRuGgvCqtUM6WXvYFTSA=;
h=References:In-Reply-To:From:Date:Subject:To:Cc;
b=bT3YR+nh7EgwWufP7iOtZ7C2DcZbDKhWlSvAM253FgDLenF4BRs37VOu/Q6RDMs6t
eRIzO2IdzT8OwWzwbATCt0InnIyFhSfYOgcaUN0JExoYl7SBUHcynH56J4y8vmnIjf
JJMCWobry35HDzz15PjowDd0yGcbCFxeRMPPVrEdk/IsYfu4+L6oIWWsVKfxjbnIE1
75mx162WzUELP+eM2sT+YBDw0KlHFjx2uWsBYQ84JxRBhSacpJ1MeNnd+s8K0MoxnI
VGTb01BVde+lP3XZAitfl50/pxDWlHDCTVWoiTNfruuQDWMsAqfiAsiFcwgUWwcEbF
Z7bvDdHgkjLbw==
X-Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5be47aa555cso2387034e87.3
for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 10:52:31 -0700 (PDT)
X-Gm-Message-State: AFq9FYLmhxxJ1Yu6HDZWsLgUPP++9lPW/R/kmrQLtLMwA+fCM/tIlS+K
FR2IBq3SpfAOsCJMdmJB+F11NYCQxCmllsGV6TdFeYLJFaNNVGWB2nbMuxi9ly9IiOmDX6zia1e
ViT2fJ9A0emL7DgIrsXQgSlJk/q/xI5w=
X-Received: by 2002:a05:6512:2392:b0:5be:5184:8c23 with SMTP id
2adb3069b0e04-5bfa1c5b7bdmr2526996e87.3.1792691550457; Thu, 22 Oct 2026
10:52:30 -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: <ACT-N6N4.v1.r0.20261022051412-2@mojatatu.com>
X-Gmail-Original-Message-ID: <CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com>
X-Gm-Features: AclHuK-HAodO7ZT4F82zTy6LKJNz-xrSusqBzXNSUa99LviiCuG6cFZ6fapMU2M
X-Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>,
Victor Nogueira <victor@mojatatu.com>, "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Martin Varghese <martin.varghese@nokia.com>, Pravin B Shelar <pshelar@ovn.org>, Vega <vega@nebusec.ai>,
stable@vger.kernel.org