netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv4 tunnels: fix an oops when using ipip/sit with IPsec
@ 2013-08-28  9:54 Nicolas Dichtel
  2013-08-30 21:14 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Dichtel @ 2013-08-28  9:54 UTC (permalink / raw)
  To: davem; +Cc: netdev, pshelar, hongjun.li, Nicolas Dichtel

From: Li Hongjun <hongjun.li@6wind.com>

Since commit 3d7b46cd20e3 (ip_tunnel: push generic protocol handling to
ip_tunnel module.), an Oops is triggered when an xfrm policy is configured on
an IPv4 over IPv4 tunnel.

xfrm4_policy_check() calls __xfrm_policy_check2(), which uses skb_dst(skb). But
this field is NULL because iptunnel_pull_header() calls skb_dst_drop(skb).

Signed-off-by: Li Hongjun <hongjun.li@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/ipv4/ipip.c | 5 ++---
 net/ipv6/sit.c  | 6 ++----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 51fc2a1dcdd3..b3ac3c3f6219 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -190,15 +190,14 @@ static int ipip_rcv(struct sk_buff *skb)
 	struct ip_tunnel *tunnel;
 	const struct iphdr *iph;
 
-	if (iptunnel_pull_header(skb, 0, tpi.proto))
-		goto drop;
-
 	iph = ip_hdr(skb);
 	tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
 			iph->saddr, iph->daddr, 0);
 	if (tunnel) {
 		if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
 			goto drop;
+		if (iptunnel_pull_header(skb, 0, tpi.proto))
+			goto drop;
 		return ip_tunnel_rcv(tunnel, skb, &tpi, log_ecn_error);
 	}
 
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index a3437a4cd07e..1e6a81d0c897 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -645,11 +645,7 @@ static int ipip_rcv(struct sk_buff *skb)
 	const struct iphdr *iph;
 	struct ip_tunnel *tunnel;
 
-	if (iptunnel_pull_header(skb, 0, tpi.proto))
-		goto drop;
-
 	iph = ip_hdr(skb);
-
 	tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
 				     iph->saddr, iph->daddr);
 	if (tunnel != NULL) {
@@ -659,6 +655,8 @@ static int ipip_rcv(struct sk_buff *skb)
 
 		if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
 			goto drop;
+		if (iptunnel_pull_header(skb, 0, tpi.proto))
+			goto drop;
 		return ip_tunnel_rcv(tunnel, skb, &tpi, log_ecn_error);
 	}
 
-- 
1.8.2.1

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

* Re: [PATCH] ipv4 tunnels: fix an oops when using ipip/sit with IPsec
  2013-08-28  9:54 [PATCH] ipv4 tunnels: fix an oops when using ipip/sit with IPsec Nicolas Dichtel
@ 2013-08-30 21:14 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-08-30 21:14 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: netdev, pshelar, hongjun.li

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Wed, 28 Aug 2013 11:54:50 +0200

> From: Li Hongjun <hongjun.li@6wind.com>
> 
> Since commit 3d7b46cd20e3 (ip_tunnel: push generic protocol handling to
> ip_tunnel module.), an Oops is triggered when an xfrm policy is configured on
> an IPv4 over IPv4 tunnel.
> 
> xfrm4_policy_check() calls __xfrm_policy_check2(), which uses skb_dst(skb). But
> this field is NULL because iptunnel_pull_header() calls skb_dst_drop(skb).
> 
> Signed-off-by: Li Hongjun <hongjun.li@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied, thanks everyone.

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

end of thread, other threads:[~2013-08-30 21:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-28  9:54 [PATCH] ipv4 tunnels: fix an oops when using ipip/sit with IPsec Nicolas Dichtel
2013-08-30 21:14 ` 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).