ipv4: fix a potential use after free in ip_tunnel_core.c
authorLi RongQing <roy.qing.li@gmail.com>
Fri, 17 Oct 2014 08:53:23 +0000 (16:53 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 18 Oct 2014 03:45:26 +0000 (23:45 -0400)
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>
net/ipv4/ip_tunnel_core.c

index f4c987bb7e94a45fd72c245a323fb4cedade4078..88c386cf7d85a985b9bd0aca11d3528347aea152 100644 (file)
@@ -91,11 +91,12 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
        skb_pull_rcsum(skb, hdr_len);
 
        if (inner_proto == htons(ETH_P_TEB)) {
-               struct ethhdr *eh = (struct ethhdr *)skb->data;
+               struct ethhdr *eh;
 
                if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
                        return -ENOMEM;
 
+               eh = (struct ethhdr *)skb->data;
                if (likely(ntohs(eh->h_proto) >= ETH_P_802_3_MIN))
                        skb->protocol = eh->h_proto;
                else