Skip to content

Commit

Permalink
bonding: fix race condition in bonding_store_slaves_active
Browse files Browse the repository at this point in the history
Race between bonding_store_slaves_active() and slave manipulation
 functions. The bond_for_each_slave use in bonding_store_slaves_active()
 is not protected by any synchronization mechanism.
 NULL pointer dereference is easy to reach.
 Fixed by acquiring the bond->lock for the slave walk.

 v2: Make description text < 75 columns

Signed-off-by: Nikolay Aleksandrov <[email protected]>
Signed-off-by: Jay Vosburgh <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
[email protected] authored and davem330 committed Nov 29, 2012
1 parent 90fb625 commit e196c0e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/bonding/bond_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
goto out;
}

read_lock(&bond->lock);
bond_for_each_slave(bond, slave, i) {
if (!bond_is_active_slave(slave)) {
if (new_value)
Expand All @@ -1576,6 +1577,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
slave->inactive = 1;
}
}
read_unlock(&bond->lock);
out:
return ret;
}
Expand Down

0 comments on commit e196c0e

Please sign in to comment.