Skip to content

Commit

Permalink
net: FIX bonding sysfs rtnl_lock deadlock
Browse files Browse the repository at this point in the history
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: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed May 19, 2009
1 parent 2657440 commit 496a60c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/bonding/bond_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

rtnl_lock();
if (!rtnl_trylock())
return restart_syscall();
down_write(&(bonding_rwsem));

sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
Expand Down Expand Up @@ -1171,7 +1172,8 @@ static ssize_t bonding_store_primary(struct device *d,
struct slave *slave;
struct bonding *bond = to_bond(d);

rtnl_lock();
if (!rtnl_trylock())
return restart_syscall();
read_lock(&bond->lock);
write_lock_bh(&bond->curr_slave_lock);

Expand Down Expand Up @@ -1288,7 +1290,8 @@ static ssize_t bonding_store_active_slave(struct device *d,
struct slave *new_active = NULL;
struct bonding *bond = to_bond(d);

rtnl_lock();
if (!rtnl_trylock())
return restart_syscall();
read_lock(&bond->lock);
write_lock_bh(&bond->curr_slave_lock);

Expand Down

0 comments on commit 496a60c

Please sign in to comment.