netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv4: fix a potential use after free in gre_offload.c
@ 2014-10-18  9:26 roy.qing.li
  2014-10-18 15:47 ` Eric Dumazet
  2014-10-18 17:07 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: roy.qing.li @ 2014-10-18  9:26 UTC (permalink / raw)
  To: netdev; +Cc: weichunc

From: Li RongQing <roy.qing.li@gmail.com>

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>
---
 net/ipv4/gre_offload.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index a777295..ccda096 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));
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ipv4: fix a potential use after free in gre_offload.c
  2014-10-18  9:26 [PATCH] ipv4: fix a potential use after free in gre_offload.c roy.qing.li
@ 2014-10-18 15:47 ` Eric Dumazet
  2014-10-18 17:07 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2014-10-18 15:47 UTC (permalink / raw)
  To: roy.qing.li; +Cc: netdev, weichunc

On Sat, 2014-10-18 at 17:26 +0800, roy.qing.li@gmail.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
> 
> 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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ipv4: fix a potential use after free in gre_offload.c
  2014-10-18  9:26 [PATCH] ipv4: fix a potential use after free in gre_offload.c roy.qing.li
  2014-10-18 15:47 ` Eric Dumazet
@ 2014-10-18 17:07 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-10-18 17:07 UTC (permalink / raw)
  To: roy.qing.li; +Cc: netdev, weichunc

From: roy.qing.li@gmail.com
Date: Sat, 18 Oct 2014 17:26:04 +0800

> From: Li RongQing <roy.qing.li@gmail.com>
> 
> 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>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-18 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-18  9:26 [PATCH] ipv4: fix a potential use after free in gre_offload.c roy.qing.li
2014-10-18 15:47 ` Eric Dumazet
2014-10-18 17:07 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).