lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 5 Aug 2013 20:31:11 +0200
From:	Veaceslav Falico <vfalico@...hat.com>
To:	netdev@...r.kernel.org
Cc:	Jay Vosburgh <fubar@...ibm.com>,
	Andy Gospodarek <andy@...yhouse.net>,
	Nikolay Aleksandrov <nikolay@...hat.com>
Subject: Re: [PATCH net-next] bonding: RCUify bond_set_rx_mode()

On Mon, Aug 05, 2013 at 11:26:16AM +0200, Veaceslav Falico wrote:
>Currently, we might easily deadlock with bond_set_rx_mode() and
>bond_hw_addr_swap(). bond_set_rx_mode() is called via dev_set_rx_mode(),
>which already holds the netif_addr_lock_bh(bond), and inside it takes the
>bond->curr_active_slave lock, while bond_hw_addr_swap() is called with
>bond->curr_active_slave lock held and then takes netif_addr_lock_bh(bond),
>which results in deadlock.
>
>CPU0                    CPU1
>----                    ----
>lock(&bonding_netdev_addr_lock_key);
>			lock(&bond->curr_slave_lock);
>			lock(&bonding_netdev_addr_lock_key);
>lock(&bond->curr_slave_lock);
>
>Fix this by using the RCU primites in bond_set_rx_mode(). We're safe wrt
>racing of dev_?c_(un)sync() because we hold
>lock(&bonding_netdev_addr_lock_key), and thus nobody will be able to modify
>these lists before we finish.
>
>CC: Jay Vosburgh <fubar@...ibm.com>
>CC: Andy Gospodarek <andy@...yhouse.net>
>CC: Nikolay Aleksandrov <nikolay@...hat.com>
>Signed-off-by: Veaceslav Falico <vfalico@...hat.com>

Self-NAK, for clarity. Posted a reworked patch - "[net-next] bonding: remove
locking from bond_set_rx_mode()" for the same issue.

>---
> drivers/net/bonding/bond_main.c |   10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 476df7d..fdc01c6 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -3571,24 +3571,22 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
> 	struct bonding *bond = netdev_priv(bond_dev);
> 	struct slave *slave;
>
>-	read_lock(&bond->lock);
>+	rcu_read_lock();
>
> 	if (USES_PRIMARY(bond->params.mode)) {
>-		read_lock(&bond->curr_slave_lock);
>-		slave = bond->curr_active_slave;
>+		slave = rcu_dereference(bond->curr_active_slave);
> 		if (slave) {
> 			dev_uc_sync(slave->dev, bond_dev);
> 			dev_mc_sync(slave->dev, bond_dev);
> 		}
>-		read_unlock(&bond->curr_slave_lock);
> 	} else {
>-		bond_for_each_slave(bond, slave) {
>+		bond_for_each_slave_rcu(bond, slave) {
> 			dev_uc_sync_multiple(slave->dev, bond_dev);
> 			dev_mc_sync_multiple(slave->dev, bond_dev);
> 		}
> 	}
>
>-	read_unlock(&bond->lock);
>+	rcu_read_unlock();
> }
>
> static int bond_neigh_init(struct neighbour *n)
>-- 
>1.7.1
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ