public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
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 V2] bonding: fix potential deadlock in bond_uninit()
Date: Wed, 31 Mar 2010 23:12:22 -0700	[thread overview]
Message-ID: <m1r5mzsnuh.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20100401061014.4815.7341.sendpatchset@localhost.localdomain> (Amerigo Wang's message of "Thu\, 1 Apr 2010 02\:06\:28 -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 move destroy_workqueue() to destructor where rtnl_lock is not held any more,
> suggested by Eric.

The error handling on creating a bond device needs to be updated as well.

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..9f0aaa2 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -4450,6 +4450,14 @@ static const struct net_device_ops bond_netdev_ops = {
>  	.ndo_vlan_rx_kill_vid	= bond_vlan_rx_kill_vid,
>  };
>  
> +static void bond_destructor(struct net_device *bond_dev)
> +{
> +	struct bonding *bond = netdev_priv(bond_dev);
> +	if (bond->wq)
> +		destroy_workqueue(bond->wq);
> +	free_netdev(bond_dev);
> +}
> +
>  static void bond_setup(struct net_device *bond_dev)
>  {
>  	struct bonding *bond = netdev_priv(bond_dev);
> @@ -4470,7 +4478,7 @@ static void bond_setup(struct net_device *bond_dev)
>  	bond_dev->ethtool_ops = &bond_ethtool_ops;
>  	bond_set_mode_ops(bond, bond->params.mode);
>  
> -	bond_dev->destructor = free_netdev;
> +	bond_dev->destructor = bond_destructor;
>  
>  	/* Initialize the device options */
>  	bond_dev->tx_queue_len = 0;
> @@ -4542,9 +4550,6 @@ static void bond_uninit(struct net_device *bond_dev)
>  
>  	bond_remove_proc_entry(bond);
>  
> -	if (bond->wq)
> -		destroy_workqueue(bond->wq);
> -
>  	netif_addr_lock_bh(bond_dev);
>  	bond_mc_list_destroy(bond);
>  	netif_addr_unlock_bh(bond_dev);

  reply	other threads:[~2010-04-01  6:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01  6:06 [Patch V2] bonding: fix potential deadlock in bond_uninit() Amerigo Wang
2010-04-01  6:12 ` Eric W. Biederman [this message]
2010-04-01  6:54   ` Cong Wang
2010-04-01  7:30   ` [Patch V3] " Cong Wang
2010-04-02  0:26     ` David Miller

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=m1r5mzsnuh.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission$(echo .)com \
    --cc=amwang@redhat$(echo .)com \
    --cc=bonding-devel@lists$(echo .)sourceforge.net \
    --cc=davem@davemloft$(echo .)net \
    --cc=fubar@us$(echo .)ibm.com \
    --cc=jpirko@redhat$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=shemminger@vyatta$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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