aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authornikolay@redhat.com <nikolay@redhat.com>2013-04-05 20:54:38 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-08 16:45:09 -0400
commit69b0216ac255f523556fa3d4ff030d857eaaa37f (patch)
tree45138d6eae10f05815b353556fa62d57ceea35db /drivers/net/bonding/bond_main.c
parentffcdedb667b6db8ee31c7efa76a3ec59d9c3b0fc (diff)
bonding: fix bonding_masters race condition in bond unloading
While the bonding module is unloading, it is considered that after rtnl_link_unregister all bond devices are destroyed but since no synchronization mechanism exists, a new bond device can be created via bonding_masters before unregister_pernet_subsys which would lead to multiple problems (e.g. NULL pointer dereference, wrong RIP, list corruption). This patch fixes the issue by removing any bond devices left in the netns after bonding_masters is removed from sysfs. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Acked-by: Veaceslav Falico <vfalico@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a51241b2e621..07401a3e256b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4846,9 +4846,18 @@ static int __net_init bond_net_init(struct net *net)
4846static void __net_exit bond_net_exit(struct net *net) 4846static void __net_exit bond_net_exit(struct net *net)
4847{ 4847{
4848 struct bond_net *bn = net_generic(net, bond_net_id); 4848 struct bond_net *bn = net_generic(net, bond_net_id);
4849 struct bonding *bond, *tmp_bond;
4850 LIST_HEAD(list);
4849 4851
4850 bond_destroy_sysfs(bn); 4852 bond_destroy_sysfs(bn);
4851 bond_destroy_proc_dir(bn); 4853 bond_destroy_proc_dir(bn);
4854
4855 /* Kill off any bonds created after unregistering bond rtnl ops */
4856 rtnl_lock();
4857 list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list)
4858 unregister_netdevice_queue(bond->dev, &list);
4859 unregister_netdevice_many(&list);
4860 rtnl_unlock();
4852} 4861}
4853 4862
4854static struct pernet_operations bond_net_ops = { 4863static struct pernet_operations bond_net_ops = {