bonding: fix race condition in bonding_store_slaves_active
Subsystems (3)
PATCH 1/1 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.
--- drivers/net/bonding/bond_sysfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/bonding/bond_sysfs.c +2 -0
@@ -1582,6 +1582,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)
@@ -1590,6 +1591,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, slave->inactive =1 ; } } +read_unlock (&bond->lock); out:return ret; }
Signature · 1 line
1.7.11.7
David Miller
maintainerSome bonding developer reviews would be appreciated.
PATCH v2 1/1 bonding: fix race condition in bonding_store_slaves_active
In reply to Nikolay Aleksandrov 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
--- drivers/net/bonding/bond_sysfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/bonding/bond_sysfs.c +2 -0
@@ -1582,6 +1582,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)
@@ -1590,6 +1591,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, slave->inactive =1 ; } } +read_unlock (&bond->lock); out:return ret; }
Signature · 1 line
1.7.11.7
Quoted 9 lines · Nikolay Aleksandrov
Race between
bonding_store_slaves_active()and slave manipulation functions. Thebond_for_each_slaveuse inbonding_store_slaves_active()is not protected by any synchronization mechanism.
NULL pointer dereference is easy to reach.
Fixed by acquiring thebond->lockfor the slave walk.v2: Make description text < 75 columns
Signed-off-by Nikolay Aleksandrov <[email protected]>
Quoted 27 lines
---
drivers/net/bonding/bond_sysfs.c| 2 ++1 file changed, 2 insertions(+)drivers/net/bonding/bond_sysfs.c +2
-0@@ -1582,6 +1582,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)@@ -1590,6 +1591,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, slave->inactive =1 ; } } +read_unlock (&bond->lock);out:
return ret; }Signature · 1 line
1.7.11.7
From: Jay Vosburgh <[email protected]>
Date: Thu, 29 Nov 2012 09:37:56 -0800
Quoted 8 lines
Quoted 6 lines · Nikolay Aleksandrov
Race between
bonding_store_slaves_active()and slave manipulation functions. Thebond_for_each_slaveuse inbonding_store_slaves_active()is not protected by any synchronization mechanism.
NULL pointer dereference is easy to reach.
Fixed by acquiring thebond->lockfor the slave walk.
Quoted 5 lines
Quoted 3 lines
v2: Make description text < 75 columns
Signed-off-by Nikolay Aleksandrov <[email protected]>Signed-off-by Jay Vosburgh <[email protected]>
Applied.