aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authornikolay@redhat.com <nikolay@redhat.com>2013-05-17 21:18:28 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-20 02:25:49 -0400
commitea6836dd7ef9cfbed5dce421190009f9eed00b7e (patch)
tree3eb87d6856598772743b4fe8088468c7de09d8bb /drivers/net
parentff0102ee104847023c36357e2b9f133f3f40d211 (diff)
bonding: fix set mode race conditions
Changing the mode without any locking can result in multiple races (e.g. upping a bond, enslaving/releasing). Depending on which race is hit the impact can vary from incosistent bond state to kernel crash. Use RTNL to synchronize the mode setting with the dangerous races. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_sysfs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index ea7a388f4843..77ea237de900 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -316,6 +316,9 @@ static ssize_t bonding_store_mode(struct device *d,
316 int new_value, ret = count; 316 int new_value, ret = count;
317 struct bonding *bond = to_bond(d); 317 struct bonding *bond = to_bond(d);
318 318
319 if (!rtnl_trylock())
320 return restart_syscall();
321
319 if (bond->dev->flags & IFF_UP) { 322 if (bond->dev->flags & IFF_UP) {
320 pr_err("unable to update mode of %s because interface is up.\n", 323 pr_err("unable to update mode of %s because interface is up.\n",
321 bond->dev->name); 324 bond->dev->name);
@@ -352,6 +355,7 @@ static ssize_t bonding_store_mode(struct device *d,
352 bond->dev->name, bond_mode_tbl[new_value].modename, 355 bond->dev->name, bond_mode_tbl[new_value].modename,
353 new_value); 356 new_value);
354out: 357out:
358 rtnl_unlock();
355 return ret; 359 return ret;
356} 360}
357static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, 361static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,