]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
kern/acpi: Fix out of bounds access in grub_acpi_xsdt_find_table()
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 16 Oct 2024 05:20:24 +0000 (16:20 +1100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 31 Oct 2024 15:04:00 +0000 (16:04 +0100)
The calculation of the size of the table was incorrect (copy/pasta from
grub_acpi_rsdt_find_table() I assume...). The entries are 64-bit long.

This causes us to access beyond the end of the table which is causing
crashes during boot on some systems. Typically this is causing a crash
on VMWare when using UEFI and enabling serial autodetection, as

  grub_acpi_find_table (GRUB_ACPI_SPCR_SIGNATURE);

will goes past the end of the table (the SPCR table doesn't exits).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
Tested-by: Renata Ravanelli <rravanel@redhat.com>
grub-core/kern/acpi.c

index 48ded4e2ea6ec8992446a15df6f59e1a998298a2..8ff0835d501f37118a1683d2e00800cd0ff5ca53 100644 (file)
@@ -75,7 +75,7 @@ grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig)
     return 0;
 
   ptr = (grub_unaligned_uint64_t *) (xsdt + 1);
-  s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t);
+  s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint64_t);
   for (; s; s--, ptr++)
     {
       struct grub_acpi_table_header *tbl;