【BUG】grub2 serial module coredump
Hello, I recently discovered a bug.
When using the serial module in the grub shell, there was no response from the grub shell, and it is initially suspected to be a core dump.
Through debugging analysis of grub-core/kern/acpi.c, grub2 crashed after grub_memcmp (tbl ->signature, sig, 4) in grub-acpi_xsdt_find_table().
tbl ->Signature obtained an address that exceeded expectations.
In 64 bit XSDT, perhaps the loop variable s should be more appropriate by dividing by grub_uinit64_t?
For example,
grub-core/kern/acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/acpi.c +0 -0
index 48ded4e2e..8ff0835d5 100644
--- a/grub-core/kern/acpi.c
+++ b/grub-core/kern/acpi.c
@@ -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;Signature · 8 lines
Hardware platform where the problem occurred: x86_64 UEFI platform, CPU: Haiguang、ZhaoXin Do you have any better suggestions to solve the current problem? Thanks!
From 78925f9b4478f818f0eafb8d2942e9a34ef6360c Mon Sep 17 00:00:00 2001
From: yueyuankun <[email protected]>
Date: Fri, 5 Jul 2024 14:43:06 +0800
Subject: [PATCH] Fix tbl ->signature taking address beyond expected on x86_64
UEFI XSDT platform
--- grub-core/kern/acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/kern/acpi.c +1 -1
@@ -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;
Signature · 1 line
2.43.0
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel