From: ebiederm@xmission.com (Eric W. Biederman)
To: Amerigo Wang <amwang@redhat.com>
Cc: linux-kernel@vger.kernel.org, Jiri Pirko <jpirko@redhat.com>,
Stephen Hemminger <shemminger@vyatta.com>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
bonding-devel@lists.sourceforge.net,
Jay Vosburgh <fubar@us.ibm.com>
Subject: Re: [Patch] bonding: fix potential deadlock in bond_uninit()
Date: Wed, 31 Mar 2010 04:28:33 -0700 [thread overview]
Message-ID: <m1d3ykzq5a.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20100331105559.5607.38643.sendpatchset@localhost.localdomain> (Amerigo Wang's message of "Wed\, 31 Mar 2010 06\:52\:13 -0400")
Amerigo Wang <amwang@redhat.com> writes:
> bond_uninit() is invoked with rtnl_lock held, when it does destroy_workqueue()
> which will potentially flush all works in this workqueue, if we hold rtnl_lock
> again in the work function, it will deadlock.
>
> So unlock rtnl_lock before calling destroy_workqueue().
Ouch. That seems rather rude to our caller, and likely very
dangerous.
Is this a deadlock you actually hit, or is this something lockdep
warned about?
My gut feel says we need to move the destroy_workqueue into
the network device destructor.
Eric
> Signed-off-by: WANG Cong <amwang@redhat.com>
> Cc: Jay Vosburgh <fubar@us.ibm.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Stephen Hemminger <shemminger@vyatta.com>
> Cc: Jiri Pirko <jpirko@redhat.com>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
>
> ---
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 5b92fbf..b781728 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4542,8 +4542,11 @@ static void bond_uninit(struct net_device *bond_dev)
>
> bond_remove_proc_entry(bond);
>
> - if (bond->wq)
> + if (bond->wq) {
> + rtnl_unlock();
> destroy_workqueue(bond->wq);
> + rtnl_lock();
> + }
>
> netif_addr_lock_bh(bond_dev);
> bond_mc_list_destroy(bond);
next prev parent reply other threads:[~2010-03-31 11:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-31 10:52 [Patch] bonding: fix potential deadlock in bond_uninit() Amerigo Wang
2010-03-31 11:28 ` Eric W. Biederman [this message]
2010-03-31 23:02 ` Stephen Hemminger
2010-04-01 2:49 ` Cong Wang
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=m1d3ykzq5a.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=amwang@redhat.com \
--cc=bonding-devel@lists.sourceforge.net \
--cc=davem@davemloft.net \
--cc=fubar@us.ibm.com \
--cc=jpirko@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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