Netdev List
 help / color / mirror / Atom feed
From: Joseph Telaak <joseph@telaak.dev>
To: Tony Nguyen <anthony.l.nguyen@intel.com>,
	 Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	 Andrew Lunn <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	 Stanislav Fomichev <sdf@fomichev.me>, Joe Damato <joe@dama.to>,
	 Jacob Keller <jacob.e.keller@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	 Joseph Telaak <joseph@telaak.dev>
Subject: [PATCH iwl-net] e1000: always cancel the reset task in e1000_remove()
Date: Thu, 03 Dec 2026 01:14:24 -0500	[thread overview]
Message-ID: <20261203-e1000-remove-reset-task-v1-1-71d6e9464dc5@telaak.dev> (raw)

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>


                 reply	other threads:[~2026-12-03  6:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261203-e1000-remove-reset-task-v1-1-71d6e9464dc5@telaak.dev \
    --to=joseph@telaak.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=joe@dama.to \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@fomichev.me \
    /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