From: Kery Qi <qikeyu2017@gmail.com>
To: mkl@pengutronix.de
Cc: linux-kernel@vger.kernel.org, Kery Qi <qikeyu2017@gmail.com>
Subject: [PATCH] can: mcp251xfd: fix UAF from workqueue double-destroy
Date: Thu, 8 Jan 2026 16:20:42 +0800 [thread overview]
Message-ID: <20260108082042.1627-1-qikeyu2017@gmail.com> (raw)
mcp251xfd_open() allocates priv->wq after the controller is started.
If request_threaded_irq() or mcp251xfd_chip_interrupts_enable() fails,
the error path destroys the workqueue but leaves priv->wq unchanged.
This leaves a dangling non-NULL pointer that can later be destroyed
again, for example:
- a retry to open the device fails before priv->wq is reallocated and a
later close/remove cleanup destroys the stale pointer; or
- reset/recovery paths end up calling mcp251xfd_stop() after the failed
open and destroy priv->wq again.
Clear priv->wq after destroy_workqueue() to make teardown idempotent and
avoid double-destroy/use-after-free crashes.
This is the same bug class as CVE-2024-26802 (stmmac workqueue teardown).
Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
---
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 5134ebb85880..c5ac0c8a6e08 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -1661,6 +1661,8 @@ static int mcp251xfd_open(struct net_device *ndev)
free_irq(spi->irq, priv);
out_destroy_workqueue:
destroy_workqueue(priv->wq);
+ if (priv->wq)
+ priv->wq = NULL;
out_can_rx_offload_disable:
can_rx_offload_disable(&priv->offload);
set_bit(MCP251XFD_FLAGS_DOWN, priv->flags);
--
2.34.1
next reply other threads:[~2026-01-08 8:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 8:20 Kery Qi [this message]
2026-01-08 9:41 ` Marc Kleine-Budde
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=20260108082042.1627-1-qikeyu2017@gmail.com \
--to=qikeyu2017@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
/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
all inboxes | Powered by JetHome®