From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: linux-can@vger.kernel.org,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH net] can: peak_pci: Fix potential use-after-free during removal
Date: Mon, 09 Nov 2026 13:21:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-205009@kernel.org> (raw)
In-Reply-To: <20261109-21df1234b2-can-peak-pci@mail.sdu.edu.cn>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] can: sja1000: peak_pci: use-after-free in
peak_pciec_led_work() [1]
--
commit c34b5385557b3189871973b5ef5794cd792b0b5e
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
can: peak_pci: Fix potential use-after-free during removal
This commit moves unregister_sja1000dev() before peak_pciec_remove() in
peak_pci_remove() so that the ExpressCard context remains valid while the
first channel is unregistered.
> diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
> index 69c61ccf621df..618f8f6a57500 100644
> --- a/drivers/net/can/sja1000/peak_pci.c
> +++ b/drivers/net/can/sja1000/peak_pci.c
> @@ -752,10 +752,10 @@ static void peak_pci_remove(struct pci_dev *pdev)
> struct net_device *prev_dev = chan->prev_dev;
>
> dev_info(&pdev->dev, "removing device %s\n", dev->name);
> + unregister_sja1000dev(dev);
> /* do that only for first channel */
> if (!prev_dev && chan->pciec_card)
> peak_pciec_remove(chan->pciec_card);
> - unregister_sja1000dev(dev);
> free_sja1000dev(dev);
[Severity: Critical]
This problem wasn't introduced by this patch, but can peak_pciec_led_work()
race with channel removal and cause a use-after-free [1] on
multi-channel ExpressCard devices?
peak_pci_remove() (and the failure_remove_channels unwind loop in
peak_pci_probe()) iterates over channels in reverse order, freeing
secondary channels via free_sja1000dev() while leaving their pointers in
card->channel[]. However, card->led_work is only cancelled by
peak_pciec_remove() once the loop reaches the first channel (!prev_dev):
CPU0 CPU1
peak_pci_remove()
free_sja1000dev(dev)
peak_pciec_led_work()
netdev = card->channel[i].netdev;
if (!(netdev->flags & IFF_UP))
<-- use-after-free
if (!prev_dev && chan->pciec_card)
peak_pciec_remove(chan->pciec_card)
...
cancel_delayed_work_sync(&card->led_work)
Cancelling the LED work before freeing any channel netdev would avoid
this race.
[1] https://sashiko.dev/#/bug/linux-d81f042f-87f9-4ee0-9986-e44ae5a9d8a7
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261109-21df1234b2-can-peak-pci@mail.sdu.edu.cn?part=1
next prev parent reply other threads:[~2026-11-09 13:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 13:09 [PATCH net] can: peak_pci: Fix potential use-after-free during removal Guangshuo Li
2026-11-09 13:21 ` sashiko-bot [this message]
2026-11-11 2:15 ` netdev-bot+sashiko
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=sashiko-outbox-205009@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=liguangshuo@mail.sdu.edu.cn \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.