Skip to content

Commit b4a8085

Browse files
jdamato-fslyanguy11
authored andcommitted
e1000: Move cancel_work_sync to avoid deadlock
Previously, e1000_down called cancel_work_sync for the e1000 reset task (via e1000_down_and_stop), which takes RTNL. As reported by users and syzbot, a deadlock is possible in the following scenario: CPU 0: - RTNL is held - e1000_close - e1000_down - cancel_work_sync (cancel / wait for e1000_reset_task()) CPU 1: - process_one_work - e1000_reset_task - take RTNL To remedy this, avoid calling cancel_work_sync from e1000_down (e1000_reset_task does nothing if the device is down anyway). Instead, call cancel_work_sync for e1000_reset_task when the device is being removed. Fixes: e400c74 ("e1000: Hold RTNL when e1000_down can be called") Reported-by: [email protected] Closes: https://lore.kernel.org/netdev/[email protected]/ Reported-by: John <[email protected]> Closes: https://lore.kernel.org/netdev/CAP=Rh=OEsn4y_2LvkO3UtDWurKcGPnZ_NPSXK=FbgygNXL37Sw@mail.gmail.com/ Signed-off-by: Joe Damato <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Acked-by: Jacob Keller <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent a5a441a commit b4a8085

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/ethernet/intel/e1000/e1000_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,6 @@ static void e1000_down_and_stop(struct e1000_adapter *adapter)
477477

478478
cancel_delayed_work_sync(&adapter->phy_info_task);
479479
cancel_delayed_work_sync(&adapter->fifo_stall_task);
480-
481-
/* Only kill reset task if adapter is not resetting */
482-
if (!test_bit(__E1000_RESETTING, &adapter->flags))
483-
cancel_work_sync(&adapter->reset_task);
484480
}
485481

486482
void e1000_down(struct e1000_adapter *adapter)
@@ -1266,6 +1262,10 @@ static void e1000_remove(struct pci_dev *pdev)
12661262

12671263
unregister_netdev(netdev);
12681264

1265+
/* Only kill reset task if adapter is not resetting */
1266+
if (!test_bit(__E1000_RESETTING, &adapter->flags))
1267+
cancel_work_sync(&adapter->reset_task);
1268+
12691269
e1000_phy_hw_reset(hw);
12701270

12711271
kfree(adapter->tx_ring);

0 commit comments

Comments
 (0)