* [PATCH] ACPICA: proactively check null ptr to avoid API misuse
@ 2022-02-16 6:26 Tong Zhang
2022-02-16 12:22 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Tong Zhang @ 2022-02-16 6:26 UTC (permalink / raw)
To: Robert Moore, Rafael J. Wysocki, Len Brown, linux-acpi, devel,
linux-kernel
Cc: Tong Zhang
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPICA: proactively check null ptr to avoid API misuse
2022-02-16 6:26 [PATCH] ACPICA: proactively check null ptr to avoid API misuse Tong Zhang
@ 2022-02-16 12:22 ` Rafael J. Wysocki
2022-02-16 16:37 ` Tong Zhang
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-02-16 12:22 UTC (permalink / raw)
To: Tong Zhang
Cc: Robert Moore, Rafael J. Wysocki, Len Brown,
ACPI Devel Maling List,
open list:ACPI COMPONENT ARCHITECTURE (ACPICA),
Linux Kernel Mailing List
On Wed, Feb 16, 2022 at 7:26 AM Tong Zhang <ztong0001@gmail.com> wrote:
>
> 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.
The issue should be fixed by this commit in the upstream ACPICA code
base: https://github.com/acpica/acpica/commit/b1c3656ef4950098e530be68d4b589584f06cddc
>
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPICA: proactively check null ptr to avoid API misuse
2022-02-16 12:22 ` Rafael J. Wysocki
@ 2022-02-16 16:37 ` Tong Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Tong Zhang @ 2022-02-16 16:37 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Robert Moore, Rafael J. Wysocki, Len Brown,
ACPI Devel Maling List,
open list:ACPI COMPONENT ARCHITECTURE (ACPICA),
Linux Kernel Mailing List
On Wed, Feb 16, 2022 at 4:22 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Wed, Feb 16, 2022 at 7:26 AM Tong Zhang <ztong0001@gmail.com> wrote:
> >
> > 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.
>
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-16 16:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 6:26 [PATCH] ACPICA: proactively check null ptr to avoid API misuse Tong Zhang
2022-02-16 12:22 ` Rafael J. Wysocki
2022-02-16 16:37 ` Tong Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).