Skip to content

Commit

Permalink
ipv4 tunnels: fix an oops when using ipip/sit with IPsec
Browse files Browse the repository at this point in the history
Since commit 3d7b46c (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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Li Hongjun authored and David S. Miller committed Aug 30, 2013
1 parent 2c8d851 commit 737e828
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions net/ipv4/ipip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 2 additions & 4 deletions net/ipv6/sit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

Expand Down

0 comments on commit 737e828

Please sign in to comment.