From: sashiko-bot@kernel.org
To: b.lane130@outlook.com
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] can: peak_pci: fix UAF and leak of PCIeC resources
Date: Mon, 23 Nov 2026 09:09:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-228944@kernel.org> (raw)
In-Reply-To: <BN8PR06MB6177DC485B9CA4729F930DBDA4452@BN8PR06MB6177.namprd06.prod.outlook.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] can: peak_pci: UAF of chan->pciec_card in peak_pci_probe()
rollback
--
commit 966ed02e76bd87e25cf2422b16a91f40918e28bf
Author: Bruce Lane <b.lane130@outlook.com>
can: peak_pci: fix UAF and leak of PCIeC resources
This commit adds peak_pciec_remove() to the failure_free_dev error path
in peak_pci_probe() and moves the peak_pciec_remove() call in
failure_remove_channels inside the channel teardown loop.
> diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
> index 69c61ccf621df..d5f862f05480a 100644
> --- a/drivers/net/can/sja1000/peak_pci.c
> +++ b/drivers/net/can/sja1000/peak_pci.c
[ ... ]
> @@ -709,15 +713,12 @@ static int peak_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> priv = netdev_priv(dev);
> chan = priv->priv;
> prev_dev = chan->prev_dev;
> -
> + if (!prev_dev && chan->pciec_card)
> + peak_pciec_remove(chan->pciec_card);
> unregister_sja1000dev(dev);
> free_sja1000dev(dev);
> }
[Severity: High]
Does calling peak_pciec_remove() before unregister_sja1000dev() cause a
use-after-free of chan->pciec_card when unwinding channel 0?
peak_pciec_remove() frees the struct peak_pciec_card pointed to by
chan->pciec_card, and unregister_sja1000dev() then calls
set_reset_mode() -> priv->write_reg(). On PCAN-ExpressCard devices,
priv->write_reg is peak_pciec_write_reg(), which dereferences
chan->pciec_card:
drivers/net/can/sja1000/peak_pci.c:peak_pciec_write_reg() {
struct peak_pci_chan *chan = priv->priv;
struct peak_pciec_card *card = chan->pciec_card;
int c = (priv->reg_base - card->reg_base) / PEAK_PCI_CHAN_SIZE;
...
}
Calling unregister_sja1000dev(dev) before peak_pciec_remove() and
free_sja1000dev(dev) afterwards avoids freeing chan->pciec_card while
unregister_sja1000dev() still needs it.
--
Sashiko AI review · https://sashiko.dev/#/patchset/BN8PR06MB6177DC485B9CA4729F930DBDA4452@BN8PR06MB6177.namprd06.prod.outlook.com?part=1
next prev parent reply other threads:[~2026-11-23 9:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 9:01 [PATCH] can: peak_pci: fix UAF and leak of PCIeC resources b.lane130
2026-11-23 9:09 ` sashiko-bot [this message]
2026-11-24 22:26 ` 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-228944@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=b.lane130@outlook.com \
--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.