From: sashiko-bot@kernel.org
To: "Akhil R" <akhilrajeev@nvidia.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
linux-i3c@lists.infradead.org, linux-hwmon@vger.kernel.org,
Frank.Li@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH v6 06/12] i3c: master: match I3C device through DT and ACPI
Date: Tue, 21 Jul 2026 04:25:58 +0000 [thread overview]
Message-ID: <20260721042558.925AA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721040805.1696503-7-akhilrajeev@nvidia.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Time-of-Check to Time-of-Use (TOCTOU) race condition leading to a NULL pointer dereference during device matching.
- [High] Missing OF and ACPI MODALIAS generation in the bus uevent callback, preventing module autoloading for newly supported devices.
- [Medium] Latent API trap: DT/ACPI matching bypasses the I3C ID table match, causing a NULL pointer dereference in driver probe functions.
Pre-existing issues:
- [High] Uninitialized kernel stack memory is deterministically leaked to user-space via the `KOBJ_REMOVE` uevent.
--
--- Patch [6]: [PATCH v6 06/12] i3c: master: match I3C device through DT and ACPI ---
commit 7db2eb24719ceb614bd3ec6e5efb369d3b92fe6e
Author: Akhil R <akhilrajeev@nvidia.com>
i3c: master: match I3C device through DT and ACPI
SETAASA-based devices cannot always be identified by PID or DCR; the
standard I3C id_table matching may not be applicable. Allow such devices to
match through Device Tree or ACPI.
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 7b2f819bf4437..43bf530bc6619 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
[ ... ]
> @@ -345,15 +346,32 @@ static int i3c_device_match(struct device *dev, const struct device_driver *drv)
> {
> struct i3c_device *i3cdev;
> const struct i3c_driver *i3cdrv;
> + u8 static_addr_method = 0;
>
> if (dev->type != &i3c_device_type)
> return 0;
>
> i3cdev = dev_to_i3cdev(dev);
> i3cdrv = drv_to_i3cdrv(drv);
> - if (i3c_device_match_id(i3cdev, i3cdrv->id_table))
> +
> + if (i3cdev->desc && i3cdev->desc->boardinfo)
> + static_addr_method = i3cdev->desc->boardinfo->static_addr_method;
[Severity: High]
Can i3cdev->desc be modified concurrently here?
Looking at i3c_master_unregister_i3c_devs(), it locklessly sets
i3cdev->dev->desc = NULL during device unregistration.
Since the check in i3c_device_match() is done without locks or READ_ONCE(),
could the compiler emit multiple loads for i3cdev->desc, leading to a NULL
pointer dereference when subsequently accessing boardinfo?
> +
> + /*
> + * SETAASA-based devices need not always have a matching ID since
> + * it is not mandatory for such devices to implement deviceinfo
> + * CCC commands. Allow them to register through DT or ACPI.
> + */
> + if (i3cdrv->id_table && i3c_device_match_id(i3cdev, i3cdrv->id_table))
> return 1;
>
> + if (static_addr_method & I3C_ADDR_METHOD_SETAASA) {
> + if (of_driver_match_device(dev, drv))
> + return 1;
> + if (acpi_driver_match_device(dev, drv))
> + return 1;
> + }
[Severity: Medium]
Will this fallback matching break the assumptions in existing driver probe
functions?
Currently, drivers typically call i3c_device_match_id() in their probe
routine and unconditionally dereference the returned pointer.
When an I3C device binds via DT or ACPI through this new path,
i3c_device_match_id() will return NULL. If developers add an of_match_table
to existing drivers to support SETAASA devices, won't this cause an immediate
NULL pointer dereference during probe?
[Severity: High]
How does this change affect module autoloading for newly supported devices?
While the patch allows devices to match via DT or ACPI, it appears the bus
uevent callback, i3c_device_uevent(), was not updated and only emits the
generic I3C modalias.
Since of_device_uevent_modalias() or acpi_device_uevent_modalias() are not
called, won't the uevent lack the required of:N... string, preventing udev
from matching the device against the driver's MODULE_DEVICE_TABLE(of, ...)?
[Severity: High]
This is a pre-existing issue, but can the removal of an I3C device leak
uninitialized kernel stack memory to user-space?
When an I3C device is removed, i3c_master_unregister_i3c_devs() sets
i3cdev->dev->desc = NULL before calling device_unregister(), which
triggers a KOBJ_REMOVE uevent.
In i3c_device_uevent():
struct i3c_device_info devinfo;
if (i3cdev->desc)
devinfo = i3cdev->desc->info;
Since i3cdev->desc is unconditionally NULL during removal, devinfo is left
uninitialized. The function then proceeds to construct the MODALIAS string
using devinfo:
return add_uevent_var(env,
"MODALIAS=i3c:dcr%02Xmanuf%04Xpart%04Xext%04X",
devinfo.dcr, manuf, part, ext);
Doesn't this deterministically embed uninitialized kernel stack data into the
uevent environment variables, exposing it to user-space programs like udev?
> +
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721040805.1696503-1-akhilrajeev@nvidia.com?part=6
next prev parent reply other threads:[~2026-07-21 4:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 4:07 [PATCH v6 00/12] Support ACPI and SETAASA device discovery Akhil R
2026-07-21 4:07 ` [PATCH v6 01/12] dt-bindings: i3c: Add mipi-i3c-static-method to support SETAASA Akhil R
2026-07-21 4:16 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 02/12] i3c: master: Use unified device property interface Akhil R
2026-07-21 4:25 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 03/12] i3c: master: Support ACPI enumeration of child devices Akhil R
2026-07-21 4:32 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 04/12] i3c: master: Add support for devices using SETAASA Akhil R
2026-07-21 4:30 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 05/12] i3c: master: Add support for devices without PID Akhil R
2026-07-21 4:26 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 06/12] i3c: master: match I3C device through DT and ACPI Akhil R
2026-07-21 4:25 ` sashiko-bot [this message]
2026-07-21 4:07 ` [PATCH v6 07/12] i3c: dw-i3c-master: Add SETAASA as supported CCC Akhil R
2026-07-21 4:24 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 08/12] i3c: dw-i3c-master: Add ACPI core clock frequency quirk Akhil R
2026-07-21 4:26 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 09/12] i3c: dw-i3c-master: Add ACPI ID for Tegra410 Akhil R
2026-07-21 4:22 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 10/12] hwmon: spd5118: Remove 16-bit addressing Akhil R
2026-07-21 4:25 ` sashiko-bot
2026-07-21 4:07 ` [PATCH v6 11/12] hwmon: spd5118: Add I3C support Akhil R
2026-07-21 4:35 ` sashiko-bot
2026-07-21 4:08 ` [PATCH v6 12/12] arm64: defconfig: Enable I3C and SPD5118 hwmon Akhil R
2026-07-21 4:28 ` sashiko-bot
2026-07-21 16:52 ` [PATCH v6 00/12] Support ACPI and SETAASA device discovery 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=20260721042558.925AA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=akhilrajeev@nvidia.com \
--cc=alexandre.belloni@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i3c@lists.infradead.org \
--cc=robh@kernel.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