From: sashiko-bot@kernel.org
To: "Robin Murphy" <robin.murphy@arm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 1/4] ACPI/APMT: Use stable device ID
Date: Thu, 16 Jul 2026 15:17:06 +0000 [thread overview]
Message-ID: <20260716151706.B13061F000E9@smtp.kernel.org> (raw)
In-Reply-To: <f7eb9a4cfea4cd6f8d87f3c2501438d484807d27.1784213435.git.robin.murphy@arm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Platform device ID collision causing APMT parsing abort and subsequent UAF.
Pre-existing issues:
- [High] Missing rollback on failure leaves previously registered platform devices holding dangling pointers to an unmapped ACPI table.
- [High] Missing bounds check on `apmt_node->length` allows out-of-bounds memory read.
- [Medium] GSI IRQ mapping is leaked on platform device registration error paths.
--
--- Patch [1]: [PATCH v2 1/4] ACPI/APMT: Use stable device ID ---
commit 895c0eb864a4218fbb99620f4fa9efb2dc4e091c
Author: Robin Murphy <robin.murphy@arm.com>
ACPI/APMT: Use stable device ID
The APMT node format includes a unique identifier, so we can use this as
the platform device ID to give userspace stable and identifiable device
names.
> diff --git a/drivers/acpi/arm64/apmt.c b/drivers/acpi/arm64/apmt.c
> index bb010f6164e52..91fcdd289e637 100644
> --- a/drivers/acpi/arm64/apmt.c
> +++ b/drivers/acpi/arm64/apmt.c
> @@ -76,10 +76,12 @@ static int __init apmt_add_platform_device(struct acpi_apmt_node *node,
> struct fwnode_handle *fwnode)
> {
> struct platform_device *pdev;
> - int ret, count;
> + int ret, count, uid = node->id & INT_MAX;
> struct resource res[DEV_MAX_RESOURCE_COUNT];
>
> - pdev = platform_device_alloc(DEV_NAME, PLATFORM_DEVID_AUTO);
> + if (uid != node->id)
> + pr_warn("Unexpectedly large UID 0x%x, truncated to 0x%x\n", node->id, uid);
> + pdev = platform_device_alloc(DEV_NAME, uid);
[Severity: High]
Does this newly introduced truncation create a risk of ID collisions if two
unique 32-bit APMT node IDs differ only in the sign bit?
If a collision occurs, platform_device_add() will fail with -EEXIST. This
halts the initialization of all remaining PMU nodes and triggers another issue.
[Severity: High]
This is a pre-existing issue, but when apmt_init_platform_devices() fails
(which is now more likely due to potential ID collisions), the caller unmaps
the ACPI table without a cleanup loop:
drivers/acpi/arm64/apmt.c:acpi_apmt_init() {
...
ret = apmt_init_platform_devices();
if (ret) {
pr_err("Failed to initialize APMT platform devices, ret: %d\n", ret);
acpi_put_table(apmt_table);
}
}
Will this leave any previously successfully registered platform devices holding
dangling pointers in their platform_data referencing the now unmapped table
memory, leading to a use-after-free when a driver later binds?
[Severity: Medium]
This is a pre-existing issue, but if a device addition fails, does the
cleanup path leak the GSI IRQ mapping?
drivers/acpi/arm64/apmt.c:apmt_init_resources() {
...
irq = acpi_register_gsi(NULL, node->ovflw_irq, trigger,
ACPI_ACTIVE_HIGH);
...
}
When apmt_add_platform_device() takes the error path:
drivers/acpi/arm64/apmt.c:apmt_add_platform_device() {
...
dev_put:
platform_device_put(pdev);
return ret;
}
Should there be an acpi_unregister_gsi() call to reverse the mapping created
during apmt_init_resources()?
[Severity: High]
This is a pre-existing issue, but does the table parsing loop in
apmt_init_platform_devices() need a bounds check on apmt_node->length?
drivers/acpi/arm64/apmt.c:apmt_init_platform_devices() {
...
while (offset < end) {
apmt_node = ACPI_ADD_PTR(struct acpi_apmt_node, apmt,
offset);
...
offset += apmt_node->length;
}
...
}
If a malformed ACPI table provides a maliciously small or truncated length,
could this lead to ACPI_ADD_PTR yielding a misaligned pointer and reading
memory outside the mapped ACPI bounds?
> if (!pdev)
> return -ENOMEM;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784213435.git.robin.murphy@arm.com?part=1
next prev parent reply other threads:[~2026-07-16 15:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 14:56 [PATCH v2 0/4] perf/arm_cspmu: Miscellaneous improvements Robin Murphy
2026-07-16 14:56 ` [PATCH v2 1/4] ACPI/APMT: Use stable device ID Robin Murphy
2026-07-16 15:17 ` sashiko-bot [this message]
2026-07-16 15:33 ` Robin Murphy
2026-07-16 14:56 ` [PATCH v2 2/4] perf/arm_cspmu: Improve APMT-based PMU naming Robin Murphy
2026-07-16 15:15 ` sashiko-bot
2026-07-16 21:13 ` Ilkka Koskinen
2026-07-16 14:56 ` [PATCH v2 3/4] perf/arm_cspmu: Improve sub-module error reporting Robin Murphy
2026-07-16 14:56 ` [PATCH v2 4/4] perf/arm_cspmu: Make IRQ more optional Robin Murphy
2026-07-16 15:11 ` sashiko-bot
2026-07-16 15:27 ` Robin Murphy
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=20260716151706.B13061F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=robin.murphy@arm.com \
--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