Skip to content

Commit

Permalink
net: ipmr, ip6mr: fix vif/tunnel failure race condition
Browse files Browse the repository at this point in the history
Since (at least) commit b17a7c1 ("[NET]: Do sysfs registration as
part of register_netdevice."), netdev_run_todo() deals only with
unregistration, so we don't need to do the rtnl_unlock/lock cycle to
finish registration when failing pimreg or dvmrp device creation. In
fact that opens a race condition where someone can delete the device
while rtnl is unlocked because it's fully registered. The problem gets
worse when netlink support is introduced as there are more points of entry
that can cause it and it also makes reusing that code correctly impossible.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Reviewed-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nikolay Aleksandrov authored and David S. Miller committed Nov 24, 2015
1 parent 33c40e2 commit fbdd29b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
8 changes: 0 additions & 8 deletions net/ipv4/ipmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,6 @@ struct net_device *ipmr_new_tunnel(struct net *net, struct vifctl *v)
return dev;

failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();

unregister_netdevice(dev);
return NULL;
}
Expand Down Expand Up @@ -540,10 +536,6 @@ static struct net_device *ipmr_reg_vif(struct net *net, struct mr_table *mrt)
return dev;

failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();

unregister_netdevice(dev);
return NULL;
}
Expand Down
4 changes: 0 additions & 4 deletions net/ipv6/ip6mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,6 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr6_table *mrt)
return dev;

failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();

unregister_netdevice(dev);
return NULL;
}
Expand Down

0 comments on commit fbdd29b

Please sign in to comment.