Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv4: fix a potential use after free in ip_tunnel_core.c

pskb_may_pull() maybe change skb->data and make eth pointer oboslete,
so set eth after pskb_may_pull()

Fixes:3d7b46cd("ip_tunnel: push generic protocol handling to ip_tunnel module")
Cc: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Li RongQing and committed by
David S. Miller
1245dfc8 f88e6714

+2 -1
+2 -1
net/ipv4/ip_tunnel_core.c
··· 91 91 skb_pull_rcsum(skb, hdr_len); 92 92 93 93 if (inner_proto == htons(ETH_P_TEB)) { 94 - struct ethhdr *eh = (struct ethhdr *)skb->data; 94 + struct ethhdr *eh; 95 95 96 96 if (unlikely(!pskb_may_pull(skb, ETH_HLEN))) 97 97 return -ENOMEM; 98 98 99 + eh = (struct ethhdr *)skb->data; 99 100 if (likely(ntohs(eh->h_proto) >= ETH_P_802_3_MIN)) 100 101 skb->protocol = eh->h_proto; 101 102 else