Skip to content

Commit e196c0e

Browse files
nikolay@redhat.comdavem330
authored andcommitted
bonding: fix race condition in bonding_store_slaves_active
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 <nikolay@redhat.com> Signed-off-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 90fb625 commit e196c0e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/bonding/bond_sysfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
15681568
goto out;
15691569
}
15701570

1571+
read_lock(&bond->lock);
15711572
bond_for_each_slave(bond, slave, i) {
15721573
if (!bond_is_active_slave(slave)) {
15731574
if (new_value)
@@ -1576,6 +1577,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
15761577
slave->inactive = 1;
15771578
}
15781579
}
1580+
read_unlock(&bond->lock);
15791581
out:
15801582
return ret;
15811583
}

0 commit comments

Comments
 (0)