From: sashiko-bot@kernel.org
To: "Robin Murphy" <robin.murphy@arm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/4] ACPI/APMT: Use stable device ID
Date: Thu, 09 Jul 2026 14:52:36 +0000 [thread overview]
Message-ID: <20260709145236.EAD221F000E9@smtp.kernel.org> (raw)
In-Reply-To: <c113eff51124250fc5798589ce905052046b43b3.1783605641.git.robin.murphy@arm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Unvalidated u32 ACPI node ID is passed to a signed int parameter, causing unintended collisions with platform bus sentinel values and negative sysfs device names.
- [Medium] Lack of collision handling for firmware-supplied IDs causes complete APMT initialization failure on duplicate IDs.
Pre-existing issues:
- [High] Failure to cleanly unregister resources and platform devices on error paths leaks IRQ mappings and creates dangling pointers to unmapped ACPI tables (Use-After-Free).
- [High] Missing structural bounds checking on APMT node length allows infinite loops or out-of-bounds reads.
--
--- Patch [1]: [PATCH 1/4] ACPI/APMT: Use stable device ID ---
commit 5ad772664b7900cfeb996b91d7d0c6ff27d931d6
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, rather than auto numbering dependent on how the table is parsed.
> --- a/drivers/acpi/arm64/apmt.c
> +++ b/drivers/acpi/arm64/apmt.c
> @@ -79,7 +79,7 @@ static int __init apmt_add_platform_device(struct acpi_apmt_node *node,
> int ret, count;
> struct resource res[DEV_MAX_RESOURCE_COUNT];
>
> - pdev = platform_device_alloc(DEV_NAME, PLATFORM_DEVID_AUTO);
> + pdev = platform_device_alloc(DEV_NAME, node->id);
[Severity: High]
Because node->id is a u32 and platform_device_alloc() takes a signed int
for the id parameter, could this cause unintended collisions?
If the firmware provides a large ID like 0xFFFFFFFE, this would be cast to
-2 (PLATFORM_DEVID_AUTO), which seems to defeat the goal of using stable
identifiers by falling back to auto-numbering.
Similarly, a value of 0xFFFFFFFF would become -1 (PLATFORM_DEVID_NONE),
causing the ID to be omitted from the device name entirely, and other large
values would result in negative sysfs device names.
[Severity: Medium]
By relying on the firmware for the ID rather than auto-numbering, is it
possible for duplicate IDs to cause initialization failures?
If firmware provides two APMT nodes with the same id, platform_device_add()
will return -EEXIST. When this propagates up to apmt_init_platform_devices():
apmt_init_platform_devices() {
...
ret = apmt_add_platform_device(apmt_node, fwnode);
if (ret) {
acpi_free_fwnode_static(fwnode);
return ret;
}
...
}
Will this abort the entire APMT initialization and prevent all subsequent
PMUs from being registered?
[Severity: High]
This is a pre-existing issue, but this patch might make it more reachable
if duplicate firmware IDs trigger the error path.
If apmt_add_platform_device() fails, the loop in apmt_init_platform_devices()
returns an error without unregistering the platform devices that were already
successfully added during previous iterations.
When this error propagates to acpi_apmt_init(), it unmaps the table:
acpi_apmt_init() {
...
ret = apmt_init_platform_devices();
if (ret) {
pr_err("Failed to initialize APMT platform devices...\n");
acpi_put_table(apmt_table);
}
}
Since the registered platform devices hold a pointer to the ACPI node in their
platform_data, will unmapping the table leave them with dangling pointers that
could cause a use-after-free when the arm_cspmu driver probes?
Additionally, the error path inside apmt_add_platform_device() does not appear
to call acpi_unregister_gsi() to clean up the IRQ mapped by
apmt_init_resources(), which might leak the GSI mapping.
[Severity: High]
This is another pre-existing issue, but looking at the table parsing loop in
apmt_init_platform_devices():
apmt_init_platform_devices() {
...
offset += apmt_node->length;
...
}
Does the loop inherently trust apmt_node->length without validating it against
the structural bounds? If firmware provides a node with a length of 0, could
this result in an infinite loop during early boot?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1783605641.git.robin.murphy@arm.com?part=1
next prev parent reply other threads:[~2026-07-09 14:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 14:39 [PATCH 0/4] perf/arm_cspmu: Miscellaneous improvements Robin Murphy
2026-07-09 14:39 ` [PATCH 1/4] ACPI/APMT: Use stable device ID Robin Murphy
2026-07-09 14:52 ` sashiko-bot [this message]
2026-07-09 15:31 ` Robin Murphy
2026-07-09 14:39 ` [PATCH 2/4] perf/arm_cspmu: Improve APMT-based PMU naming Robin Murphy
2026-07-09 14:48 ` sashiko-bot
2026-07-09 15:42 ` Robin Murphy
2026-07-09 14:39 ` [PATCH 3/4] perf/arm_cspmu: Improve sub-module error reporting Robin Murphy
2026-07-09 14:39 ` [PATCH 4/4] perf/arm_cspmu: Make IRQ more optional Robin Murphy
2026-07-09 14:49 ` sashiko-bot
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=20260709145236.EAD221F000E9@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