Re: [PATCH] ACPICA: fix NULL pointer dereference in acpi_ns_custom_package()

"Rafael J. Wysocki" <[email protected]>
Newsgroups dev.linux.lists.acpica-devel,org.kernel.vger.linux-acpi
Message-ID <CAJZ5v0gFizazkso9TXc1eu46=g6ht77z1Q00Aps-z9RKAnOZew@mail.gmail.com>
On Sun, Mar 22, 2026 at 4:36 PM Weiming Shi <[email protected]> wrote:
>
> acpi_ns_custom_package() unconditionally dereferences the first element
> of the package to read the _BIX version number, without checking for
> NULL:
>
>   if ((*elements)->common.type != ACPI_TYPE_INTEGER)
>
> When firmware returns a _BIX package whose first element is an
> unresolvable reference, ACPICA evaluates that entry to NULL.
> acpi_ns_remove_null_elements() does not strip NULL entries for
> ACPI_PTYPE_CUSTOM packages (fixed-position format would break if
> elements were shifted), so acpi_ns_custom_package() sees the NULL
> and panics.
>
>  general protection fault, probably for non-canonical address
>  0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI
>  KASAN: null-ptr-deref in range
>  [0x0000000000000008-0x000000000000000f]
>  RIP: acpi_ns_check_package
>  (drivers/acpi/acpica/nsprepkg.c:634
>   drivers/acpi/acpica/nsprepkg.c:110)
>  Call Trace:
>   <TASK>
>   acpi_ns_check_return_value (nspredef.c:136)
>   acpi_ns_evaluate (nseval.c:266)
>   acpi_evaluate_object (nsxfeval.c:360)
>   acpi_battery_get_info (battery.c:537)
>   acpi_battery_update (battery.c:1007)
>   acpi_battery_add (battery.c:1237)
>   acpi_device_probe (bus.c:1076)
>   really_probe (dd.c:659)
>   </TASK>
>
> Add a NULL check for the first element (version field) before
> dereferencing it. The battery probe then fails gracefully with
> AE_AML_OPERAND_TYPE instead of crashing the kernel.
>
> Required CONFIG: CONFIG_ACPI_BATTERY=y
>
> Fixes: 7952d40240855932 ("ACPICA: ACPI 6.0: Update _BIX support for new package element")
> Reported-by: Xiang Mei <[email protected]>
> Signed-off-by: Weiming Shi <[email protected]>
> ---
>  drivers/acpi/acpica/nsprepkg.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c
> index ca137ce5674f..c32770570120 100644
> --- a/drivers/acpi/acpica/nsprepkg.c
> +++ b/drivers/acpi/acpica/nsprepkg.c
> @@ -631,6 +631,13 @@ acpi_ns_custom_package(struct acpi_evaluate_info *info,
>
>         /* Get version number, must be Integer */
>
> +       if (!(*elements)) {
> +               ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
> +                                     info->node_flags,
> +                                     "Return Package has a NULL version element"));
> +               return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
> +       }
> +
>         if ((*elements)->common.type != ACPI_TYPE_INTEGER) {
>                 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
>                                       info->node_flags,
> --

ACPICA changes need to be routed via upstream ACPICA project on GitHub.

Please see Documentation/driver-api/acpi/linuxized-acpica.rst
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.