aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-08-23 04:15:37 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-25 18:39:59 -0400
commitb4de77ade3fc56e41b978b68d78a351dab28b74e (patch)
tree92e18e67c92a67d7ae83160a80c66b1767547840
parentb8e2fde466f7902fed4ad10bb60c1377b27cbfb7 (diff)
ipip: potential race in ip_tunnel_init_net()
Eric Dumazet says that my previous fix for an ERR_PTR dereference (ea857f28ab 'ipip: dereferencing an ERR_PTR in ip_tunnel_init_net()') could be racy and suggests the following fix instead. Reported-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/ip_tunnel.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 24549b4aeae2..830de3f4e293 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -854,16 +854,14 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
854 854
855 rtnl_lock(); 855 rtnl_lock();
856 itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms); 856 itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms);
857 rtnl_unlock();
858
859 if (IS_ERR(itn->fb_tunnel_dev))
860 return PTR_ERR(itn->fb_tunnel_dev);
861 /* FB netdevice is special: we have one, and only one per netns. 857 /* FB netdevice is special: we have one, and only one per netns.
862 * Allowing to move it to another netns is clearly unsafe. 858 * Allowing to move it to another netns is clearly unsafe.
863 */ 859 */
864 itn->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL; 860 if (!IS_ERR(itn->fb_tunnel_dev))
861 itn->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL;
862 rtnl_unlock();
865 863
866 return 0; 864 return PTR_RET(itn->fb_tunnel_dev);
867} 865}
868EXPORT_SYMBOL_GPL(ip_tunnel_init_net); 866EXPORT_SYMBOL_GPL(ip_tunnel_init_net);
869 867