Netdev List
 help / color / mirror / Atom feed
* [PATCH iwl-net] e1000: always cancel the reset task in e1000_remove()
@ 2026-12-03  6:14 Joseph Telaak
  0 siblings, 0 replies; only message in thread
From: Joseph Telaak @ 2026-12-03  6:14 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Stanislav Fomichev,
	Joe Damato, Jacob Keller
  Cc: intel-wired-lan, netdev, Joseph Telaak

e1000_remove() skips cancel_work_sync() on the reset task while
__E1000_RESETTING is set. The check was needed when the cancel was in
e1000_down_and_stop(), which the reset task reaches through
e1000_down(), and it stayed when commit b4a8085ceefb ("e1000: Move
cancel_work_sync to avoid deadlock") moved the cancel after
unregister_netdev() in e1000_remove().

Every other path that sets __E1000_RESETTING runs under RTNL on the
registered netdev, so after unregister_netdev() only the reset task can
hold it. The check therefore skips the cancel while the task holds the
bit, and free_netdev() can free the adapter before the task clears it.
With __E1000_DOWN already set the task holds the bit only briefly, so
this needs the task to be preempted there.

e1000_remove() does not hold RTNL there, so cancelling the task, which
takes RTNL, cannot deadlock. e1000e also cancels its reset task
unconditionally in its remove path.

Fixes: b4a8085ceefb ("e1000: Move cancel_work_sync to avoid deadlock")
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
Sashiko pointed this out while reviewing an unrelated e1000 series:
https://lore.kernel.org/r/sashiko-outbox-245054@kernel.org
I know of no field reports, and I could only hit the window with the
test hooks below.

Tested on a CE5300 board with KASAN and lockdep, using test-only hooks
that queue the reset task in e1000_remove() and hold __E1000_RESETTING
in it for a second. Without this patch KASAN reports a slab
use-after-free in e1000_reinit_locked() from the reset task, with the
netdev freed by e1000_remove(). With it, e1000_remove() waits for the
task, and unbind and rebind work with no reports.
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index a52fff0259a1..d79e7ca69792 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1270,9 +1270,7 @@ static void e1000_remove(struct pci_dev *pdev)
 
 	unregister_netdev(netdev);
 
-	/* Only kill reset task if adapter is not resetting */
-	if (!test_bit(__E1000_RESETTING, &adapter->flags))
-		cancel_work_sync(&adapter->reset_task);
+	cancel_work_sync(&adapter->reset_task);
 
 	e1000_phy_hw_reset(hw);
 

---
base-commit: 68be40d53028e490d37ff7e754dac4afae2ef421
change-id: 20261202-e1000-remove-reset-task-f2c8d8518822

Best regards,
--  
Joseph Telaak <joseph@telaak.dev>


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-03  6:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  6:14 [PATCH iwl-net] e1000: always cancel the reset task in e1000_remove() Joseph Telaak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox