Skip to content

Commit

Permalink
bonding: disallow enslaving a bond to itself
Browse files Browse the repository at this point in the history
Enslaving a bond to itself leads to an endless loop and hangs the kernel.

Signed-off-by: Jiri Bohac <jbohac@suse.cz>
Tested-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
jiribohac authored and davem330 committed Feb 27, 2014
1 parent ee6154e commit 09a89c2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
return -EBUSY;
}

if (bond_dev == slave_dev) {
pr_err("%s: cannot enslave bond to itself.\n", bond_dev->name);
return -EPERM;
}

/* vlan challenged mutual exclusion */
/* no need to lock since we're protected by rtnl_lock */
if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
Expand Down

0 comments on commit 09a89c2

Please sign in to comment.