Commit 496a60cd authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

net: FIX bonding sysfs rtnl_lock deadlock

Sysfs files for a network device can not unconditionally take the
rtnl_lock as the bonding sysfs files do.  If someone accesses those
sysfs files while the network device is being unregistered with the
rtnl_lock held we will deadlock.

So use trylock and restart_syscall to avoid this problem.
Signed-off-by: default avatarEric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 26574401
...@@ -251,7 +251,8 @@ static ssize_t bonding_store_slaves(struct device *d, ...@@ -251,7 +251,8 @@ static ssize_t bonding_store_slaves(struct device *d,
/* Note: We can't hold bond->lock here, as bond_create grabs it. */ /* Note: We can't hold bond->lock here, as bond_create grabs it. */
rtnl_lock(); if (!rtnl_trylock())
return restart_syscall();
down_write(&(bonding_rwsem)); down_write(&(bonding_rwsem));
sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
...@@ -1171,7 +1172,8 @@ static ssize_t bonding_store_primary(struct device *d, ...@@ -1171,7 +1172,8 @@ static ssize_t bonding_store_primary(struct device *d,
struct slave *slave; struct slave *slave;
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
rtnl_lock(); if (!rtnl_trylock())
return restart_syscall();
read_lock(&bond->lock); read_lock(&bond->lock);
write_lock_bh(&bond->curr_slave_lock); write_lock_bh(&bond->curr_slave_lock);
...@@ -1288,7 +1290,8 @@ static ssize_t bonding_store_active_slave(struct device *d, ...@@ -1288,7 +1290,8 @@ static ssize_t bonding_store_active_slave(struct device *d,
struct slave *new_active = NULL; struct slave *new_active = NULL;
struct bonding *bond = to_bond(d); struct bonding *bond = to_bond(d);
rtnl_lock(); if (!rtnl_trylock())
return restart_syscall();
read_lock(&bond->lock); read_lock(&bond->lock);
write_lock_bh(&bond->curr_slave_lock); write_lock_bh(&bond->curr_slave_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment