diff options
author | Li RongQing <roy.qing.li@gmail.com> | 2014-10-18 05:26:04 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-18 13:04:08 -0400 |
commit | b4e3cef703fb21b26db053a770900f2bd910638b (patch) | |
tree | 8eb99932d3c7af0461a93467ad8b3f0549745d69 | |
parent | 815afe1785da727ee48cd8e63ac4a3ec6c7459b3 (diff) |
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 <weichunc@plumgrid.com>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/gre_offload.c | 6 |
1 files changed, 3 insertions, 3 deletions
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, | |||
55 | if (csum) | 55 | if (csum) |
56 | skb->encap_hdr_csum = 1; | 56 | skb->encap_hdr_csum = 1; |
57 | 57 | ||
58 | if (unlikely(!pskb_may_pull(skb, ghl))) | ||
59 | goto out; | ||
60 | |||
61 | /* setup inner skb. */ | 58 | /* setup inner skb. */ |
62 | skb->protocol = greh->protocol; | 59 | skb->protocol = greh->protocol; |
63 | skb->encapsulation = 0; | 60 | skb->encapsulation = 0; |
64 | 61 | ||
62 | if (unlikely(!pskb_may_pull(skb, ghl))) | ||
63 | goto out; | ||
64 | |||
65 | __skb_pull(skb, ghl); | 65 | __skb_pull(skb, ghl); |
66 | skb_reset_mac_header(skb); | 66 | skb_reset_mac_header(skb); |
67 | skb_set_network_header(skb, skb_inner_network_offset(skb)); | 67 | skb_set_network_header(skb, skb_inner_network_offset(skb)); |