Skip to content

Commit

Permalink
ipip: potential race in ip_tunnel_init_net()
Browse files Browse the repository at this point in the history
Eric Dumazet says that my previous fix for an ERR_PTR dereference
(ea857f2 '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>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Aug 25, 2013
1 parent b8e2fde commit b4de77a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions net/ipv4/ip_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,14 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,

rtnl_lock();
itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms);
rtnl_unlock();

if (IS_ERR(itn->fb_tunnel_dev))
return PTR_ERR(itn->fb_tunnel_dev);
/* FB netdevice is special: we have one, and only one per netns.
* Allowing to move it to another netns is clearly unsafe.
*/
itn->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL;
if (!IS_ERR(itn->fb_tunnel_dev))
itn->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL;
rtnl_unlock();

return 0;
return PTR_RET(itn->fb_tunnel_dev);
}
EXPORT_SYMBOL_GPL(ip_tunnel_init_net);

Expand Down

0 comments on commit b4de77a

Please sign in to comment.