net: pull short linear Ethernet headers before eth_type_trans()
Subsystems (5)
Jamal Hadi Salim
maintainerv2 cover net: pull short linear Ethernet headers before eth_type_trans()
This series fixes a class of producer/consumer bugs in which an outer header is popped and the packet is then handed to a consumer with fewer than ETH_HLEN bytes in the linear area. eth_type_trans() pulls ETH_HLEN from that area and can BUG in __skb_pull() when the inner Ethernet header is not linear. The affected producers are act_vlan POP_ETH, act_mpls POP, act_ife egress decode, and the Open vSwitch MPLS/TEB and NSH pops. A consumer-side guard in act_mirred rejects redirecting a headerless packet to a device that expects a link-layer header.
Patch 1 makes act_vlan POP_ETH pull the inner Ethernet header after the pop and drop only when the packet is genuinely shorter than ETH_HLEN. Patch 2 does the same for act_mpls, gated on the pre-pop MAC length. Patch 3 adds the act_mirred guard at the redirect boundary. Patch 4 keeps act_ife egress decode from consuming the inner Ethernet header and restores the header metadata.
Patches 5 and 6 establish the same linear-header invariant for the OVS MPLS/TEB and NSH pops before restoring MAC_PROTO_ETHERNET.
Changes in v2:
- Pull the inner header with pskb_may_pull(skb, ETH_HLEN) and drop only on failure, instead of dropping on the post-pop skb_headlen() check which may drop frags (Eric/Willem).
- act_mpls: gate the pull on the pre-pop mac_len and remove the separate was_mpls state.
- Drop the v1 TUN patch; add the act_mirred consumer-side guard.
- Add the act_ife egress decode fix; decode is receive-side, and the egress path restores the frame for loopback-style transmit paths.
- Keep the OVS TEB and NSH patches unchanged and restore their v1 Reviewed-by trailers.
- Drop two bouncing Cc addresses.
Jamal Hadi Salim (6):
net/sched: act_vlan: pull the inner Ethernet header after POP_ETH net/sched: act_mpls: pull the inner Ethernet header after POP net/sched: act_mirred: reject redirects without a link-layer header net/sched: act_ife: do not consume the inner header on egress
net: openvswitch: ensure a linear inner Ethernet header on TEB pop
net: openvswitch: ensure a linear inner Ethernet header on NSH pop
net/openvswitch/actions.c | 12 +++++++++--- net/sched/act_ife.c | 4 ++++ net/sched/act_mirred.c | 7 +++++++ net/sched/act_mpls.c | 2 ++ net/sched/act_vlan.c | 2 ++ 5 files changed, 24 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 1/6 net/sched: act_vlan: pull the inner Ethernet header after POP_ETH
The issue:act_vlan POP_ETH removes the outer Ethernet header and leaves the inner Ethernet header at the head of the packet. A non-linear skb can have the inner header in a page fragment, so a following eth_type_trans() may find less than ETH_HLEN bytes in the linear area and BUG in __skb_pull().
The Fix:
Pull the inner Ethernet header into the linear area after skb_eth_pop():
drop the packet only when pskb_may_pull(skb, ETH_HLEN) fails. This keeps valid non-linear packets whose inner header sits in frags.
Conditions to recreate the bug:
- egress tc filter on lo: action vlan pop_eth.
- AF_PACKET SOCK_RAW with PACKET_VNET_HDR, hdr_len=28, and a non-linear eth / inner-eth frame.
- The inner header is in page frags; a following eth_type_trans() can BUG in __skb_pull().
---
v1 -> v2:
- pull the inner Ethernet header with pskb_may_pull() and drop only
when the packet is too short;
- keep the OVS TEB and NSH members and restore their Reviewed-by
trailers;
- replace the TUN patch with the act_mirred consumer guard and add
the act_ife egress fix.
---
net/sched/act_vlan.c | 2 ++
1 file changed, 2 insertions(+)net/sched/act_vlan.c +2 -0
@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_vlan_act(struct sk_buff *skb, err =skb_eth_pop (skb);if (err) goto drop; +if (!pskb_may_pull (skb,ETH_HLEN )) + goto drop;break ;case TCA_VLAN_ACT_PUSH_ETH : err =skb_eth_push (skb, p->tcfv_push_dst, p->tcfv_push_src);
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 2/6 net/sched: act_mpls: pull the inner Ethernet header after POP
The issue: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, if the original MAC header is shorter than ETH_HLEN, pull the inner Ethernet header into the linear area and drop only when pskb_may_pull(skb, ETH_HLEN) fails. skb_mpls_pop() does nothing when the skb was not MPLS, so no separate state is needed.
Conditions to recreate the bug:
- egress tc filter on lo: action vlan pop_eth action mpls pop (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().
--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)
net/sched/act_mpls.c +2 -0
@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !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)));
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 3/6 net/sched: act_mirred: reject redirects without a link-layer header
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, require a link-layer header of at least dev->min_header_len bytes and pull it into the linear area. Drop the packet otherwise. This mirrors the check bpf_redirect() already performs and keeps the legitimate push_eth-then-mirred case working.
Conditions to recreate the bug:
- create a TUN device with IFF_TUN | IFF_VNET_HDR | IFF_NO_PI;
- attach egress mirred redirect to an Ethernet device (for example 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.
--- net/sched/act_mirred.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/sched/act_mirred.c +7 -0
@@ -316,6 +316,11 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, } } +if (!expects_nh && + (unlikely (skb_network_offset (skb_to_send) < dev->min_header_len) || + !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 +340,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);
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 4/6 net/sched: act_ife: do not consume the inner header on egress
The issue:tcf_ife_decode() unconditionally calls eth_type_trans(), which pulls ETH_HLEN. On egress this consumes the inner Ethernet header; a following eth_type_trans() from loopback_xmit() then parses L3 data as Ethernet and can BUG in __skb_pull() when the remaining linear area is short.
The Fix:
Parse the inner Ethernet header with eth_type_trans() in both directions, then restore the egress data position and MAC length. On ingress the existing behavior is unchanged. On egress, push the inner Ethernet header back after parsing so the xmit path sees the original frame and later actions see a consistent network header.
Decode is a receive-side operation; the egress branch keeps the frame intact for transmit paths such as loopback. tcf_ife_is_eth_skb() accepts Ethernet and loopback devices generally.
Conditions to recreate the bug:
- egress tc filter on lo: action ife decode pipe;
- AF_PACKET SOCK_RAW frame: outer Ethernet with ETH_P_IFE, IFE metadata, inner Ethernet and an 8192-byte payload;
- the egress pipe re-enters eth_type_trans() via loopback_xmit() after the action consumed the inner header.
--- net/sched/act_ife.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sched/act_ife.c +4 -0
@@ -769,6 +769,10 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, skb->protocol =eth_type_trans (skb, skb->dev);skb_reset_network_header (skb); +if (!skb_at_tc_ingress (skb)) { +skb_push (skb,ETH_HLEN ); +skb_reset_mac_len (skb); + }return action; }
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 5/6 net: openvswitch: ensure a linear inner Ethernet header on TEB pop
The issue:pop_mpls() restores MAC_PROTO_ETHERNET when the popped ethertype is ETH_P_TEB, but skb_mpls_pop() only guarantees that the MPLS shim is in the linear area. When the inner Ethernet header sits in a page fragment, the datapath now claims an Ethernet header it cannot access linearly.
Output to an OVS internal vport then calls eth_type_trans(), which pulls ETH_HLEN from an empty linear area and triggers the BUG in __skb_pull():
kernel BUG at ./include/linux/skbuff.h:2830!
RIP: 0010:eth_type_trans+0x335/0x500 internal_dev_recv ovs_vport_send do_output do_execute_actions ovs_execute_actions ovs_dp_process_packet ovs_vport_receive internal_dev_xmit
Conditions to recreate the bug:
On a system with 4 KiB pages and CONFIG_OPENVSWITCH and CONFIG_PACKET enabled, use CAP_NET_ADMIN to create an OVS datapath and bring its local internal port up with MTU 9000. Install a flow matching an Ethernet/MPLS packet with one bottom-of-stack label and actions pop_eth, pop_mpls(0x6558), output to the local port. With CAP_NET_RAW, send a 4128-byte AF_PACKET/SOCK_RAW frame containing outer Ethernet, the MPLS label, inner Ethernet and 4096 payload bytes. The two pops consume the linear headers and expose the inner Ethernet header in page fragments.
The Fix:
Pull the inner Ethernet header into the linear area before restoring MAC_PROTO_ETHERNET.
--- net/openvswitch/actions.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/openvswitch/actions.c +4 -1
@@ -153,8 +153,11 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,if (err)return err; -if (ethertype ==htons (ETH_P_TEB )) +if (ethertype ==htons (ETH_P_TEB )) { +if (!pskb_may_pull (skb,ETH_HLEN )) +return -ENOMEM ; key->mac_proto =MAC_PROTO_ETHERNET ; + }invalidate_flow_key (key);return 0 ;
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 6/6 net: openvswitch: ensure a linear inner Ethernet header on NSH pop
The issue:pop_nsh() restores MAC_PROTO_ETHERNET when the popped NSH next-protocol is TUN_P_ETHERNET, but nsh_pop() only guarantees that the NSH header is in the linear area. When the inner Ethernet header sits in a page fragment, the datapath then claims an Ethernet header it cannot access linearly.
Output to an OVS internal vport then calls eth_type_trans(), which pulls ETH_HLEN from an empty linear area and triggers the BUG in __skb_pull():
kernel BUG at ./include/linux/skbuff.h:2830!
RIP: 0010:eth_type_trans+0x335/0x500 internal_dev_recv ovs_vport_send do_output do_execute_actions ovs_execute_actions ovs_dp_process_packet ovs_vport_receive internal_dev_xmit
Conditions to recreate the bug:
On a system with 4 KiB pages and CONFIG_OPENVSWITCH and CONFIG_PACKET enabled, use CAP_NET_ADMIN to create an OVS datapath and bring its local internal port up with MTU 9000. Install a flow matching an Ethernet/NSH packet with a 24-byte MD1 header whose next-protocol is TUN_P_ETHERNET, and actions pop_eth, pop_nsh, output to the local port. With CAP_NET_RAW, send a 4148-byte AF_PACKET/SOCK_RAW frame containing outer Ethernet, the NSH header, inner Ethernet and 4096 payload bytes. The two pops consume the linear headers and expose the inner Ethernet header in page fragments.
The fix:
Pull the inner Ethernet header into the linear area before restoring MAC_PROTO_ETHERNET. This is the NSH counterpart of the MPLS/TEB producer fix in the previous patch.
--- net/openvswitch/actions.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/openvswitch/actions.c +5 -2
@@ -314,10 +314,13 @@ static int pop_nsh(struct sk_buff *skb, struct sw_flow_key *key)return err;/* safe right before invalidate_flow_key */ -if (skb->protocol ==htons (ETH_P_TEB )) +if (skb->protocol ==htons (ETH_P_TEB )) { +if (!pskb_may_pull (skb,ETH_HLEN )) +return -ENOMEM ; key->mac_proto =MAC_PROTO_ETHERNET ; -else + }else { key->mac_proto =MAC_PROTO_NONE ; + }invalidate_flow_key (key);return 0 ; }
Signature · 1 line
2.43.0
Aaron Conole
maintainerRe: [PATCH net v2 6/6] net: openvswitch: ensure a linear inner Ethernet header on NSH pop
Quoted 38 lines · Jamal Hadi Salim
The issue:
pop_nsh()restoresMAC_PROTO_ETHERNETwhen the popped NSH next-protocol isTUN_P_ETHERNET, butnsh_pop()only guarantees that the NSH header is in the linear area. When the inner Ethernet header sits in a page fragment, the datapath then claims an Ethernet header it cannot access linearly.Output to an OVS internal vport then calls
eth_type_trans(), which pullsETH_HLENfrom an empty linear area and triggers the BUG in__skb_pull():kernel BUG at
./include/linux/skbuff.h:2830!RIP: 0010:eth_type_trans+0x335/0x500 internal_dev_recv ovs_vport_send do_output do_execute_actions ovs_execute_actions ovs_dp_process_packet ovs_vport_receive internal_dev_xmitConditions to recreate the bug:
On a system with 4 KiB pages andCONFIG_OPENVSWITCHandCONFIG_PACKETenabled, useCAP_NET_ADMINto create an OVS datapath and bring its local internal port up with MTU 9000. Install a flow matching an Ethernet/NSH packet with a 24-byte MD1 header whose next-protocol isTUN_P_ETHERNET, and actionspop_eth,pop_nsh, output to the local port. WithCAP_NET_RAW, send a 4148-byte AF_PACKET/SOCK_RAW frame containing outer Ethernet, the NSH header, inner Ethernet and 4096 payload bytes. The two pops consume the linear headers and expose the inner Ethernet header in page fragments.The fix:
Pull the inner Ethernet header into the linear area before restoringMAC_PROTO_ETHERNET. This is the NSH counterpart of the MPLS/TEB producer fix in the previous patch.
Quoted 8 lines
Fixes b2d0f5d5dc53 ("openvswitch: enable NSH support")Reviewed-by Jiri Benc <[email protected]>Reviewed-by Ilya Maximets <[email protected]>Reviewed-by Eric Dumazet <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>---
Re: [PATCH net v2 5/6] net: openvswitch: ensure a linear inner Ethernet header on TEB pop
In reply to Jamal Hadi SalimQuoted 36 lines · Jamal Hadi Salim
The issue:
pop_mpls()restoresMAC_PROTO_ETHERNETwhen the popped ethertype isETH_P_TEB, butskb_mpls_pop()only guarantees that the MPLS shim is in the linear area. When the inner Ethernet header sits in a page fragment, the datapath now claims an Ethernet header it cannot access linearly.Output to an OVS internal vport then calls
eth_type_trans(), which pullsETH_HLENfrom an empty linear area and triggers the BUG in__skb_pull():kernel BUG at
./include/linux/skbuff.h:2830!RIP: 0010:eth_type_trans+0x335/0x500 internal_dev_recv ovs_vport_send do_output do_execute_actions ovs_execute_actions ovs_dp_process_packet ovs_vport_receive internal_dev_xmitConditions to recreate the bug:
On a system with 4 KiB pages andCONFIG_OPENVSWITCHandCONFIG_PACKETenabled, useCAP_NET_ADMINto create an OVS datapath and bring its local internal port up with MTU 9000. Install a flow matching an Ethernet/MPLS packet with one bottom-of-stack label and actionspop_eth,pop_mpls(0x6558), output to the local port. WithCAP_NET_RAW, send a 4128-byte AF_PACKET/SOCK_RAW frame containing outer Ethernet, the MPLS label, inner Ethernet and 4096 payload bytes. The two pops consume the linear headers and expose the inner Ethernet header in page fragments.The Fix:
Pull the inner Ethernet header into the linear area before restoringMAC_PROTO_ETHERNET.
Quoted 7 lines
Fixes f66b53fdbb22 ("openvswitch: New MPLS actions for layer 2 tunnelling")Reviewed-by Ilya Maximets <[email protected]>Reviewed-by Eric Dumazet <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>---
Re: [PATCH net v2 4/6] net/sched: act_ife: do not consume the inner header on egress
In reply to Jamal Hadi SalimQuoted 25 lines · Jamal Hadi Salim
The issue:
tcf_ife_decode()unconditionally callseth_type_trans(), which pullsETH_HLEN. On egress this consumes the inner Ethernet header; a followingeth_type_trans()fromloopback_xmit()then parses L3 data as Ethernet and can BUG in__skb_pull()when the remaining linear area is short.The Fix:
Parse the inner Ethernet header witheth_type_trans()in both directions, then restore the egress data position and MAC length. On ingress the existing behavior is unchanged. On egress, push the inner Ethernet header back after parsing so the xmit path sees the original frame and later actions see a consistent network header.Decode is a receive-side operation; the egress branch keeps the frame intact for transmit paths such as loopback.
tcf_ife_is_eth_skb()accepts Ethernet and loopback devices generally.Conditions to recreate the bug:
- egress tc filter on lo: action ife decode pipe;
-AF_PACKETSOCK_RAWframe: outer Ethernet withETH_P_IFE, IFE metadata, inner Ethernet and an 8192-byte payload;
- the egress pipe re-enterseth_type_trans()vialoopback_xmit()after the action consumed the inner header.
Quoted 4 lines
Fixes ef6980b6becb ("introduce IFE action")Signed-off-by Jamal Hadi Salim <[email protected]>---
Eric Dumazet
maintainerRe: [PATCH net v2 3/6] net/sched: act_mirred: reject redirects without a link-layer header
In reply to Jamal Hadi SalimQuoted 36 lines · Jamal Hadi Salim
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 withmac_len== 0; mirred then pushes zero bytes and the IP header is parsed as Ethernet byeth_type_trans(). The same happens after a VLANPOP_ETHor 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, require a link-layer header of at leastdev->min_header_lenbytes and pull it into the linear area. Drop the packet otherwise. This mirrors the checkbpf_redirect()already performs and keeps the legitimate push_eth-then-mirred case working.Conditions to recreate the bug:
- create a TUN device withIFF_TUN|IFF_VNET_HDR|IFF_NO_PI;
- attach egress mirred redirect to an Ethernet device (for example lo);
- write avirtio_net_hdrwith hdr_len=1 and an 8192-byte payload. The unfixed kernel parses the IP header as Ethernet and can BUG ineth_type_trans()vialoopback_xmit.Fixes 53592b364001 ("net/sched: act_mirred: Implement ingress actions")Suggested-by Eric Dumazet <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mirred.c | 7 +++++++ 1 file changed, 7 insertions(+)net/sched/act_mirred.c +0
-0
net/sched/act_mirred.c static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, · line 323
Quoted 8 lines
net/sched/act_mirred.c +5
-0@@ -316,6 +316,11 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, } } +if (!expects_nh && + (unlikely (skb_network_offset (skb_to_send) < dev->min_header_len) || + !pskb_may_pull (skb_to_send, dev->min_header_len))) + goto err_cant_do; +
Oops, sorry this breaks tools/testing/selftests/net/forwarding/tc_mpls_l2vpn.sh
My bad, the skb_network_offset() part I suggested in v1 is wrong.
Please remove it:
net/sched/act_mirred.c +0 -0
100644
net/sched/act_mirred.c +0 -0
@@ -317,8 +317,7 @@ static int tcf_mirred_to_dev(struct sk_buff *skb,
struct tcf_mirred *m,
}
if (!expects_nh &&
- (unlikely(skb_network_offset(skb_to_send) < dev->min_header_len) ||
- !pskb_may_pull(skb_to_send, dev->min_header_len)))
+ !pskb_may_pull(skb_to_send, dev->min_header_len))
goto err_cant_do;
skb_to_send->skb_iif = skb->dev->ifindex;Keep only the pskb_may_pull() which is enough to prevent eth_type_trans() from crashing on a short linear part.
Thanks!
Jamal Hadi Salim
maintainerRe: [PATCH net v2 3/6] net/sched: act_mirred: reject redirects without a link-layer header
Quoted 70 lines · Eric Dumazet
Quoted 36 lines · Jamal Hadi Salim
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 withmac_len== 0; mirred then pushes zero bytes and the IP header is parsed as Ethernet byeth_type_trans(). The same happens after a VLANPOP_ETHor 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, require a link-layer header of at leastdev->min_header_lenbytes and pull it into the linear area. Drop the packet otherwise. This mirrors the checkbpf_redirect()already performs and keeps the legitimate push_eth-then-mirred case working.Conditions to recreate the bug:
- create a TUN device withIFF_TUN|IFF_VNET_HDR|IFF_NO_PI;
- attach egress mirred redirect to an Ethernet device (for example lo);
- write avirtio_net_hdrwith hdr_len=1 and an 8192-byte payload. The unfixed kernel parses the IP header as Ethernet and can BUG ineth_type_trans()vialoopback_xmit.Fixes 53592b364001 ("net/sched: act_mirred: Implement ingress actions")Suggested-by Eric Dumazet <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mirred.c | 7 +++++++ 1 file changed, 7 insertions(+)net/sched/act_mirred.c +0
-0net/sched/act_mirred.c static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, · line 323
Quoted 8 lines
net/sched/act_mirred.c +5
-0@@ -316,6 +316,11 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, } } +if (!expects_nh && + (unlikely (skb_network_offset (skb_to_send) < dev->min_header_len) || + !pskb_may_pull (skb_to_send, dev->min_header_len))) + goto err_cant_do; +Oops, sorry this breaks
tools/testing/selftests/net/forwarding/tc_mpls_l2vpn.shMy bad, the
skb_network_offset()part I suggested in v1 is wrong.Please remove it:
net/sched/act_mirred.c +0
-0100644
net/sched/act_mirred.c +1
-2@@ -317,8 +317,7 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, }if (!expects_nh && - (unlikely (skb_network_offset (skb_to_send) < dev->min_header_len) || - !pskb_may_pull (skb_to_send, dev->min_header_len))) + !pskb_may_pull (skb_to_send, dev->min_header_len)) goto err_cant_do;skb_to_send->skb_iif = skb->dev->ifindex;
Quoted 3 lines
Keep only the
pskb_may_pull()which is enough to preventeth_type_trans()from crashing on a short linear part.
Grrr.. Eric, you are not allowed to comment after this.
I should include running those tests going forward when appropriate. I only test tdc and reproducers.
cheers,
jamal
Quoted 1 line
Thanks!
Re: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
In reply to Jamal Hadi SalimQuoted 13 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.
Quoted 8 lines
Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().
Re: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
In reply to Jamal Hadi SalimQuoted 39 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)net/sched/act_mpls.c +0
-0
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 5 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;
Is this first condition needed?
More importantly, can it hide a bug?
Simply running pskb_may_pull is cheap if no pull is needed.
Quoted 7 lines
net/sched/act_mpls.c +0
-0break ;case TCA_MPLS_ACT_PUSH : new_lse =tcf_mpls_get_lse (NULL , p, !eth_p_mpls (skb_protocol (skb, true)));Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove it
Quoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
cheers,
jamal
Quoted 10 lines
Simply running
pskb_may_pullis cheap if no pull is needed.Quoted 7 lines
net/sched/act_mpls.c +0
-1break ;case TCA_MPLS_ACT_PUSH : new_lse =tcf_mpls_get_lse (NULL , p, !eth_p_mpls (skb_protocol (skb, true))); --2.43.0
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 53 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Lol - never mind, stoopid question.
cheers,
jamal
Re: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
In reply to Jamal Hadi SalimQuoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original mac_len is larger, gets popped and the resultant packet is still too short for ETH_HLEN afterwards.
But this can probably not happen, as skb_mpls_pop only pops one MPLS tag.
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
My LLM raised similar points and says it better than I could:
1. Missing protocol check: tcf_mpls_act handles popping MPLS to arbitrary inner protocols (ETH_P_IP, ETH_P_IPV6, ETH_P_MPLS_UC, ETH_P_TEB). Requiring ETH_HLEN (14 bytes) unconditionally when mac_len < ETH_HLEN drops valid non-Ethernet packets shorter than 14 bytes (e.g. popping an outer label to reveal a 4-byte inner label stack entry on an L3 path or after pop_eth). Pulling ETH_HLEN only applies when popping to Ethernet / TEB (p->tcfm_proto == htons(ETH_P_TEB)), exactly as done in patch 5 for Open vSwitch (pop_mpls).
2. Gating on mac_len < ETH_HLEN: mac_len here is the pre-pop outer MAC length. pskb_may_pull is already a no-op if the linear buffer is sufficient; gating on pre-pop mac_len is unnecessary and risks skipping the pull when mac_len >= ETH_HLEN even if the revealed header is in fragments.
3. Downstream metadata invariant: Popping to ETH_P_TEB exposes an inner Ethernet header at skb->data, but skb_mpls_pop leaves skb->mac_len at 0 and resets the network header to 0 (skb_network_offset(skb) == 0). Downstream actions such as act_mirred (with patch 3's skb_network_offset(skb) < dev->min_header_len check) will treat the packet as headerless and drop it, causing regressions in L2VPN forwarding (tc_mpls_l2vpn.sh). When popping to TEB, the L2 MAC header boundaries (mac_len and network header offset) need to be properly established.
──────
### Summary of comments:
• Patch 2/6: Missing inner protocol check (p->tcfm_proto == htons(ETH_P_TEB)) before pulling ETH_HLEN; drops non-Ethernet payloads < 14 bytes.
• Patch 2/6: Unsound pre-pop mac_len < ETH_HLEN gate.
• Patch 2/6: Incomplete header bookkeeping (mac_len and network header offset) on TEB pop breaks subsequent redirect actions (act_mirred).*
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.
Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right only ETH_P_TEB promises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check for p->tcfm_proto == htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.
1/6 (act_vlan POP_ETH) has a similar unconditional pskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:
if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN))
goto drop;Note: skb_eth_pop() only removes the outer ethernet header but does not change skb->protocol
thoughts?
cheers,
jamal
Quoted 23 lines
My LLM raised similar points and says it better than I could:
1. Missing protocol check:
tcf_mpls_acthandles popping MPLS to arbitrary inner protocols (ETH_P_IP,ETH_P_IPV6,ETH_P_MPLS_UC,ETH_P_TEB). RequiringETH_HLEN(14 bytes) unconditionally whenmac_len<ETH_HLENdrops valid non-Ethernet packets shorter than 14 bytes (e.g. popping an outer label to reveal a 4-byte inner label stack entry on an L3 path or afterpop_eth). PullingETH_HLENonly applies when popping to Ethernet / TEB (p->tcfm_proto==htons(ETH_P_TEB)), exactly as done in patch 5 for Open vSwitch (pop_mpls).
2. Gating onmac_len<ETH_HLEN:mac_lenhere is the pre-pop outer MAC length.pskb_may_pullis already a no-op if the linear buffer is sufficient; gating on pre-popmac_lenis unnecessary and risks skipping the pull whenmac_len>=ETH_HLENeven if the revealed header is in fragments.
3. Downstream metadata invariant: Popping toETH_P_TEBexposes an inner Ethernet header atskb->data, butskb_mpls_popleavesskb->mac_lenat 0 and resets the network header to 0 (skb_network_offset(skb)== 0). Downstream actions such asact_mirred(with patch 3'sskb_network_offset(skb)<dev->min_header_lencheck) will treat the packet as headerless and drop it, causing regressions in L2VPN forwarding (tc_mpls_l2vpn.sh). When popping to TEB, the L2 MAC header boundaries (mac_lenand network header offset) need to be properly established.
──────
### Summary of comments:• Patch 2/6: Missing inner protocol check (
p->tcfm_proto==htons(ETH_P_TEB)) before pullingETH_HLEN; drops non-Ethernet payloads < 14 bytes.
• Patch 2/6: Unsound pre-popmac_len<ETH_HLENgate.
• Patch 2/6: Incomplete header bookkeeping (mac_lenand network header offset) on TEB pop breaks subsequent redirect actions (act_mirred).*
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 86 lines · Jamal Hadi Salim
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right onlyETH_P_TEBpromises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check forp->tcfm_proto==htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.
Quoted 9 lines
1/6 (
act_vlanPOP_ETH) has a similar unconditionalpskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN)) goto drop;Note:
skb_eth_pop()only removes the outer ethernet header but does not changeskb->protocol
I am going to send it without this 1/6 change - it just doesn't feel like good taste. I will add a comment in the changes to say i considered it but decided not to. I also spent time eyeballing the code, i dont think there's a potential way to craft a packet that will hit the perceived issue. In any case the 24 hour embargo lifts in a few hours so i am not posting yet.
cheers,
jamal
Quoted 28 lines
thoughts?
cheers,
jamalQuoted 23 lines
My LLM raised similar points and says it better than I could:
1. Missing protocol check:
tcf_mpls_acthandles popping MPLS to arbitrary inner protocols (ETH_P_IP,ETH_P_IPV6,ETH_P_MPLS_UC,ETH_P_TEB). RequiringETH_HLEN(14 bytes) unconditionally whenmac_len<ETH_HLENdrops valid non-Ethernet packets shorter than 14 bytes (e.g. popping an outer label to reveal a 4-byte inner label stack entry on an L3 path or afterpop_eth). PullingETH_HLENonly applies when popping to Ethernet / TEB (p->tcfm_proto==htons(ETH_P_TEB)), exactly as done in patch 5 for Open vSwitch (pop_mpls).
2. Gating onmac_len<ETH_HLEN:mac_lenhere is the pre-pop outer MAC length.pskb_may_pullis already a no-op if the linear buffer is sufficient; gating on pre-popmac_lenis unnecessary and risks skipping the pull whenmac_len>=ETH_HLENeven if the revealed header is in fragments.
3. Downstream metadata invariant: Popping toETH_P_TEBexposes an inner Ethernet header atskb->data, butskb_mpls_popleavesskb->mac_lenat 0 and resets the network header to 0 (skb_network_offset(skb)== 0). Downstream actions such asact_mirred(with patch 3'sskb_network_offset(skb)<dev->min_header_lencheck) will treat the packet as headerless and drop it, causing regressions in L2VPN forwarding (tc_mpls_l2vpn.sh). When popping to TEB, the L2 MAC header boundaries (mac_lenand network header offset) need to be properly established.
──────
### Summary of comments:• Patch 2/6: Missing inner protocol check (
p->tcfm_proto==htons(ETH_P_TEB)) before pullingETH_HLEN; drops non-Ethernet payloads < 14 bytes.
• Patch 2/6: Unsound pre-popmac_len<ETH_HLENgate.
• Patch 2/6: Incomplete header bookkeeping (mac_lenand network header offset) on TEB pop breaks subsequent redirect actions (act_mirred).*
Re: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 104 lines · Jamal Hadi Salim
Quoted 86 lines · Jamal Hadi Salim
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right onlyETH_P_TEBpromises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check forp->tcfm_proto==htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.Quoted 9 lines
1/6 (
act_vlanPOP_ETH) has a similar unconditionalpskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN)) goto drop;Note:
skb_eth_pop()only removes the outer ethernet header but does not changeskb->protocolI am going to send it without this 1/6 change - it just doesn't feel like good taste. I will add a comment in the changes to say i considered it but decided not to. I also spent time eyeballing the code, i dont think there's a potential way to craft a packet that will hit the perceived issue. In any case the 24 hour embargo lifts in a few hours so i am not posting yet.
Quoted 4 lines
cheers,
jamalQuoted 1 line
thoughts?
I'm actually a little confused why the tc layer has to anticipate the needs of downstream code and pull headers here.
That directly lead to this guessing of what may be the next header, such as Ethernet. Which may often be correct, but not always.
All protocol parsing code itself should already be robust and call pskb_may_pull where it is needed. Sounds like there are some targets post TC where that is not true *and* we think there are too many to update those targets directly, rather than this transformation logic that exposes them to unpulled packets?
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 114 lines · Willem de Bruijn
Quoted 104 lines · Jamal Hadi Salim
Quoted 86 lines · Jamal Hadi Salim
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right onlyETH_P_TEBpromises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check forp->tcfm_proto==htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.Quoted 9 lines
1/6 (
act_vlanPOP_ETH) has a similar unconditionalpskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN)) goto drop;Note:
skb_eth_pop()only removes the outer ethernet header but does not changeskb->protocolI am going to send it without this 1/6 change - it just doesn't feel like good taste. I will add a comment in the changes to say i considered it but decided not to. I also spent time eyeballing the code, i dont think there's a potential way to craft a packet that will hit the perceived issue. In any case the 24 hour embargo lifts in a few hours so i am not posting yet.
Quoted 4 lines
cheers,
jamalQuoted 1 line
thoughts?
I'm actually a little confused why the tc layer has to anticipate the needs of downstream code and pull headers here.
Quoted 8 lines
That directly lead to this guessing of what may be the next header, such as Ethernet. Which may often be correct, but not always.
All protocol parsing code itself should already be robust and call
pskb_may_pullwhere it is needed. Sounds like there are some targets post TC where that is not true *and* we think there are too many to update those targets directly, rather than this transformation logic that exposes them to unpulled packets?
Not "too many updates" rather the main motivation here (which i kinda empathize with) is pushback from Eric that you have to "fix at the producer" to avoid performance degradation at the "consumer". i.e rather fix the vlan action than have loopback vet as in the original patch (and you just witnessed him stand up and push back on tun for that same reason ;->).
IOW, we are anticipating so that eth type transfer doesnt bug out (_for ethernet headers_) when invoked at the downstream consumer (loopback etc). Essentially it is a game of whack-a-mole until the next bug or malicious use shows up.
Generally, policing intoxicated drivers from getting on the autobahn isn't the best philosophy; it's better to complement that with a "driver beware, you may encounter drunks" warning but that would slow down the fast car on the autobahn ;->
cheers,
jamal
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 126 lines · Jamal Hadi Salim
Quoted 114 lines · Willem de Bruijn
Quoted 104 lines · Jamal Hadi Salim
Quoted 86 lines · Jamal Hadi Salim
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right onlyETH_P_TEBpromises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check forp->tcfm_proto==htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.Quoted 9 lines
1/6 (
act_vlanPOP_ETH) has a similar unconditionalpskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN)) goto drop;Note:
skb_eth_pop()only removes the outer ethernet header but does not changeskb->protocolI am going to send it without this 1/6 change - it just doesn't feel like good taste. I will add a comment in the changes to say i considered it but decided not to. I also spent time eyeballing the code, i dont think there's a potential way to craft a packet that will hit the perceived issue. In any case the 24 hour embargo lifts in a few hours so i am not posting yet.
Quoted 4 lines
cheers,
jamalQuoted 1 line
thoughts?
I'm actually a little confused why the tc layer has to anticipate the needs of downstream code and pull headers here.
Quoted 8 lines
That directly lead to this guessing of what may be the next header, such as Ethernet. Which may often be correct, but not always.
All protocol parsing code itself should already be robust and call
pskb_may_pullwhere it is needed. Sounds like there are some targets post TC where that is not true *and* we think there are too many to update those targets directly, rather than this transformation logic that exposes them to unpulled packets?
Quoted 14 lines
Not "too many updates" rather the main motivation here (which i kinda empathize with) is pushback from Eric that you have to "fix at the producer" to avoid performance degradation at the "consumer". i.e rather fix the vlan action than have loopback vet as in the original patch (and you just witnessed him stand up and push back on tun for that same reason ;->).
IOW, we are anticipating so that eth type transfer doesnt bug out (_forethernetheaders_) when invoked at the downstream consumer (loopback etc). Essentially it is a game of whack-a-mole until the next bug or malicious use shows up.
Generally, policing intoxicated drivers from getting on the autobahn isn't the best philosophy; it's better to complement that with a "driver beware, you may encounter drunks" warning but that would slow down the fast car on the autobahn ;->
Actually the more i think about this the more i am concluding just fixing the producers wont be sufficient (Eric!).
If i have an incompetent or malicious ebpf program it could do whatever it wants.. I am going to try something with ebpf.
cheers,
jamal
Quoted 2 lines
cheers,
jamal
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 143 lines · Jamal Hadi Salim
Quoted 126 lines · Jamal Hadi Salim
Quoted 114 lines · Willem de Bruijn
Quoted 104 lines · Jamal Hadi Salim
Quoted 86 lines · Jamal Hadi Salim
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right onlyETH_P_TEBpromises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check forp->tcfm_proto==htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.Quoted 9 lines
1/6 (
act_vlanPOP_ETH) has a similar unconditionalpskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN)) goto drop;Note:
skb_eth_pop()only removes the outer ethernet header but does not changeskb->protocolI am going to send it without this 1/6 change - it just doesn't feel like good taste. I will add a comment in the changes to say i considered it but decided not to. I also spent time eyeballing the code, i dont think there's a potential way to craft a packet that will hit the perceived issue. In any case the 24 hour embargo lifts in a few hours so i am not posting yet.
Quoted 4 lines
cheers,
jamalQuoted 1 line
thoughts?
I'm actually a little confused why the tc layer has to anticipate the needs of downstream code and pull headers here.
Quoted 8 lines
That directly lead to this guessing of what may be the next header, such as Ethernet. Which may often be correct, but not always.
All protocol parsing code itself should already be robust and call
pskb_may_pullwhere it is needed. Sounds like there are some targets post TC where that is not true *and* we think there are too many to update those targets directly, rather than this transformation logic that exposes them to unpulled packets?Quoted 14 lines
Not "too many updates" rather the main motivation here (which i kinda empathize with) is pushback from Eric that you have to "fix at the producer" to avoid performance degradation at the "consumer". i.e rather fix the vlan action than have loopback vet as in the original patch (and you just witnessed him stand up and push back on tun for that same reason ;->).
IOW, we are anticipating so that eth type transfer doesnt bug out (_forethernetheaders_) when invoked at the downstream consumer (loopback etc). Essentially it is a game of whack-a-mole until the next bug or malicious use shows up.
Generally, policing intoxicated drivers from getting on the autobahn isn't the best philosophy; it's better to complement that with a "driver beware, you may encounter drunks" warning but that would slow down the fast car on the autobahn ;->
Quoted 4 lines
Actually the more i think about this the more i am concluding just fixing the producers wont be sufficient (Eric!).
If i have an incompetent or malicious ebpf program it could do whatever it wants.. I am going to try something with ebpf.
And the reason i am bringing up ebpf is because i noticed sashikos after like several iterations of a patch find a way to sneak in some ebpf corner case. So i am sure that is coming (if indeed an issue can be reproduced)
cheers,
jamal
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 150 lines · Jamal Hadi Salim
Quoted 143 lines · Jamal Hadi Salim
Quoted 126 lines · Jamal Hadi Salim
Quoted 114 lines · Willem de Bruijn
Quoted 104 lines · Jamal Hadi Salim
Quoted 86 lines · Jamal Hadi Salim
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right onlyETH_P_TEBpromises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check forp->tcfm_proto==htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.Quoted 9 lines
1/6 (
act_vlanPOP_ETH) has a similar unconditionalpskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN)) goto drop;Note:
skb_eth_pop()only removes the outer ethernet header but does not changeskb->protocolI am going to send it without this 1/6 change - it just doesn't feel like good taste. I will add a comment in the changes to say i considered it but decided not to. I also spent time eyeballing the code, i dont think there's a potential way to craft a packet that will hit the perceived issue. In any case the 24 hour embargo lifts in a few hours so i am not posting yet.
Quoted 4 lines
cheers,
jamalQuoted 1 line
thoughts?
I'm actually a little confused why the tc layer has to anticipate the needs of downstream code and pull headers here.
Quoted 8 lines
That directly lead to this guessing of what may be the next header, such as Ethernet. Which may often be correct, but not always.
All protocol parsing code itself should already be robust and call
pskb_may_pullwhere it is needed. Sounds like there are some targets post TC where that is not true *and* we think there are too many to update those targets directly, rather than this transformation logic that exposes them to unpulled packets?Quoted 14 lines
Not "too many updates" rather the main motivation here (which i kinda empathize with) is pushback from Eric that you have to "fix at the producer" to avoid performance degradation at the "consumer". i.e rather fix the vlan action than have loopback vet as in the original patch (and you just witnessed him stand up and push back on tun for that same reason ;->).
IOW, we are anticipating so that eth type transfer doesnt bug out (_forethernetheaders_) when invoked at the downstream consumer (loopback etc). Essentially it is a game of whack-a-mole until the next bug or malicious use shows up.
Generally, policing intoxicated drivers from getting on the autobahn isn't the best philosophy; it's better to complement that with a "driver beware, you may encounter drunks" warning but that would slow down the fast car on the autobahn ;->Quoted 4 lines
Actually the more i think about this the more i am concluding just fixing the producers wont be sufficient (Eric!).
If i have an incompetent or malicious ebpf program it could do whatever it wants.. I am going to try something with ebpf.
Quoted 4 lines
And the reason i am bringing up ebpf is because i noticed sashikos after like several iterations of a patch find a way to sneak in some ebpf corner case. So i am sure that is coming (if indeed an issue can be reproduced)
confirmed.
#include <linux/bpf.h>
#include <linux/pkt_cls.h>
#define SEC(NAME) __attribute__((section(NAME), used))
static long (*bpf_skb_adjust_room)(void *skb, __s32 len_diff,
__u32 mode, __u64 flags) =
(void *)BPF_FUNC_skb_adjust_room;
SEC("action")
int shrink(struct __sk_buff *skb)
{
bpf_skb_adjust_room(skb, -1, BPF_ADJ_ROOM_MAC, 0);
return TC_ACT_OK;
}
char _license[] SEC("license") = "GPL"; ip link set lo up
tc qdisc add dev lo clsact
tc filter add dev lo egress matchall \
action vlan pop_eth pipe \
action bpf object-file /mnt/shrink.o section action
tc filter show
action order 1: vlan pop_eth pipe
action order 2: bpf shrink.o:[action] ... jited default-action pipe
And boom:
[ 6.748140] kernel BUG at ./include/linux/skbuff.h:2830!
[ 6.748154] Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
[ 6.749434] CPU: 1 UID: 0 PID: 301 Comm: mini_poc Not tainted
7.3.0-rc7+ #271 PREEMPT(full)
[ 6.750115] RIP: 0010:eth_type_trans+0x335/0x500
...
[ 6.757723] loopback_xmit+0x1c1/0x580
...
[ 6.778076] Kernel panic - not syncing: Fatal exception in interruptEric, any ideas?
cheers,
jamal
Jamal Hadi Salim
maintainerRe: [PATCH net v2 2/6] net/sched: act_mpls: pull the inner Ethernet header after POP
Quoted 196 lines · Jamal Hadi Salim
Quoted 150 lines · Jamal Hadi Salim
Quoted 143 lines · Jamal Hadi Salim
Quoted 126 lines · Jamal Hadi Salim
Quoted 114 lines · Willem de Bruijn
Quoted 104 lines · Jamal Hadi Salim
Quoted 86 lines · Jamal Hadi Salim
. On Fri, Oct 23, 2026 at 6:50 PM Willem de Bruijn
Quoted 69 lines · <[email protected]> wrote:
Quoted 52 lines · Jamal Hadi Salim
Quoted 36 lines · Willem de Bruijn
Quoted 34 lines · Jamal Hadi Salim
The issue:
act_mplsPOP can leave the inner Ethernet header in a page fragment afterskb_mpls_pop(), either on an L3 device (mac_len== 0) or chained afteract_vlanPOP_ETH. A followingeth_type_trans()can then BUG in__skb_pull().The Fix:
After the pop, if the original MAC header is shorter thanETH_HLEN, pull the inner Ethernet header into the linear area and drop only whenpskb_may_pull(skb, ETH_HLEN)fails.skb_mpls_pop()does nothing when the skb was not MPLS, so no separate state is needed.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_ethaction mpls pop (chained), or on an L3 device wheremac_len== 0.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / mpls / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().Fixes 2a2ea50870ba ("net: sched: add mpls manipulation actions to TC")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiiqSMdYQYeeW0Fk_GK6ekR4xiS4zPrGKrbB9wZknpqf1-w@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>--- net/sched/act_mpls.c | 2 ++ 1 file changed, 2 insertions(+)Quoted 13 lines
net/sched/act_mpls.c TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb, · line 83
Quoted 10 lines
net/sched/act_mpls.c +2
-0@@ -79,6 +79,8 @@ TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,if (skb_mpls_pop (skb, p->tcfm_proto, mac_len, skb->dev && skb->dev->type ==ARPHRD_ETHER )) goto drop; +if (mac_len <ETH_HLEN && !pskb_may_pull (skb,ETH_HLEN )) + goto drop;Is this first condition needed?
Quoted 8 lines
That was me conjecturing from Eric saying in v1 "...the check can only matter when the original MAC header is short.."
Since i have to send a v3 (Thanks Eric;->) I will remove itQuoted 2 lines
More importantly, can it hide a bug?
What kind of bug?
Two kinds. One, if original
mac_lenis larger, gets popped and the resultant packet is still too short forETH_HLENafterwards.But this can probably not happen, as
skb_mpls_poponly pops one MPLS tag.Quoted 7 lines
What this patch tries to ensure is that the subsequent Ethernet header is linear.
The second potential bug is this assumption that after the MPLS tag lies an Ethernet header. Is that a valid assumption? Or could we drop a valid packet with smaller header.
tbh, I was thinking more about skb frags earlier.
You are right onlyETH_P_TEBpromises an inner Ethernet header; for other inner protocols the pull is wrong, so I’ll check forp->tcfm_proto==htons(ETH_P_TEB). I didnt have this check in the current fix - good you responded before i sent out.Quoted 9 lines
1/6 (
act_vlanPOP_ETH) has a similar unconditionalpskb_may_pull(ETH_HLEN). A brute approach is also to check for TEB:if (skb->protocol == htons(ETH_P_TEB) && !pskb_may_pull(skb, ETH_HLEN)) goto drop;Note:
skb_eth_pop()only removes the outer ethernet header but does not changeskb->protocolI am going to send it without this 1/6 change - it just doesn't feel like good taste. I will add a comment in the changes to say i considered it but decided not to. I also spent time eyeballing the code, i dont think there's a potential way to craft a packet that will hit the perceived issue. In any case the 24 hour embargo lifts in a few hours so i am not posting yet.
Quoted 4 lines
cheers,
jamalQuoted 1 line
thoughts?
I'm actually a little confused why the tc layer has to anticipate the needs of downstream code and pull headers here.
Quoted 8 lines
That directly lead to this guessing of what may be the next header, such as Ethernet. Which may often be correct, but not always.
All protocol parsing code itself should already be robust and call
pskb_may_pullwhere it is needed. Sounds like there are some targets post TC where that is not true *and* we think there are too many to update those targets directly, rather than this transformation logic that exposes them to unpulled packets?Quoted 14 lines
Not "too many updates" rather the main motivation here (which i kinda empathize with) is pushback from Eric that you have to "fix at the producer" to avoid performance degradation at the "consumer". i.e rather fix the vlan action than have loopback vet as in the original patch (and you just witnessed him stand up and push back on tun for that same reason ;->).
IOW, we are anticipating so that eth type transfer doesnt bug out (_forethernetheaders_) when invoked at the downstream consumer (loopback etc). Essentially it is a game of whack-a-mole until the next bug or malicious use shows up.
Generally, policing intoxicated drivers from getting on the autobahn isn't the best philosophy; it's better to complement that with a "driver beware, you may encounter drunks" warning but that would slow down the fast car on the autobahn ;->Quoted 4 lines
Actually the more i think about this the more i am concluding just fixing the producers wont be sufficient (Eric!).
If i have an incompetent or malicious ebpf program it could do whatever it wants.. I am going to try something with ebpf.Quoted 4 lines
And the reason i am bringing up ebpf is because i noticed sashikos after like several iterations of a patch find a way to sneak in some ebpf corner case. So i am sure that is coming (if indeed an issue can be reproduced)
confirmed.
#include <linux/bpf.h> #include <linux/pkt_cls.h> #define SEC(NAME) __attribute__((section(NAME), used)) static long (*bpf_skb_adjust_room)(void *skb, __s32 len_diff, __u32 mode, __u64 flags) = (void *)BPF_FUNC_skb_adjust_room; SEC("action") int shrink(struct __sk_buff *skb) { bpf_skb_adjust_room(skb, -1, BPF_ADJ_ROOM_MAC, 0); return TC_ACT_OK; } char _license[] SEC("license") = "GPL";ip link set lo up
tc qdisc add dev lo clsact
tc filter add dev lo egress matchall \
action vlanpop_ethpipe \
action bpf object-file/mnt/shrink.osection actiontc filter show
action order 1: vlan
pop_ethpipe
action order 2: bpf shrink.o:[action] ... jited default-action pipeAnd boom:
[ 6.748140] kernel BUG at ./include/linux/skbuff.h:2830! [ 6.748154] Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI [ 6.749434] CPU: 1 UID: 0 PID: 301 Comm: mini_poc Not tainted 7.3.0-rc7+ #271 PREEMPT(full) [ 6.750115] RIP: 0010:eth_type_trans+0x335/0x500 ... [ 6.757723] loopback_xmit+0x1c1/0x580 ... [ 6.778076] Kernel panic - not syncing: Fatal exception in interrupt
Quoted 2 lines
Eric, any ideas?
And worse, i just tested a non ethernet next header for mpls (the TEB check is a bad idea) and it killed the kernel as well:
tc filter add dev lo egress protocol all flower action vlan pop_eth pipe action mpls pop protocol ip pipe action gact pass
BUG at include/linux/skbuff.h:2830 in eth_type_trans via loopback_xmit
I am going to withdraw this series - lets reach some consensus first.
cheers,
jamal
Quoted 2 lines
cheers,
jamal
Re: [PATCH net v2 1/6] net/sched: act_vlan: pull the inner Ethernet header after POP_ETH
In reply to Jamal Hadi SalimQuoted 19 lines · Jamal Hadi Salim
The issue:
act_vlanPOP_ETHremoves the outer Ethernet header and leaves the inner Ethernet header at the head of the packet. A non-linear skb can have the inner header in a page fragment, so a followingeth_type_trans()may find less thanETH_HLENbytes in the linear area and BUG in__skb_pull().The Fix:
Pull the inner Ethernet header into the linear area afterskb_eth_pop():
drop the packet only whenpskb_may_pull(skb, ETH_HLEN)fails. This keeps valid non-linear packets whose inner header sits in frags.Conditions to recreate the bug:
- egress tc filter on lo: action vlanpop_eth.
-AF_PACKETSOCK_RAWwithPACKET_VNET_HDR, hdr_len=28, and a non-linear eth / inner-eth frame.
- The inner header is in page frags; a followingeth_type_trans()can BUG in__skb_pull().
Quoted 12 lines
Fixes 19fbcb36a39e ("net/sched: act_vlan: Add {POP,PUSH}_ETH actions")Reported-by Vega <[email protected]>Link https://lore.kernel.org/r/40fe2d7dfce13411bfbe9271c0f7c54fb7e88e3b.1782548651.git.bronzed_45_vested@icloud.com/ open hereLink https://lore.kernel.org/netdev/CAL4WiipJLzZ9ywOPaFHZ+wePTOuO+6+aaRCVXMHz+xmmQm2hcA@mail.gmail.com/ open hereSuggested-by Jakub Kicinski <[email protected]>Suggested-by Willem de Bruijn <[email protected]>Suggested-by Eric Dumazet <[email protected]>Reviewed-by Victor Nogueira <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>
Thanks!
Jakub Kicinski
maintainerQuoted 16 lines · On Fri, 23 Oct 2026 07:59:15 -0400 Jamal Hadi Salim wrote:
This series fixes a class of producer/consumer bugs in which an outer header is popped and the packet is then handed to a consumer with fewer than
ETH_HLENbytes in the linear area.eth_type_trans()pullsETH_HLENfrom that area and can BUG in__skb_pull()when the inner Ethernet header is not linear. The affected producers areact_vlanPOP_ETH,act_mplsPOP,act_ifeegress decode, and the Open vSwitch MPLS/TEB and NSH pops. A consumer-side guard inact_mirredrejects redirecting a headerless packet to a device that expects a link-layer header.Patch 1 makes
act_vlanPOP_ETHpull the inner Ethernet header after the pop and drop only when the packet is genuinely shorter thanETH_HLEN. Patch 2 does the same foract_mpls, gated on the pre-pop MAC length. Patch 3 adds theact_mirredguard at the redirect boundary. Patch 4 keepsact_ifeegress decode from consuming the inner Ethernet header and restores the header metadata.
Quoted 2 lines
Patches 5 and 6 establish the same linear-header invariant for the OVS MPLS/TEB and NSH pops before restoring
MAC_PROTO_ETHERNET.
NIPA CI flagged a regression that appears to be introduced by this patch (or one of the closely related act_vlan/act_mirred patches in the same series).
The selftest tools/testing/selftests/net/forwarding/tc_mpls_l2vpn.sh now fails reliably (both the "ping" and "ping6" sub-tests, on both the regular and debug forwarding test configs, consistently on retry as well):
# TEST: ping [FAIL]
# TEST: ping6 [FAIL]
The test builds an Ethernet-over-MPLS L2VPN using exactly the tc action sequence this series touches:
- ingress: mpls mac_push + vlan push_eth + mirred egress redirect
- ingress: vlan pop_eth + mpls pop protocol teb + mirred egress redirect
dmesg on the test run shows mirred failing to redirect the traffic:
tc mirred to Houston: device veth2 is down
tc mirred to Houston: device veth3 is down
This is the same "vlan pop_eth followed by mpls pop" chain described in this patch's own commit message as the bug reproduction scenario, so it looks like the mac_len/pskb_may_pull bookkeeping added here may not be correctly handling the ingress case used by this test, causing otherwise valid packets built by this chain to be mishandled and the redirect to fail.
Could you take a look at whether the new POP header-pull logic correctly handles the "vlan pop_eth -> mpls pop protocol teb -> mirred redirect" chain on ingress? It would also be worth double-checking this alongside the companion act_vlan POP_ETH and act_mirred link-layer-header patches from the same series, since they touch the same pipeline.
Jamal Hadi Salim
maintainerQuoted 51 lines · Jakub Kicinski
Quoted 16 lines · On Fri, 23 Oct 2026 07:59:15 -0400 Jamal Hadi Salim wrote:
This series fixes a class of producer/consumer bugs in which an outer header is popped and the packet is then handed to a consumer with fewer than
ETH_HLENbytes in the linear area.eth_type_trans()pullsETH_HLENfrom that area and can BUG in__skb_pull()when the inner Ethernet header is not linear. The affected producers areact_vlanPOP_ETH,act_mplsPOP,act_ifeegress decode, and the Open vSwitch MPLS/TEB and NSH pops. A consumer-side guard inact_mirredrejects redirecting a headerless packet to a device that expects a link-layer header.Patch 1 makes
act_vlanPOP_ETHpull the inner Ethernet header after the pop and drop only when the packet is genuinely shorter thanETH_HLEN. Patch 2 does the same foract_mpls, gated on the pre-pop MAC length. Patch 3 adds theact_mirredguard at the redirect boundary. Patch 4 keepsact_ifeegress decode from consuming the inner Ethernet header and restores the header metadata.Quoted 2 lines
Patches 5 and 6 establish the same linear-header invariant for the OVS MPLS/TEB and NSH pops before restoring
MAC_PROTO_ETHERNET.NIPA CI flagged a regression that appears to be introduced by this patch (or one of the closely related act_vlan/act_mirred patches in the same series).
The selftest
tools/testing/selftests/net/forwarding/tc_mpls_l2vpn.shnow fails reliably (both the "ping" and "ping6" sub-tests, on both the regular and debug forwarding test configs, consistently on retry as well):# TEST: ping [FAIL]
# TEST: ping6 [FAIL]The test builds an Ethernet-over-MPLS L2VPN using exactly the tc action sequence this series touches:
- ingress: mpls
mac_push+ vlanpush_eth+ mirred egress redirect
- ingress: vlanpop_eth+ mpls pop protocol teb + mirred egress redirectdmesg on the test run shows mirred failing to redirect the traffic:
tc mirred to Houston: device veth2 is down
tc mirred to Houston: device veth3 is downThis is the same "vlan
pop_ethfollowed by mpls pop" chain described in this patch's own commit message as the bug reproduction scenario, so it looks like the mac_len/pskb_may_pull bookkeeping added here may not be correctly handling the ingress case used by this test, causing otherwise valid packets built by this chain to be mishandled and the redirect to fail.
Quoted 5 lines
Could you take a look at whether the new POP header-pull logic correctly handles the "vlan
pop_eth-> mpls pop protocol teb -> mirred redirect" chain on ingress? It would also be worth double-checking this alongside the companionact_vlanPOP_ETHandact_mirredlink-layer-header patches from the same series, since they touch the same pipeline.
Victor monitors NIPA but is currently away for a few days. I will take a look. Eric pointed out this broke:tools/testing/selftests/net/forwarding/tc_mpls_l2vpn.sh
I'm working on updating that and will try to fix this as well..
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 59 lines · Jamal Hadi Salim
Quoted 51 lines · Jakub Kicinski
Quoted 16 lines · On Fri, 23 Oct 2026 07:59:15 -0400 Jamal Hadi Salim wrote:
This series fixes a class of producer/consumer bugs in which an outer header is popped and the packet is then handed to a consumer with fewer than
ETH_HLENbytes in the linear area.eth_type_trans()pullsETH_HLENfrom that area and can BUG in__skb_pull()when the inner Ethernet header is not linear. The affected producers areact_vlanPOP_ETH,act_mplsPOP,act_ifeegress decode, and the Open vSwitch MPLS/TEB and NSH pops. A consumer-side guard inact_mirredrejects redirecting a headerless packet to a device that expects a link-layer header.Patch 1 makes
act_vlanPOP_ETHpull the inner Ethernet header after the pop and drop only when the packet is genuinely shorter thanETH_HLEN. Patch 2 does the same foract_mpls, gated on the pre-pop MAC length. Patch 3 adds theact_mirredguard at the redirect boundary. Patch 4 keepsact_ifeegress decode from consuming the inner Ethernet header and restores the header metadata.Quoted 2 lines
Patches 5 and 6 establish the same linear-header invariant for the OVS MPLS/TEB and NSH pops before restoring
MAC_PROTO_ETHERNET.NIPA CI flagged a regression that appears to be introduced by this patch (or one of the closely related act_vlan/act_mirred patches in the same series).
The selftest
tools/testing/selftests/net/forwarding/tc_mpls_l2vpn.shnow fails reliably (both the "ping" and "ping6" sub-tests, on both the regular and debug forwarding test configs, consistently on retry as well):# TEST: ping [FAIL]
# TEST: ping6 [FAIL]The test builds an Ethernet-over-MPLS L2VPN using exactly the tc action sequence this series touches:
- ingress: mpls
mac_push+ vlanpush_eth+ mirred egress redirect
- ingress: vlanpop_eth+ mpls pop protocol teb + mirred egress redirectdmesg on the test run shows mirred failing to redirect the traffic:
tc mirred to Houston: device veth2 is down
tc mirred to Houston: device veth3 is downThis is the same "vlan
pop_ethfollowed by mpls pop" chain described in this patch's own commit message as the bug reproduction scenario, so it looks like the mac_len/pskb_may_pull bookkeeping added here may not be correctly handling the ingress case used by this test, causing otherwise valid packets built by this chain to be mishandled and the redirect to fail.Quoted 5 lines
Could you take a look at whether the new POP header-pull logic correctly handles the "vlan
pop_eth-> mpls pop protocol teb -> mirred redirect" chain on ingress? It would also be worth double-checking this alongside the companionact_vlanPOP_ETHandact_mirredlink-layer-header patches from the same series, since they touch the same pipeline.
Quoted 4 lines
Victor monitors NIPA but is currently away for a few days. I will take a look. Eric pointed out this broke:
tools/testing/selftests/net/forwarding/tc_mpls_l2vpn.sh
I'm working on updating that and will try to fix this as well..
ok, the new update fixes this. I was planning to wait for the obligatory 24 hours (so tommorow my AM)- unless you say otherwise..
cheers,
jamal
Quoted 2 lines
cheers,
jamal