Article View: linux.kernel.netdev
Article #12650Re: [PATCH net 1/3] net: atl1: disable work before freeing the netdev
From: netdev-bot+sashiko
Date: Sun, 08 Nov 2026 06:59
Date: Sun, 08 Nov 2026 06:59
164 lines
14034 bytes
14034 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message offers atl2_remove() as a correct sibling:
"atl2_remove() cancels both works and deletes the timer before…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
atl1_reset_dev_task()…
--
net: atl1: disable work before freeing the netdev
This patch changes atl1_remove() to call disable_work_sync() on
reset_dev_task and link_chg_task before unregister_netdev(). After that,
it deletes the PHY config timer. The goal is to stop either work from
running after free_netdev().
> Disable both works synchronously before unregistering the interface,
> then delete the PHY configuration timer. disable_work_sync() drains a
> queued or running instance and rejects a later queue_work(), which a
> plain cancel_work_sync() would not. Deleting the timer after the works
> have stopped also prevents a running link work from rearming it.
> atl2_remove() cancels both works and deletes the timer before
> unregistering for the same reason.
[Severity: Medium]
Is atl2_remove() a correct precedent here? By the reasoning in this
message, it looks like atl2 still has the same use-after-free:
drivers/net/ethernet/atheros/atlx/atl2.c:atl2_remove() {
...
set_bit(__ATL2_DOWN, &adapter->flags);
timer_delete_sync(&adapter->watchdog_timer);
timer_delete_sync(&adapter->phy_config_timer);
cancel_work_sync(&adapter->reset_task);
cancel_work_sync(&adapter->link_chg_task);
unregister_netdev(netdev);
...
}
When the cancel_work_sync() calls run, the IRQ is still requested. It is
only freed by atl2_close(), from inside unregister_netdev(), and
dev_watchdog is still active as well. That leaves these paths able to
queue work again after the cancels:
atl2_intr()
schedule_work(&adapter->reset_task); (link-down and DMA errors)
atl2_intr() -> atl2_check_for_link()
schedule_work(&adapter->link_chg_task); (ISR_PHY or ISR_MANUAL)
dev_watchdog -> atl2_tx_timeout()
schedule_work(&adapter->reset_task);
None of these check __ATL2_DOWN. atl2_close() and atl2_down() never
cancel the works, so anything queued in that window can still be pending
at free_netdev().
The ordering is also the reverse of what the message says is needed.
atl2 deletes the timers before it cancels the works, and relies on
__ATL2_DOWN to block rearming. But atl2_reset_task() ->
atl2_reinit_locked() -> atl2_up() runs:
clear_bit(__ATL2_DOWN, &adapter->flags);
atl2_up() also sets MASTER_CTRL_MANUAL_INT, which can raise a manual
interrupt that queues link_chg_task again.
No other patch in the series touches atl2.c. Should the message stop
describing atl2_remove() as equivalent, or should atl2_remove() get the
same conversion?
> diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
> index 2883e9462f6fd..2bd35c3cfc820 100644
> --- a/drivers/net/ethernet/atheros/atlx/atl1.c
> +++ b/drivers/net/ethernet/atheros/atlx/atl1.c
> @@ -3132,6 +3132,18 @@ static void atl1_remove(struct pci_dev *pdev)
>
> adapter = netdev_priv(netdev);
>
> + /*
> + * reset_dev_task is queued from the interrupt handler and from the
> + * tx watchdog; link_chg_task is queued from the interrupt handler
> + * when ISR_GPHY reports a link event. Disable both before
> + * unregistering the interface so that neither a pending nor a late
> + * queue attempt can run after free_netdev().
> + */
> + disable_work_sync(&adapter->reset_dev_task);
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. Can
atl1_reset_dev_task() race with atl1_close() and the ethtool
reconfiguration paths? It takes no lock and does not check
netif_running():
drivers/net/ethernet/atheros/atlx/atl1.c:atl1_reset_dev_task() {
...
netif_device_detach(netdev);
atl1_down(adapter);
atl1_up(adapter);
netif_device_attach(netdev);
}
atl1_close() (ndo_stop), atl1_change_mtu(), atl1_set_link_ksettings(),
atl1_set_ringparam() and atl1_nway_reset() all run atl1_down() and
atl1_up() under RTNL. Nothing serializes them against this work, and
atl1_close() does not cancel it:
drivers/net/ethernet/atheros/atlx/atl1.c:atl1_close() {
...
atl1_down(adapter);
atl1_free_ring_resources(adapter);
return 0;
}
Here is one possible sequence:
atlx_tx_timeout() or atl1_intr()
queue reset_dev_task
ip link set dev ethX down
__dev_close_many() (no netif_device_present() check)
atl1_close()
atl1_down() napi_disable(), free_irq(), ring cleanup
atl1_free_ring_resources()
kworker: atl1_reset_dev_task()
atl1_down()
napi_disable()
netdev_lock(n->dev);
napi_disable_locked(n); spins forever, SCHED never clears
When that happens, the kworker blocks while holding the netdev instance
lock. A later atl1_open() -> atl1_up() -> napi_enable() -> netdev_lock()
would then deadlock with RTNL held.
If the work instead runs at the same time as close or ethtool -G, both
CPUs end up in atl1_down(). That can call free_irq() twice and double
free skbs in atl1_clean_rx_ring() and atl1_clean_tx_ring(). It can also
let atl1_set_ringparam() or atl1_close() free the descriptor rings while
the worker's atl1_up() is refilling them in atl1_alloc_rx_buffers().
With this patch applied, this disable_work_sync() would also wait forever
on a worker stuck that way. Should the reset work take rtnl_lock() and
check netif_running(), as other drivers do in their reset tasks?
> + disable_work_sync(&adapter->link_chg_task);
> + timer_delete_sync(&adapter->phy_config_timer);
> + adapter->phy_timer_pending = false;
> +
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261104063245.23402-1-0xbeac%40gmail.com
Technical Details
Message-ID:
<179412116691.994134.8959848817104495766@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358619-linux-kernel-netdev=dewy.ruReferences:
<20261104063245.23402-2-0xbeac@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358619-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 1/3] net: atl1: disable work before freeing the netdev Date: Sun, 08 Nov 2026 06:59:26 +0000 Organization: Usenet Network Message-ID: <179412116691.994134.8959848817104495766@kernel.org> References: <20261104063245.23402-2-0xbeac@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="82386"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:VFuUTW9vjold1HWIDT3qNLgpchY= sha256:usxe5lIBCEZYcCEQHWNaPAdD1WVnuBRTKMCbKtaOOVs= sha1:sJg3hRRGwhn8cUXaB6gwO294pS4= sha256:TtsF/bq/SmChz3hi91y2rleD39AxaxvZa/FGEI6TLcM= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 9AB51113525; Sun, 8 Nov 2026 10:02:01 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K4oOrYPNMEQ1; Sun, 8 Nov 2026 10:01:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-358619-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id F34E411351D; Sun, 8 Nov 2026 10:01:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 793193CBC1; Sun, 8 Nov 2026 06:59:40 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794121180; b=x/nHq4yjOnJ5t1bn5sWR7/eY46LJVBa5xYBrByE5usqUGWMFYgk9ZWp8B5lE/HjqZ+OZ 5Jh1mrh4IxFvvtRbOFZlxMsPgW7I+THSpwPBCGcmRGp2W0LYJXnKzi4Wqgk7tP7ZnkcRP iQIm/wBymOPEQrPVXWxy3j3GKHqoyrO3W89bRFmLGZk6hX5uJdjPR4Bbbev3vuQrMsmB9 AS5CxR3DG8RmWLJNzuKQPyWEUPt4V+woa7wx87oc5bWC2sySO5xn8ukc6UaHjpj1EJvjR lPbaoLrXaPzv1g0Dk/1uooQdzgFAFx1DuBRI278TSSfsNeL0EGecshFJzRuOISwkmrA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794121180; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=TxIUb5bWZGmoAUzDYkV/qaWh4k4doHszwohpd1hGknw=; b=N+twR2fSco5vT0z4HK//yIVQ2Ia8PvWcj1Bb9B7QEs/H5/8EbdpVzahkrb/6xRthWOTv A6Rmta1t/e0kJ/OaRZGXZkFCJioth0n4IGlDXqkdDGzjgwmwSBsXvtzTUP1Q3px1HxyI1 8BeRVx6rvXNy6HW4zvfxjyCEIcmFvzhnfDxrot59uwKR8kF2ykLM5cXXDmViGGJTMLIoO FI3jx0fVZc+vmOiEQ6j6sKApKNgTtlgc6+eZhJJIa4wkBmlQgqcI9ok8ienBDuROHMszl G19RaI4jRSfsOSi5RghSURyTJKGD6jW3d4W7gaRB87BmZJXAyTmz9Hyzzog5loM0HkQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Xpy7CNth; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E3F0606A323; Sun, 8 Nov 2026 06:59:40 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Xpy7CNth X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794121168; b=19pNAsHJ7WyvS4Ky9vkGiFhYUet+6B2RdvfTJQTOYQxyeqVqgluCGG5s5mmh1mCA1PYa CjQo5GbVFwpmWvVGr0WYZGU9LFJVKF0oYnQ5cEZPNjbdUqo/sIIamw5IXptCTKD4UO3ni RBYaD2pvnJgmd8HGndDUqvIACV5itQW1kcFXb5GZ6PnTeo9pbjkHRm+t58cC37E/QrjPG IOimKlQ+wDKLd4MkK2BWTfHiL/GfvweaCmO+dzDq1+BTRpqs4y6aXtcJmZGWjPfMcNECr WSVV4/sf6iHMJ8+lmDErLUMPVKYRjURyrviJyUOinTGDgahFXxXQewnTDz4jydd2fnQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794121168; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=TxIUb5bWZGmoAUzDYkV/qaWh4k4doHszwohpd1hGknw=; b=cTS4jGLl+1WqV+vBiC4DGZOvZqewDAX2xuGQBBVQT4U3ROxs3GymK/cXsQ080QzKPaOm kAj3ADztdas7n3OuUq2vNhbaddOLvknsk1Po4pI9xxJu+gfAoNZ+ipgsh5P7arZFHfqu8 C3YDK6yA70QYf/yyBJZiSTwTxkFizQhyUKmskZEcglxs8WXNjlIXDGq8V0vGs5vp4C7Tm SPfJLt+ABp5r9+rkC+rnoP6B8/9buG2DDaoUOaoqI3sW1f2d39/XinKWtyP496TWSQEso lyBJbvYD77+mPLpsmNUw90WKjJTklFjLTokbp0xLqy8t5qavdOb4+i+hTdjez1tOV3g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Xpy7CNth; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C4D9606A31A; Sun, 8 Nov 2026 06:59:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 678F61F0089F; Sun, 8 Nov 2026 06:59:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794121167; bh=TxIUb5bWZGmoAUzDYkV/qaWh4k4doHszwohpd1hGknw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Xpy7CNthMHn7JInJJ7zre/OqP5C8GcTpHaAlrXr7G+LZmitImXzREGNi8Acd3uiy/ 98Mv1j0teruR8uzB/8vZJflMq1xUKNjP0vftBPeJ9sLaGTVPv1/p07cViCdHqE9Osn Fhy6zhNjTAopyoC9ni7qR1s4H6Z9aC6u+mJQ7FW5ry7aPVh6h3csm8rGiKTvGK1gYU ZcNxMLybVNYi7nWKBJq1uUJ2NJlJzMbjMDWgTgsga4g+UopjTdOaWr20Ir0l/ltiQ/ GHOxM5SQR40nA6apXUStl0Z5+FtpqrRJEJyTZiUbom1wghv6DfAYo8+V+TnLyh/3Wo oglY2IQYn0t9g== X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <20261104063245.23402-2-0xbeac@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list