lkml.org 
[lkml]   [2022]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ACPICA: proactively check null ptr to avoid API misuse
Date
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.

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
drivers/acpi/acpica/nswalk.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 915c2433463d..9ae45db16d86 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -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
\
 
 \ /
  Last update: 2022-02-16 07:27    [W:0.050 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site