netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bonding: fix race condition in bonding_store_slaves_active
@ 2012-11-24 12:19 Nikolay Aleksandrov
  2012-11-28 16:21 ` David Miller
  2012-11-29 11:37 ` [PATCH v2] " Nikolay Aleksandrov
  0 siblings, 2 replies; 5+ messages in thread
From: Nikolay Aleksandrov @ 2012-11-24 12:19 UTC (permalink / raw)
  To: netdev; +Cc: andy, fubar, davem

 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.

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
---
 drivers/net/bonding/bond_sysfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index ef8d2a0..ba4f95b 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -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;
 }
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-29 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-24 12:19 [PATCH] bonding: fix race condition in bonding_store_slaves_active Nikolay Aleksandrov
2012-11-28 16:21 ` David Miller
2012-11-29 11:37 ` [PATCH v2] " Nikolay Aleksandrov
2012-11-29 17:37   ` Jay Vosburgh
2012-11-29 18:14     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).