netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: akpm@linux-foundation.org
Cc: fubar@us.ibm.com, olel@ans.pl, jeff@garzik.org,
	shemminger@linux-foundation.org, netdev@vger.kernel.org
Subject: Re: [patch for 2.6.24? 1/1] bonding: locking fix
Date: Sun, 20 Jan 2008 16:57:16 -0800 (PST)	[thread overview]
Message-ID: <20080120.165716.172421176.davem@davemloft.net> (raw)
In-Reply-To: <20080117154243.9ee4265c.akpm@linux-foundation.org>

From: Andrew Morton <akpm@linux-foundation.org>
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 <fubar@us.ibm.com>
    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 <andy@greyhouse.net>
    Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
    Signed-off-by: Jeff Garzik <jeff@garzik.org>

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 <davem@davemloft.net>
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 <davem@davemloft.net>

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

      parent reply	other threads:[~2008-01-21  0:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200801140904.m0E94vJd020425@imap1.linux-foundation.org>
     [not found] ` <Pine.LNX.4.64.0801142313350.26034@bizon.gios.gov.pl>
2008-01-14 22:47   ` [patch for 2.6.24? 1/1] bonding: locking fix Andrew Morton
2008-01-14 23:01     ` Jay Vosburgh
2008-01-17 23:42       ` Andrew Morton
2008-01-18  0:26         ` Jay Vosburgh
2008-01-18  0:58           ` Krzysztof Oledzki
2008-01-18  1:45             ` Jay Vosburgh
2008-01-18  8:34               ` Krzysztof Oledzki
2008-01-18 17:32                 ` Jay Vosburgh
2008-01-21  0:57         ` David Miller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080120.165716.172421176.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=akpm@linux-foundation.org \
    --cc=fubar@us.ibm.com \
    --cc=jeff@garzik.org \
    --cc=netdev@vger.kernel.org \
    --cc=olel@ans.pl \
    --cc=shemminger@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).