From: Li RongQing Date: Sat, 18 Oct 2014 09:26:04 +0000 (+0800) Subject: ipv4: fix a potential use after free in gre_offload.c X-Git-Tag: firefly_0821_release~176^2~3001^2~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b4e3cef703fb21b26db053a770900f2bd910638b;p=firefly-linux-kernel-4.4.55.git ipv4: fix a potential use after free in gre_offload.c pskb_may_pull() may change skb->data and make greh pointer oboslete; so need to reassign greh; but since first calling pskb_may_pull already ensured that skb->data has enough space for greh, so move the reference of greh before second calling pskb_may_pull(), to avoid reassign greh. Fixes: 7a7ffbabf9("ipv4: fix tunneled VM traffic over hw VXLAN/GRE GSO NIC") Cc: Wei-Chun Chao Signed-off-by: Li RongQing Acked-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c index a77729503071..ccda09628de7 100644 --- a/net/ipv4/gre_offload.c +++ b/net/ipv4/gre_offload.c @@ -55,13 +55,13 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, if (csum) skb->encap_hdr_csum = 1; - if (unlikely(!pskb_may_pull(skb, ghl))) - goto out; - /* setup inner skb. */ skb->protocol = greh->protocol; skb->encapsulation = 0; + if (unlikely(!pskb_may_pull(skb, ghl))) + goto out; + __skb_pull(skb, ghl); skb_reset_mac_header(skb); skb_set_network_header(skb, skb_inner_network_offset(skb));