:: commit 81624fce25136947eaf6bed90f53b83873692af9

Mintsuki <mintsuki@protonmail.com> — 2026-01-12 21:26

parents: 94c7ffaa39

smp: Add MADT GIC entry size validation on AArch64

diff --git a/common/sys/smp.c b/common/sys/smp.c
index 5ffbdb01..cb7e1c09 100644
--- a/common/sys/smp.c
+++ b/common/sys/smp.c
@@ -481,6 +481,9 @@ static struct limine_mp_info *try_acpi_smp(size_t   *cpu_count,
         switch (*madt_ptr) {
             case 11: {
                 // GIC CPU Interface
+                if (*(madt_ptr + 1) < sizeof(struct madt_gicc))
+                    continue;
+
                 struct madt_gicc *gicc = (void *)madt_ptr;
 
                 // Check if we can actually try to start the AP
@@ -502,6 +505,9 @@ static struct limine_mp_info *try_acpi_smp(size_t   *cpu_count,
         switch (*madt_ptr) {
             case 11: {
                 // GIC CPU Interface
+                if (*(madt_ptr + 1) < sizeof(struct madt_gicc))
+                    continue;
+
                 struct madt_gicc *gicc = (void *)madt_ptr;
 
                 // Check if we can actually try to start the AP
tab: 248 wrap: offon