Skip to content

Commit

Permalink
net: skbuff: ensure LSE is pullable before decrementing the MPLS ttl
Browse files Browse the repository at this point in the history
skb_mpls_dec_ttl() reads the LSE without ensuring that it is contained in
the skb "linear" area. Fix this calling pskb_may_pull() before reading the
current ttl.

Found by code inspection.

Fixes: 2a2ea50 ("net: sched: add mpls manipulation actions to TC")
Reported-by: Marcelo Ricardo Leitner <[email protected]>
Signed-off-by: Davide Caratti <[email protected]>
Link: https://lore.kernel.org/r/53659f28be8bc336c113b5254dc637cc76bbae91.1606987074.git.dcaratti@redhat.com
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
dcaratti authored and kuba-moo committed Dec 3, 2020
1 parent 6392b5b commit 13de4ed
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -5786,6 +5786,9 @@ int skb_mpls_dec_ttl(struct sk_buff *skb)
if (unlikely(!eth_p_mpls(skb->protocol)))
return -EINVAL;

if (!pskb_may_pull(skb, skb_network_offset(skb) + MPLS_HLEN))
return -ENOMEM;

lse = be32_to_cpu(mpls_hdr(skb)->label_stack_entry);
ttl = (lse & MPLS_LS_TTL_MASK) >> MPLS_LS_TTL_SHIFT;
if (!--ttl)
Expand Down

0 comments on commit 13de4ed

Please sign in to comment.