[PATCH v2 01/15] ACPI: CPPC: Validate the _CPC package header

From: Christian Loehle

Date: Sat Aug 08 2026 - 04:28:23 EST


The _CPC NumEntries field includes every package element, including
NumEntries and Revision. acpi_cppc_processor_probe() nevertheless reads
those first two elements before checking that they exist and trusts
NumEntries when walking the remaining elements.

Reject packages with fewer than two elements and require NumEntries to
match the package count before accessing Revision or iterating over the
register descriptors.

Revision is specified as a BYTE, but the parser assigns its 64-bit AML
Integer to an unsigned int before validating it. Reject values above
U8_MAX before conversion so, for example, 0x100000004 cannot truncate to
revision 4.

Fixes: 337aadff8e45 ("ACPI: Introduce CPU performance controls using CPPC")
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Link: https://sashiko.dev/#/patchset/20260724134251.1632824-1-christian.loehle%40arm.com
Signed-off-by: Christian Loehle <christian.loehle@xxxxxxx>
---
drivers/acpi/cppc_acpi.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 2f7c09552566..a3a203f8e816 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -793,6 +793,11 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
}

out_obj = (union acpi_object *) output.pointer;
+ if (out_obj->package.count < 2) {
+ pr_debug("Unexpected _CPC package count (%u) for CPU:%d\n",
+ out_obj->package.count, pr->id);
+ goto out_buf_free;
+ }

cpc_ptr = kzalloc_obj(struct cpc_desc);
if (!cpc_ptr) {
@@ -803,12 +808,14 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
/* First entry is NumEntries. */
cpc_obj = &out_obj->package.elements[0];
if (cpc_obj->type == ACPI_TYPE_INTEGER) {
- num_ent = cpc_obj->integer.value;
- if (num_ent <= 1) {
- pr_debug("Unexpected _CPC NumEntries value (%d) for CPU:%d\n",
- num_ent, pr->id);
+ if (cpc_obj->integer.value != out_obj->package.count) {
+ pr_debug("_CPC NumEntries (%llu) does not match package count (%u) for CPU:%d\n",
+ cpc_obj->integer.value, out_obj->package.count,
+ pr->id);
goto out_free;
}
+
+ num_ent = out_obj->package.count;
} else {
pr_debug("Unexpected _CPC NumEntries entry type (%d) for CPU:%d\n",
cpc_obj->type, pr->id);
@@ -818,6 +825,12 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
/* Second entry should be revision. */
cpc_obj = &out_obj->package.elements[1];
if (cpc_obj->type == ACPI_TYPE_INTEGER) {
+ if (cpc_obj->integer.value > U8_MAX) {
+ pr_debug("Invalid _CPC Revision (%llu) for CPU:%d\n",
+ cpc_obj->integer.value, pr->id);
+ ret = -EINVAL;
+ goto out_free;
+ }
cpc_rev = cpc_obj->integer.value;
} else {
pr_debug("Unexpected _CPC Revision entry type (%d) for CPU:%d\n",
--
2.34.1