Skip to content

Commit

Permalink
net: Fix potential wrong skb->protocol in skb_vlan_untag()
Browse files Browse the repository at this point in the history
[ Upstream commit 55eff0e ]

We may access the two bytes after vlan_hdr in vlan_set_encap_proto(). So
we should pull VLAN_HLEN + sizeof(unsigned short) in skb_vlan_untag() or
we may access the wrong data.

Fixes: 0d5501c ("net: Always untag vlan-tagged traffic on input.")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
MiaoheLin authored and gregkh committed Sep 3, 2020
1 parent b5e3412 commit 6ed8917
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/core/skbuff.c
Expand Up @@ -5317,8 +5317,8 @@ struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
skb = skb_share_check(skb, GFP_ATOMIC);
if (unlikely(!skb))
goto err_free;

if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
/* We may access the two bytes after vlan_hdr in vlan_set_encap_proto(). */
if (unlikely(!pskb_may_pull(skb, VLAN_HLEN + sizeof(unsigned short))))
goto err_free;

vhdr = (struct vlan_hdr *)skb->data;
Expand Down

0 comments on commit 6ed8917

Please sign in to comment.