Skip to content

Commit

Permalink
ipv4: ip_tunnel: use net namespace from rtable not socket
Browse files Browse the repository at this point in the history
The socket parameter might legally be NULL, thus sock_net is sometimes
causing a NULL pointer dereference. Using net_device pointer in dst_entry
is more reliable.

Fixes: b6a7719 ("ipv4: hash net ptr into fragmentation bucket selection")
Reported-by: Rick Jones <rick.jones2@hp.com>
Cc: Rick Jones <rick.jones2@hp.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hannes Frederic Sowa authored and David S. Miller committed Apr 8, 2015
1 parent 8bc0034 commit 926a882
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/ipv4/ip_tunnel_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ int iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
iph->daddr = dst;
iph->saddr = src;
iph->ttl = ttl;
__ip_select_ident(sock_net(sk), iph, skb_shinfo(skb)->gso_segs ?: 1);
__ip_select_ident(dev_net(rt->dst.dev), iph,
skb_shinfo(skb)->gso_segs ?: 1);

err = ip_local_out_sk(sk, skb);
if (unlikely(net_xmit_eval(err)))
Expand Down

0 comments on commit 926a882

Please sign in to comment.