* [PATCH v2 1/2] iio: light: cm32181: validate ACPI object type in cm32181_acpi_get_cpm()
2026-10-26 14:20 [PATCH v2 0/2] iio: validate ACPI object types before package access Tristan Madani
@ 2026-10-26 14:20 ` Tristan Madani
2026-10-26 14:20 ` [PATCH v2 2/2] iio: imu: inv_mpu6050: validate ACPI object types in asus_acpi_get_sensor_info() Tristan Madani
1 sibling, 0 replies; 3+ messages in thread
From: Tristan Madani @ 2026-10-26 14:20 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Lars-Peter Clausen, Kevin Tsai, Jean-Baptiste Maneyrol,
David Lechner, Nuno Sa, Andy Shevchenko, Hans de Goede,
Srinivas Pandruvada, linux-iio, linux-kernel, stable,
Tristan Madani
From: Tristan Madani <tristan@talencesecurity.com>
cm32181_acpi_get_cpm() accesses cpm->package.count and
cpm->package.elements without checking that the returned ACPI object
is of type ACPI_TYPE_PACKAGE. If firmware returns a different type,
the package union members alias onto unrelated data.
Use acpi_evaluate_object_typed() to request an ACPI_TYPE_PACKAGE
directly, so the ACPI core validates the type before returning.
Also replace kfree() with ACPI_FREE() for the ACPI-allocated buffer.
Fixes: d34ca613b939 ("iio: light: cm32181: Add support for parsing CPM0 and CPM1 ACPI tables")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/iio/light/cm32181.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index b32a94028f091e..8d00486af608c9 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -114,7 +114,8 @@ static int cm32181_acpi_get_cpm(struct device *dev, char *obj_name,
if (!handle)
return -ENODEV;
- status = acpi_evaluate_object(handle, obj_name, NULL, &buffer);
+ status = acpi_evaluate_object_typed(handle, obj_name, NULL, &buffer,
+ ACPI_TYPE_PACKAGE);
if (ACPI_FAILURE(status)) {
dev_err(dev, "object %s not found\n", obj_name);
return -ENODEV;
@@ -131,7 +132,7 @@ static int cm32181_acpi_get_cpm(struct device *dev, char *obj_name,
values[i] = elem->integer.value;
}
- kfree(buffer.pointer);
+ ACPI_FREE(buffer.pointer);
return count;
}
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v2 2/2] iio: imu: inv_mpu6050: validate ACPI object types in asus_acpi_get_sensor_info()
2026-10-26 14:20 [PATCH v2 0/2] iio: validate ACPI object types before package access Tristan Madani
2026-10-26 14:20 ` [PATCH v2 1/2] iio: light: cm32181: validate ACPI object type in cm32181_acpi_get_cpm() Tristan Madani
@ 2026-10-26 14:20 ` Tristan Madani
1 sibling, 0 replies; 3+ messages in thread
From: Tristan Madani @ 2026-10-26 14:20 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Lars-Peter Clausen, Kevin Tsai, Jean-Baptiste Maneyrol,
David Lechner, Nuno Sa, Andy Shevchenko, Hans de Goede,
Srinivas Pandruvada, linux-iio, linux-kernel, stable,
Tristan Madani
From: Tristan Madani <tristan@talencesecurity.com>
asus_acpi_get_sensor_info() iterates through a nested ACPI package
structure without checking types at either level. The outer object
returned by acpi_evaluate_object() and each inner element must be
validated as ACPI_TYPE_PACKAGE before accessing their package.count
and package.elements members.
Use acpi_evaluate_object_typed() to validate the outer object type
at evaluation time. Add a type check for each inner element before
accessing its package contents. Also replace kfree() with
ACPI_FREE() for the ACPI-allocated buffer.
Fixes: a35c5d1aa96a ("iio: imu: inv_mpu6050: Create mux clients for ACPI")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
index 460792ed27e031..e5ffa0d5f6b1a2 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
@@ -52,7 +52,8 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
union acpi_object *cpm;
int ret;
- status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer);
+ status = acpi_evaluate_object_typed(adev->handle, "CNF0", NULL,
+ &buffer, ACPI_TYPE_PACKAGE);
if (ACPI_FAILURE(status))
return -ENODEV;
@@ -62,6 +63,8 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
int j;
elem = &cpm->package.elements[i];
+ if (elem->type != ACPI_TYPE_PACKAGE)
+ continue;
for (j = 0; j < elem->package.count; ++j) {
union acpi_object *sub_elem;
@@ -78,7 +81,7 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
}
}
ret = cpm->package.count;
- kfree(buffer.pointer);
+ ACPI_FREE(buffer.pointer);
return ret;
}
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread