From: Andrew Morton <[EMAIL PROTECTED]>
Date: Thu, 17 Jan 2008 15:42:43 -0800

> Applying this:
> 
> --- a/drivers/net/bonding/bond_sysfs.c~bonding-locking-fix
> +++ a/drivers/net/bonding/bond_sysfs.c
> @@ -1111,8 +1111,6 @@ static ssize_t bonding_store_primary(str
>  out:
>       write_unlock_bh(&bond->lock);
>  
> -     rtnl_unlock();
> -
>       return count;
>  }
>  static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, 
> bonding_store_primary);
> 
> 
> is better than doing nothing.

If you look at the change that introduced this:

    commit 6603a6f25e4bca922a7dfbf0bf03072d98850176
    Author: Jay Vosburgh <[EMAIL PROTECTED]>
    Date:   Wed Oct 17 17:37:50 2007 -0700

    bonding: Convert more locks to _bh, acquire rtnl, for new locking
    
        Convert more lock acquisitions to _bh flavor to avoid deadlock
    with workqueue activity and add acquisition of RTNL in appropriate places.
    Affects ALB mode, as well as core bonding functions and sysfs.
    
    Signed-off-by: Andy Gospodarek <[EMAIL PROTECTED]>
    Signed-off-by: Jay Vosburgh <[EMAIL PROTECTED]>
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>

It is clearly the author's intent to surround the execution
of this function (and also bonding_show_active_slave() which
was done correctly) with RTNL semaphore holding.

Therefore the correct fix, which I'll push, is:

commit 991a15cb1cd60a918bd864bb79e7649c30aab275
Author: David S. Miller <[EMAIL PROTECTED]>
Date:   Sun Jan 20 16:55:20 2008 -0800

    [BONDING]: Fix rtnl locking in bonding_store_primary().
    
    Changeset 6603a6f25e4bca922a7dfbf0bf03072d98850176 (Convert more locks
    to _bh, acquire rtnl, for new locking) added a regression.
    
    A rtnl_unlock() was added but a rtnl_lock() was not.
    
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 11b76b3..4845c01 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1075,6 +1075,7 @@ static ssize_t bonding_store_primary(struct device *d,
        struct slave *slave;
        struct bonding *bond = to_bond(d);
 
+       rtnl_lock();
        write_lock_bh(&bond->lock);
        if (!USES_PRIMARY(bond->params.mode)) {
                printk(KERN_INFO DRV_NAME
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to