platform/x86: acer-wmi: validate ACPI object type in acer_gsensor_event()
Subsystems (3)
PATCH 1/1 platform/x86: acer-wmi: validate ACPI object type in acer_gsensor_event()
From: Tristan Madani <[email protected]>
acer_gsensor_event() accesses the ACPI evaluation result as a package without first verifying the object type. If the firmware returns a non-package type, the code reads package.count and package.elements from the wrong union member, which can cause a NULL pointer dereference or read from an invalid address.
Add a type check for ACPI_TYPE_PACKAGE before accessing the package fields, and validate that each element is ACPI_TYPE_INTEGER before reading integer.value.
Fixes 1eb3fe1d3b6b ("ACER: Add support for accelerometer sensor")
Signed-off-by Tristan Madani <[email protected]>
--- drivers/platform/x86/acer-wmi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +6 -1
@@ -2043,7 +2043,12 @@ static int acer_gsensor_event(void)if (ACPI_FAILURE (status))return -1 ; -if (out_obj->package.count !=4 ) +if (out_obj->type !=ACPI_TYPE_PACKAGE || out_obj->package.count !=4 ) +return -1 ; + +if (out_obj->package.elements[0 ].type !=ACPI_TYPE_INTEGER || + out_obj->package.elements[1 ].type !=ACPI_TYPE_INTEGER || + out_obj->package.elements[2 ].type !=ACPI_TYPE_INTEGER )return -1 ; input_report_abs(acer_wmi_accel_dev, ABS_X,
Signature · 1 line
2.47.3