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>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Shmulik Ladkani <shmulik.ladkani@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH net v3 3/6] net/sched: act_mirred: ensure a pullable link-layer header before redirect
Date: Sat, 24 Oct 2026 10:28:38 -0400 [thread overview]
Message-ID: <ACT-N6N4.v3.r0.20261023200137-3@mojatatu.com> (raw)
In-Reply-To: <ACT-N6N4.v3.r0.20261023200137-2@mojatatu.com>
The issue:
tcf_mirred_to_dev() may redirect a packet that has no link-layer header to
a device that expects one. TUN builds a valid L3 skb with mac_len == 0;
mirred then pushes zero bytes and the IP header is parsed as Ethernet by
eth_type_trans(). The same happens after a VLAN POP_ETH or MPLS POP chain
whose producer did not leave a full inner Ethernet header.
The Fix:
After the existing push/pull adjustment, when the target expects data at
the MAC header, pull dev->min_header_len bytes into the linear area and
drop the packet only when that pull fails. This ensures that a consumer
such as eth_type_trans() can pull the target device's minimum link-layer
header from the linear area. Do not gate the check on skb_network_offset():
tc_mpls_l2vpn.sh legitimately redirects a decapsulated packet whose MAC
header is not at the recorded network offset.
Conditions to recreate the bug:
- create a TUN device with IFF_TUN | IFF_VNET_HDR | IFF_NO_PI;
- attach a filter to the TUN device's ingress hook, with a mirred egress
redirect action targeting an Ethernet device such as lo;
- write a virtio_net_hdr with hdr_len=1 and an 8192-byte payload.
The unfixed kernel parses the IP header as Ethernet and can BUG in
eth_type_trans() via loopback_xmit.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Link: https://lore.kernel.org/netdev/CAL4Wiiq3h_OoVo9BpBy0pqFe=AeyN25QxsU86h63qEf05uCJRA@mail.gmail.com/
Cc: stable@vger.kernel.org
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
v2 -> v3:
- drop the skb_network_offset() condition; keep only
pskb_may_pull(dev->min_header_len). The offset check rejected valid
MPLS L2VPN redirects (Eric Dumazet; tc_mpls_l2vpn.sh).
---
net/sched/act_mirred.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 553342c55cf7..85163c46d652 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -316,6 +316,10 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m,
}
}
+ if (!expects_nh &&
+ !pskb_may_pull(skb_to_send, dev->min_header_len))
+ goto err_cant_do;
+
skb_to_send->skb_iif = skb->dev->ifindex;
skb_to_send->dev = dev;
@@ -335,6 +339,8 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m,
return retval;
err_cant_do:
+ if (skb_to_send != skb)
+ kfree_skb(skb_to_send);
if (is_redirect)
retval = TC_ACT_SHOT;
tcf_action_inc_overlimit_qstats(&m->common);
--
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 ` [PATCH net v3 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP Jamal Hadi Salim
2026-10-24 14:28 ` Jamal Hadi Salim [this message]
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-3@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=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shmulik.ladkani@gmail.com \
--cc=stable@vger.kernel.org \
--cc=victor@mojatatu.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