From: sashiko-bot@kernel.org
To: "Adrian Hunter" <adrian.hunter@intel.com>
Cc: linux-i3c@lists.infradead.org, Frank.Li@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH 08/17] i3c: mipi-i3c-hci: Fix runtime PM violation in i3c_hci_free_ibi()
Date: Mon, 14 Sep 2026 11:58:01 +0000 [thread overview]
Message-ID: <20260914115802.2C2951F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260914113003.183150-9-adrian.hunter@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Use-after-free of IBI slot and payload buffer during IBI teardown due to premature memory pool freeing.
- [High] NULL pointer dereference when processing IBI requests on v2 HCI controllers.
--
commit 732d63594fc6d691b8839c600454610c6dcb62e2
Author: Adrian Hunter <adrian.hunter@intel.com>
i3c: mipi-i3c-hci: Fix runtime PM violation in i3c_hci_free_ibi()
This commit addresses a runtime PM issue where i3c_hci_free_ibi() calls
__i3c_hci_disable_ibi() without runtime PM being resumed. It fixes the issue
by replacing the hardware disable call with software removal of the device
from the ibi_devs array.
> - runtime resume failed in i3c_dev_free_ibi_locked(), so it skips the
> IBI disable but still proceeds to call ->free_ibi()
> - the device has been re-enumerated under a new dynamic address in
> __i3c_master_add_i3c_dev_locked(), which tears down the old device
> descriptor and deliberately clears olddev->ibi->enabled (to avoid
> sending a DISEC to the stale old address) before calling
> i3c_dev_free_ibi_locked(). As a result ->free_ibi() is reached with
> neither a hardware IBI disable nor runtime PM resumed.
[Severity: Critical]
This is a pre-existing issue, but does skipping the disable step in
i3c_dev_free_ibi_locked() lead to a use-after-free when there are pending IBIs?
When i3c_dev_free_ibi_locked() skips i3c_dev_disable_ibi_locked(), it proceeds
to call master->ops->free_ibi(dev) which frees the backing memory pool:
drivers/i3c/master.c:i3c_dev_free_ibi_locked() {
...
master->ops->free_ibi(dev);
if (dev->ibi->wq) {
destroy_workqueue(dev->ibi->wq);
dev->ibi->wq = NULL;
}
...
}
Because destroy_workqueue() flushes and executes pending works after the pool
is already freed, could the work handler access the freed slot data?
drivers/i3c/master.c:i3c_master_handle_ibi() {
...
payload.data = slot->data;
payload.len = slot->len;
if (dev->dev)
dev->ibi->handler(dev->dev, &payload);
...
}
> diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mipi-i3c-hci/core.c
> index f6a34ce7a2955..b9b20797d0454 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/core.c
> +++ b/drivers/i3c/master/mipi-i3c-hci/core.c
> @@ -675,11 +675,13 @@ static void __i3c_hci_disable_ibi(struct i3c_hci *hci, struct i3c_dev_desc *dev)
>
> static void i3c_hci_free_ibi(struct i3c_dev_desc *dev)
> {
[Severity: High]
This isn't a bug introduced by this patch, but does the __i3c_hci_disable_ibi()
function (and i3c_hci_request_ibi()) cause a NULL pointer dereference on v2
HCI controllers?
For v2 controllers (where hci->cmd == &mipi_i3c_hci_cmd_v2), i3c_hci_bus_init()
does not initialize the DAT array, leaving hci->DAT as NULL. However, the IBI
ops unconditionally invoke v1 DAT operations:
drivers/i3c/master/mipi-i3c-hci/core.c:__i3c_hci_disable_ibi() {
...
mipi_i3c_hci_dat_v1.set_flags(hci, dev_data->dat_idx, DAT_0_SIR_REJECT, 0);
...
}
And similarly in i3c_hci_request_ibi():
drivers/i3c/master/mipi-i3c-hci/core.c:i3c_hci_request_ibi() {
...
if (req->max_payload_len != 0)
mipi_i3c_hci_dat_v1.set_flags(hci, dat_idx, DAT_0_IBI_PAYLOAD, 0);
...
}
Will these unconditionally dereference the NULL hci->DAT pointer via
dat_w0_read() when an IBI is requested or disabled on a v2 controller?
> + struct i3c_hci_dev_data *dev_data = i3c_dev_get_master_data(dev);
> struct i3c_master_controller *m = i3c_dev_get_master(dev);
> struct i3c_hci *hci = to_i3c_hci(m);
>
> - /* Must ensure the IBI has been disabled */
> - __i3c_hci_disable_ibi(hci, dev);
> + /* Must ensure IBIs for this device will no longer be processed */
> + scoped_guard(spinlock_irqsave, &hci->lock)
> + hci->ibi_devs[dev_data->dat_idx] = NULL;
> hci->io->free_ibi(hci, dev);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914113003.183150-1-adrian.hunter@intel.com?part=8
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2026-09-14 11:58 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 11:29 [PATCH 00/17] i3c: Fixes, cleanups and HDR-DDR support Adrian Hunter
2026-09-14 11:29 ` [PATCH 01/17] i3c: master: Fix out-of-bounds read in DMA bounce buffer setup Adrian Hunter
2026-09-14 16:09 ` Frank Li
2026-09-14 11:29 ` [PATCH 02/17] i3c: mipi-i3c-hci: Bounce short reads irrespective of the IOMMU Adrian Hunter
2026-09-14 16:16 ` Frank Li
2026-09-14 11:29 ` [PATCH 03/17] i3c: mipi-i3c-hci-pci: Set drvdata before creating LTR sysfs attribute Adrian Hunter
2026-09-14 11:45 ` sashiko-bot
2026-09-14 16:17 ` Frank Li
2026-09-14 11:29 ` [PATCH 04/17] i3c: master: Match ACPI targets to the correct bus controller instance Adrian Hunter
2026-09-14 11:50 ` sashiko-bot
2026-09-14 16:19 ` Frank Li
2026-09-14 11:29 ` [PATCH 05/17] i3c: master: Remove stale GETSTATUS length check Adrian Hunter
2026-09-14 16:23 ` Frank Li
2026-09-14 11:29 ` [PATCH 06/17] i3c: mipi-i3c-hci: Fix i3c_hci_enable_ibi() error path Adrian Hunter
2026-09-14 11:46 ` sashiko-bot
2026-09-14 16:27 ` Frank Li
2026-09-14 11:29 ` [PATCH 07/17] i3c: mipi-i3c-hci: Send DISEC before disabling IBIs in hardware Adrian Hunter
2026-09-14 16:29 ` Frank Li
2026-09-14 11:29 ` [PATCH 08/17] i3c: mipi-i3c-hci: Fix runtime PM violation in i3c_hci_free_ibi() Adrian Hunter
2026-09-14 11:58 ` sashiko-bot [this message]
2026-09-14 11:29 ` [PATCH 09/17] i3c: mipi-i3c-hci: Process multiple IBIs per interrupt Adrian Hunter
2026-09-14 16:45 ` Frank Li
2026-09-15 9:36 ` Adrian Hunter
2026-09-14 11:29 ` [PATCH 10/17] i3c: mipi-i3c-hci: Move DMA suspend/resume callbacks Adrian Hunter
2026-09-14 16:46 ` Frank Li
2026-09-14 11:29 ` [PATCH 11/17] i3c: mipi-i3c-hci: Stop rings gracefully when suspending Adrian Hunter
2026-09-14 16:51 ` Frank Li
2026-09-14 11:29 ` [PATCH 12/17] i3c: mipi-i3c-hci: Fix Response Descriptor DATA_LENGTH mask Adrian Hunter
2026-09-14 11:48 ` sashiko-bot
2026-09-14 16:55 ` Frank Li
2026-09-14 11:29 ` [PATCH 13/17] i3c: mipi-i3c-hci: Remove invalid transfer size limit Adrian Hunter
2026-09-14 11:49 ` sashiko-bot
2026-09-14 16:58 ` Frank Li
2026-09-14 11:30 ` [PATCH 14/17] i3c: mipi-i3c-hci: Remove invalid HDR-BT and Fm/Fm+ definitions Adrian Hunter
2026-09-14 17:00 ` Frank Li
2026-09-14 11:30 ` [PATCH 15/17] i3c: mipi-i3c-hci: Support configurable device NACK retries Adrian Hunter
2026-09-14 11:56 ` sashiko-bot
2026-09-14 18:21 ` Frank Li
2026-09-15 9:41 ` Adrian Hunter
2026-09-14 11:30 ` [PATCH 16/17] i3c: Restrict HDR modes to those supported by the bus and target Adrian Hunter
2026-09-14 18:26 ` Frank Li
2026-09-14 11:30 ` [PATCH 17/17] i3c: mipi-i3c-hci: Add HDR-DDR support Adrian Hunter
2026-09-14 11:54 ` sashiko-bot
2026-09-14 12:54 ` Adrian Hunter
2026-09-14 18:32 ` Frank Li
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=20260914115802.2C2951F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-i3c@lists.infradead.org \
--cc=sashiko-reviews@lists.linux.dev \
/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