Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Duyck, Alexander H <alexander.h.duyck@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH] [PATCH v2] igb: close/suspend race in netif_device_detach
Date: Tue, 15 Nov 2016 17:55:54 +0000	[thread overview]
Message-ID: <1479232551.681.96.camel@intel.com> (raw)
In-Reply-To: <1479228866-15506-1-git-send-email-todd.fujinaka@intel.com>

On Tue, 2016-11-15 at 08:54 -0800, Todd Fujinaka wrote:
> Similar to ixgbe, when an interface is part of a namespace it is
> possible that igb_close() may be called while __igb_shutdown() is
> running which ends up in a double free WARN and/or a BUG in
> free_msi_irqs().
> 
> Extend the rtnl_lock() to protect the call to netif_device_detach() and
> igb_clear_interrupt_scheme() in __igb_shutdown() and check for
> netif_device_present() to avoid calling igb_clear_interrupt_scheme() a
> second time in igb_close().
> 
> Also extend the rtnl lock in igb_resume() to netif_device_attach().
> 
> Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com>

Looks good.

Acked-by: Alexander Duyck <alexander.h.duyck@intel.com>

> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 4feca69..8b1b4dd 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -3275,7 +3275,9 @@ static int __igb_close(struct net_device *netdev, bool suspending)
>  
>  int igb_close(struct net_device *netdev)
>  {
> -	return __igb_close(netdev, false);
> +	if (netif_device_present(netdev))
> +		return __igb_close(netdev, false);
> +	return 0;
>  }
>  
>  /**
> @@ -7537,6 +7539,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
>  	int retval = 0;
>  #endif
>  
> +	rtnl_lock();
>  	netif_device_detach(netdev);
>  
>  	if (netif_running(netdev))
> @@ -7545,6 +7548,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
>  	igb_ptp_suspend(adapter);
>  
>  	igb_clear_interrupt_scheme(adapter);
> +	rtnl_unlock();
>  
>  #ifdef CONFIG_PM
>  	retval = pci_save_state(pdev);
> @@ -7663,16 +7667,15 @@ static int igb_resume(struct device *dev)
>  
>  	wr32(E1000_WUS, ~0);
>  
> -	if (netdev->flags & IFF_UP) {
> -		rtnl_lock();
> +	rtnl_lock();
> +	if (!err && netif_running(netdev))
>  		err = __igb_open(netdev, true);
> -		rtnl_unlock();
> -		if (err)
> -			return err;
> -	}
>  
> -	netif_device_attach(netdev);
> -	return 0;
> +	if (!err)
> +		netif_device_attach(netdev);
> +	rtnl_unlock();
> +
> +	return err;
>  }
>  
>  static int igb_runtime_idle(struct device *dev)

  reply	other threads:[~2016-11-15 17:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 16:54 [Intel-wired-lan] [PATCH] [PATCH v2] igb: close/suspend race in netif_device_detach Todd Fujinaka
2016-11-15 17:55 ` Duyck, Alexander H [this message]
2016-11-30 20:25 ` Brown, Aaron F
2016-12-06 22:13   ` Brown, Aaron F
2016-12-06 22:51     ` Brown, Aaron F

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=1479232551.681.96.camel@intel.com \
    --to=alexander.h.duyck@intel.com \
    --cc=intel-wired-lan@osuosl.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