ACPICA: proactively check null ptr to avoid API misuse
Subsystems (2)
PATCH 1/1 ACPICA: proactively check null ptr to avoid API misuse
There are some cases that user use acpi_ns_walk_namespace() without checking acpi_disable flag. When acpi=off is provided in boot cmdline, acpi_gbl_root_node is NULL and calling acpi_ns_walk_namespace() will crash kernel. In order to avoid such misuse, we proactively check null ptr and return an error when we know ACPI is disabled.
--- drivers/acpi/acpica/nswalk.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/acpica/nswalk.c +7 -0
@@ -171,6 +171,13 @@ acpi_ns_walk_namespace(acpi_object_type type, start_node = acpi_gbl_root_node; } +/* acpi_gbl_root_node is NULL when acpi=off is provided. +* We proactively check nulliness here and return an error if user call +* this function without checking acpi_disabled +*/ +if (start_node ==NULL ) +return_ACPI_STATUS (AE_ERROR ); +/* Null child means "get first node" */ parent_node = start_node;
Signature · 1 line
2.25.1
Rafael J. Wysocki
maintainerQuoted 6 lines · Tong Zhang
There are some cases that user use
acpi_ns_walk_namespace()without checkingacpi_disableflag. When acpi=off is provided in boot cmdline,acpi_gbl_root_nodeis NULL and callingacpi_ns_walk_namespace()will crash kernel. In order to avoid such misuse, we proactively check null ptr and return an error when we know ACPI is disabled.
The issue should be fixed by this commit in the upstream ACPICA code
base: https://github.com/acpica/acpica/commit/b1c3656ef4950098e530be68d4b589584f06cddc
Quoted 27 lines
Signed-off-by Tong Zhang <ztong0001(a)gmail.com>--- drivers/acpi/acpica/nswalk.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/acpi/acpica/nswalk.c +7
-1@@ -171,6 +171,13 @@ acpi_ns_walk_namespace(acpi_object_type type, start_node = acpi_gbl_root_node; } +/* acpi_gbl_root_node is NULL when acpi=off is provided. +* We proactively check nulliness here and return an error if user call +* this function without checking acpi_disabled +*/ +if (start_node ==NULL ) +return_ACPI_STATUS (AE_ERROR ); +/* Null child means "get first node" */ parent_node = start_node; --2.25.1
Quoted 12 lines · Rafael J. Wysocki
Quoted 6 lines · Tong Zhang
There are some cases that user use
acpi_ns_walk_namespace()without checkingacpi_disableflag. When acpi=off is provided in boot cmdline,acpi_gbl_root_nodeis NULL and callingacpi_ns_walk_namespace()will crash kernel. In order to avoid such misuse, we proactively check null ptr and return an error when we know ACPI is disabled.The issue should be fixed by this commit in the upstream ACPICA code
base: https://github.com/acpica/acpica/commit/b1c3656ef4950098e530be68d4b589584f06cddc
Thank you Rafael. I've just seen that commit upstream.