Patchwork [v3] IP_GRE: Fix kernel panic in IP_GRE with GRE csum.

login
register
mail settings
Submitter Pravin B Shelar
Date Jan. 23, 2013, 9:45 p.m.
Message ID <1358977542-1627-1-git-send-email-pshelar@nicira.com>
Download mbox | patch
Permalink /patch/215052/
State Accepted
Delegated to: David Miller
Headers show

Comments

Pravin B Shelar - Jan. 23, 2013, 9:45 p.m.
Due to IP_GRE GSO support, GRE can recieve non linear skb which
results in panic in case of GRE_CSUM.
Following patch fixes it by using correct csum API.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
v3: Coding style Fix.

---
 net/ipv4/ip_gre.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Eric Dumazet - Jan. 23, 2013, 10 p.m.
On Wed, 2013-01-23 at 13:45 -0800, Pravin B Shelar wrote:
> Due to IP_GRE GSO support, GRE can recieve non linear skb which
> results in panic in case of GRE_CSUM.
> Following patch fixes it by using correct csum API.
> 
> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
> ---
> v3: Coding style Fix.

More precisely, this comes from SG (Scatter Gather) support, not GSO.

Bug introduced in commit 6b78f16e4bdde3936b
(gre: add GSO support)

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks !


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 303012a..e81b1ca 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -963,8 +963,12 @@  static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
 			ptr--;
 		}
 		if (tunnel->parms.o_flags&GRE_CSUM) {
+			int offset = skb_transport_offset(skb);
+
 			*ptr = 0;
-			*(__sum16 *)ptr = ip_compute_csum((void *)(iph+1), skb->len - sizeof(struct iphdr));
+			*(__sum16 *)ptr = csum_fold(skb_checksum(skb, offset,
+								 skb->len - offset,
+								 0));
 		}
 	}