Skip to content

Commit 09a89c2

Browse files
jiribohacdavem330
authored andcommitted
bonding: disallow enslaving a bond to itself
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>
1 parent ee6154e commit 09a89c2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
11971197
return -EBUSY;
11981198
}
11991199

1200+
if (bond_dev == slave_dev) {
1201+
pr_err("%s: cannot enslave bond to itself.\n", bond_dev->name);
1202+
return -EPERM;
1203+
}
1204+
12001205
/* vlan challenged mutual exclusion */
12011206
/* no need to lock since we're protected by rtnl_lock */
12021207
if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {

0 commit comments

Comments
 (0)