Skip to content

Commit 4296adc

Browse files
Guillaume Naultdavem330
authored andcommitted
net/core: check length before updating Ethertype in skb_mpls_{push,pop}
Openvswitch allows to drop a packet's Ethernet header, therefore skb_mpls_push() and skb_mpls_pop() might be called with ethernet=true and mac_len=0. In that case the pointer passed to skb_mod_eth_type() doesn't point to an Ethernet header and the new Ethertype is written at unexpected locations. Fix this by verifying that mac_len is big enough to contain an Ethernet header. Fixes: fa4e0f8 ("net/sched: fix corrupted L2 header with MPLS 'push' and 'pop' actions") Signed-off-by: Guillaume Nault <[email protected]> Acked-by: Davide Caratti <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f4544e5 commit 4296adc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/core/skbuff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5622,7 +5622,7 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
56225622
lse->label_stack_entry = mpls_lse;
56235623
skb_postpush_rcsum(skb, lse, MPLS_HLEN);
56245624

5625-
if (ethernet)
5625+
if (ethernet && mac_len >= ETH_HLEN)
56265626
skb_mod_eth_type(skb, eth_hdr(skb), mpls_proto);
56275627
skb->protocol = mpls_proto;
56285628

@@ -5662,7 +5662,7 @@ int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
56625662
skb_reset_mac_header(skb);
56635663
skb_set_network_header(skb, mac_len);
56645664

5665-
if (ethernet) {
5665+
if (ethernet && mac_len >= ETH_HLEN) {
56665666
struct ethhdr *hdr;
56675667

56685668
/* use mpls_hdr() to get ethertype to account for VLANs. */

0 commit comments

Comments
 (0)