From: Jamal Hadi Salim <jhs@mojatatu.com>
To: netdev@vger.kernel.org
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Pirko <jiri@resnulli.us>,
Victor Nogueira <victor@mojatatu.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
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>,
Willem de Bruijn <willemb@google.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH net v3 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Date: Sat, 24 Oct 2026 10:28:37 -0400 [thread overview]
Message-ID: <ACT-N6N4.v3.r0.20261023200137-2@mojatatu.com> (raw)
In-Reply-To: <ACT-N6N4.v3.r0.20261023200137-1@mojatatu.com>
The issue:
When the configured inner protocol is ETH_P_TEB, act_mpls POP can leave
the inner Ethernet header in a page fragment after skb_mpls_pop(), either
on an L3 device (mac_len == 0) or chained after act_vlan POP_ETH. A
following eth_type_trans() can then BUG in __skb_pull().
The Fix:
After the pop, pull the inner Ethernet header into the linear area only
when p->tcfm_proto is ETH_P_TEB; drop the packet only when that pull
fails. Other inner protocols (IP, MPLS, ...) have no inner Ethernet
header and must not be required to carry one. The pull is a no-op when
the header is already linear.
Conditions to recreate the bug:
- egress tc filter on lo: action vlan pop_eth action mpls pop protocol teb
(chained), or on an L3 device where mac_len == 0.
- AF_PACKET SOCK_RAW with PACKET_VNET_HDR, hdr_len=28, and a non-linear
eth / mpls / inner-eth frame.
- The inner header is in page frags; a following eth_type_trans() can BUG
in __skb_pull().
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/
Link: https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/
Link: https://lore.kernel.org/netdev/willemdebruijn.kernel.26d1ddb3bd2ae@gmail.com/
Cc: stable@vger.kernel.org
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
v2 -> v3:
- drop the pre-pop mac_len gate. The pull is a no-op when the header
is already linear, so the gate only avoided a cheap call (Willem de
Bruijn).
- restrict the pull to ETH_P_TEB. act_mpls POP can target IP, MPLS,
etc.; those inner protocols have no Ethernet header and must not be
required to carry one (Willem de Bruijn).
---
net/sched/act_mpls.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c
index 4ea8b2e08c3a..35a6d27f76a4 100644
--- a/net/sched/act_mpls.c
+++ b/net/sched/act_mpls.c
@@ -79,6 +79,9 @@
if (skb_mpls_pop(skb, p->tcfm_proto, mac_len,
skb->dev && skb->dev->type == ARPHRD_ETHER))
goto drop;
+ if (p->tcfm_proto == htons(ETH_P_TEB) &&
+ !pskb_may_pull(skb, ETH_HLEN))
+ goto drop;
break;
case TCA_MPLS_ACT_PUSH:
new_lse = tcf_mpls_get_lse(NULL, p, !eth_p_mpls(skb_protocol(skb, true)));
--
2.43.0
next prev parent reply other threads:[~2026-10-24 14:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 14:28 [PATCH net v3 0/6] net: pull short linear Ethernet headers before eth_type_trans() Jamal Hadi Salim
2026-10-24 14:28 ` [PATCH net v3 1/6] net/sched: act_vlan: pull the inner Ethernet header after POP_ETH Jamal Hadi Salim
2026-10-24 14:28 ` Jamal Hadi Salim [this message]
2026-10-24 14:28 ` [PATCH net v3 3/6] net/sched: act_mirred: ensure a pullable link-layer header before redirect Jamal Hadi Salim
2026-10-24 14:28 ` [PATCH net v3 4/6] net/sched: act_ife: do not consume the inner header on egress Jamal Hadi Salim
2026-10-24 14:28 ` [PATCH net v3 5/6] net: openvswitch: ensure a linear inner Ethernet header on TEB pop Jamal Hadi Salim
2026-10-24 14:28 ` [PATCH net v3 6/6] net: openvswitch: ensure a linear inner Ethernet header on NSH pop Jamal Hadi Salim
2026-10-26 9:42 ` [PATCH net v3 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP Jamal Hadi Salim
2026-10-26 10:31 ` Jamal Hadi Salim
2026-10-26 13:10 ` Eric Dumazet
2026-10-26 13:51 ` Jamal Hadi Salim
2026-10-26 14:16 ` Eric Dumazet
2026-10-26 16:01 ` Jamal Hadi Salim
2026-10-26 17:34 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ACT-N6N4.v3.r0.20261023200137-2@mojatatu.com \
--to=jhs@mojatatu.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=martin.varghese@nokia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pshelar@ovn.org \
--cc=stable@vger.kernel.org \
--cc=vega@nebusec.ai \
--cc=victor@mojatatu.com \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox