ixgbe: handle close/suspend race with netif_device_detach/present
Subsystems (2)
PATCH v3 1/1 ixgbe: handle close/suspend race with netif_device_detach/present
When an interface is part of a namespace it is possible that ixgbe_close() may be called while __ixgbe_shutdown() is running which ends up in a double free WARN and/or a BUG in free_msi_irqs().
To handle this situation we extend the rtnl_lock() to protect the call to netif_device_detach() and ixgbe_clear_interrupt_scheme() in __ixgbe_shutdown() and check for netif_device_present() to avoid clearing the interrupts second time in ixgbe_close();
Also extend the rtnl lock in ixgbe_resume() to netif_device_attach().
v2 - add rtnl locks and a check in ixgbe_remove()
v3 - remove the check in ixgbe_remove(), I will submit a separate patch to address the case of failed PCIe error recovery
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +8 -9
@@ -6200,7 +6200,8 @@ int ixgbe_close(struct net_device *netdev)ixgbe_ptp_stop (adapter); -ixgbe_close_suspend (adapter); +if (netif_device_present (netdev)) +ixgbe_close_suspend (adapter);ixgbe_fdir_filter_exit (adapter);
@@ -6245,14 +6246,12 @@ static int ixgbe_resume(struct pci_dev *pdev)if (!err &&netif_running (netdev)) err =ixgbe_open (netdev); -rtnl_unlock (); -if (err) -return err; - -netif_device_attach (netdev); +if (!err) +netif_device_attach (netdev); +rtnl_unlock (); - return 0; + return err; }#endif /* CONFIG_PM */
@@ -6267,14 +6266,14 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)int retval =0 ;#endif +rtnl_lock ();netif_device_detach (netdev); -rtnl_lock ();if (netif_running (netdev))ixgbe_close_suspend (adapter); -rtnl_unlock ();ixgbe_clear_interrupt_scheme (adapter); +rtnl_unlock ();#ifdef CONFIG_PM retval =pci_save_state (pdev);
Bowers
PATCH v3 1/1 ixgbe: handle close/suspend race with netif_device_detach/present
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Emil Tantilov
Sent: Friday, November 11, 2016 10:08 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH v3] ixgbe: handle close/suspend race with netif_device_detach/presentWhen an interface is part of a namespace it is possible that
ixgbe_close()may be called while__ixgbe_shutdown()is running which ends up in a double free WARN and/or a BUG infree_msi_irqs().To handle this situation we extend the
rtnl_lock()to protect the call tonetif_device_detach()andixgbe_clear_interrupt_scheme()in__ixgbe_shutdown()and check fornetif_device_present()to avoid clearing the interrupts second time inixgbe_close();Also extend the rtnl lock in
ixgbe_resume()tonetif_device_attach().v2 - add rtnl locks and a check in
ixgbe_remove()
Quoted 7 lines
v3 - remove the check in
ixgbe_remove(), I will submit a separate patch to address the case of failed PCIe error recoverySigned-off-by Emil Tantilov <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)