diff mbox series

[iwl-net] idpf: fix possible race on remove during a reset

Message ID 20260811171751.22165-1-emil.s.tantilov@intel.com
State Changes Requested
Delegated to: Anthony Nguyen
Headers show
Series [iwl-net] idpf: fix possible race on remove during a reset | expand

Commit Message

Tantilov, Emil S Aug. 11, 2026, 5:17 p.m. UTC
Reset and remove can race, leaving NAPI registered and enabled:

modprobe idpf& sleep 1; ip link set eth0 up& rmmod idpf

[145561.805104] WARNING: net/core/dev.c:7699 at __netif_napi_del_locked+0x11a/0x130, CPU#30: rmmod/22393
...
[145561.810238] RIP: 0010:__netif_napi_del_locked+0x11a/0x130
...
[145561.817678] Call Trace:
[145561.818125]  <TASK>
[145561.818653]  free_netdev+0x110/0x2a0
[145561.819109]  idpf_vport_dealloc+0x452/0x460 [idpf]
[145561.819668]  ? enable_work+0x9f/0x100
[145561.820133]  idpf_deinit_task+0x51/0x70 [idpf]
[145561.820694]  idpf_vc_core_deinit+0x32/0x170 [idpf]
[145561.821193]  idpf_remove+0x40/0x200 [idpf]
[145561.821667]  pci_device_remove+0x40/0xa0
[145561.822132]  device_release_driver_internal+0x1a9/0x210
[145561.822691]  driver_detach+0x4b/0x90
[145561.823161]  bus_remove_driver+0x70/0x100
[145561.823721]  pci_unregister_driver+0x2e/0xb0
[145561.824207]  __do_sys_delete_module.constprop.0+0x190/0x2e0
[145561.824715]  ? kmem_cache_free+0x312/0x550
[145561.825213]  do_syscall_64+0xc8/0x6b0
[145561.825709]  ? clear_bhb_loop+0x30/0x80
[145561.826216]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
[145561.826602] RIP: 0033:0x7fe628130beb

Make sure to call idpf_vport_stop() in idpf_stop(), irrespective of the
IDPF_REMOVE_IN_PROG state, to allow a reset racing with remove to tear
down NAPI in idpf_detach_and_close(), which runs under RTNL lock.

Fixes: 2e281e1155fc ("idpf: detach and close netdevs while handling a reset")
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Reviewed-by: Joshua Hay <joshua.a.hay@intel.com>
---
 drivers/net/ethernet/intel/idpf/idpf_lib.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Simon Horman Aug. 13, 2026, 1:41 p.m. UTC | #1
On Tue, Aug 11, 2026 at 10:17:51AM -0700, Emil Tantilov wrote:
> Reset and remove can race, leaving NAPI registered and enabled:
> 
> modprobe idpf& sleep 1; ip link set eth0 up& rmmod idpf
> 
> [145561.805104] WARNING: net/core/dev.c:7699 at __netif_napi_del_locked+0x11a/0x130, CPU#30: rmmod/22393
> ...
> [145561.810238] RIP: 0010:__netif_napi_del_locked+0x11a/0x130
> ...
> [145561.817678] Call Trace:
> [145561.818125]  <TASK>
> [145561.818653]  free_netdev+0x110/0x2a0
> [145561.819109]  idpf_vport_dealloc+0x452/0x460 [idpf]
> [145561.819668]  ? enable_work+0x9f/0x100
> [145561.820133]  idpf_deinit_task+0x51/0x70 [idpf]
> [145561.820694]  idpf_vc_core_deinit+0x32/0x170 [idpf]
> [145561.821193]  idpf_remove+0x40/0x200 [idpf]
> [145561.821667]  pci_device_remove+0x40/0xa0
> [145561.822132]  device_release_driver_internal+0x1a9/0x210
> [145561.822691]  driver_detach+0x4b/0x90
> [145561.823161]  bus_remove_driver+0x70/0x100
> [145561.823721]  pci_unregister_driver+0x2e/0xb0
> [145561.824207]  __do_sys_delete_module.constprop.0+0x190/0x2e0
> [145561.824715]  ? kmem_cache_free+0x312/0x550
> [145561.825213]  do_syscall_64+0xc8/0x6b0
> [145561.825709]  ? clear_bhb_loop+0x30/0x80
> [145561.826216]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
> [145561.826602] RIP: 0033:0x7fe628130beb
> 
> Make sure to call idpf_vport_stop() in idpf_stop(), irrespective of the
> IDPF_REMOVE_IN_PROG state, to allow a reset racing with remove to tear
> down NAPI in idpf_detach_and_close(), which runs under RTNL lock.
> 
> Fixes: 2e281e1155fc ("idpf: detach and close netdevs while handling a reset")
> Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
> Reviewed-by: Joshua Hay <joshua.a.hay@intel.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Salin, Samuel Sept. 3, 2026, 1:17 a.m. UTC | #2
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Simon Horman
> Sent: Thursday, August 13, 2026 6:41 AM
> To: Tantilov, Emil S <emil.s.tantilov@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; Nguyen,
> Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; andrew+netdev@lunn.ch;
> davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
> pabeni@redhat.com; Hay, Joshua A <joshua.a.hay@intel.com>
> Subject: Re: [Intel-wired-lan] [PATCH iwl-net] idpf: fix possible race on remove
> during a reset
> 
> On Tue, Aug 11, 2026 at 10:17:51AM -0700, Emil Tantilov wrote:
> > Reset and remove can race, leaving NAPI registered and enabled:
> >
> > modprobe idpf& sleep 1; ip link set eth0 up& rmmod idpf
> >
> > [145561.805104] WARNING: net/core/dev.c:7699 at
> > __netif_napi_del_locked+0x11a/0x130, CPU#30: rmmod/22393 ...
> > [145561.810238] RIP: 0010:__netif_napi_del_locked+0x11a/0x130
> > ...
> > [145561.817678] Call Trace:
> > [145561.818125]  <TASK>
> > [145561.818653]  free_netdev+0x110/0x2a0 [145561.819109]
> > idpf_vport_dealloc+0x452/0x460 [idpf] [145561.819668]  ?
> > enable_work+0x9f/0x100 [145561.820133]  idpf_deinit_task+0x51/0x70
> > [idpf] [145561.820694]  idpf_vc_core_deinit+0x32/0x170 [idpf]
> > [145561.821193]  idpf_remove+0x40/0x200 [idpf] [145561.821667]
> > pci_device_remove+0x40/0xa0 [145561.822132]
> > device_release_driver_internal+0x1a9/0x210
> > [145561.822691]  driver_detach+0x4b/0x90 [145561.823161]
> > bus_remove_driver+0x70/0x100 [145561.823721]
> > pci_unregister_driver+0x2e/0xb0 [145561.824207]
> > __do_sys_delete_module.constprop.0+0x190/0x2e0
> > [145561.824715]  ? kmem_cache_free+0x312/0x550 [145561.825213]
> > do_syscall_64+0xc8/0x6b0 [145561.825709]  ? clear_bhb_loop+0x30/0x80
> > [145561.826216]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
> > [145561.826602] RIP: 0033:0x7fe628130beb
> >
> > Make sure to call idpf_vport_stop() in idpf_stop(), irrespective of
> > the IDPF_REMOVE_IN_PROG state, to allow a reset racing with remove to
> > tear down NAPI in idpf_detach_and_close(), which runs under RTNL lock.
> >
> > Fixes: 2e281e1155fc ("idpf: detach and close netdevs while handling a
> > reset")
> > Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
> > Reviewed-by: Joshua Hay <joshua.a.hay@intel.com>
> 
> Reviewed-by: Simon Horman <horms@kernel.org>

Tested-by: Samuel Salin <Samuel.salin@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
index bb81e620c5c8..c2d7d92d0bf1 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c
@@ -1031,12 +1031,8 @@  static void idpf_vport_stop(struct idpf_vport *vport, bool rtnl)
  */
 static int idpf_stop(struct net_device *netdev)
 {
-	struct idpf_netdev_priv *np = netdev_priv(netdev);
 	struct idpf_vport *vport;
 
-	if (test_bit(IDPF_REMOVE_IN_PROG, np->adapter->flags))
-		return 0;
-
 	idpf_vport_ctrl_lock(netdev);
 	vport = idpf_netdev_to_vport(netdev);