diff options
author | nikolay@redhat.com <nikolay@redhat.com> | 2013-04-06 00:54:38 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-01 09:41:06 -0700 |
commit | 643094adbef902c4a1f5a544f1f8eb8512e7ff8c (patch) | |
tree | 9e0aba96e458e4ae750c9a84a712812bdaf70560 | |
parent | 74595d06f51d68bbc25c5864d15566ea5049a33a (diff) | |
download | linux-stable-643094adbef902c4a1f5a544f1f8eb8512e7ff8c.tar.gz linux-stable-643094adbef902c4a1f5a544f1f8eb8512e7ff8c.tar.bz2 linux-stable-643094adbef902c4a1f5a544f1f8eb8512e7ff8c.zip |
bonding: fix bonding_masters race condition in bond unloading
[ Upstream commit 69b0216ac255f523556fa3d4ff030d857eaaa37f ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/net/bonding/bond_main.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index d9f646f3d9b7..e2c5e0fb88c7 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4864,9 +4864,18 @@ static int __net_init bond_net_init(struct net *net) static void __net_exit bond_net_exit(struct net *net) { struct bond_net *bn = net_generic(net, bond_net_id); + struct bonding *bond, *tmp_bond; + LIST_HEAD(list); bond_destroy_sysfs(bn); bond_destroy_proc_dir(bn); + + /* Kill off any bonds created after unregistering bond rtnl ops */ + rtnl_lock(); + list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list) + unregister_netdevice_queue(bond->dev, &list); + unregister_netdevice_many(&list); + rtnl_unlock(); } static struct pernet_operations bond_net_ops = { |