:: commit bb4f6c4c9f92df56f7ee0400c4fee5f30d5a14ab

Mintsuki <mintsuki@protonmail.com> — 2026-04-01 20:32

parents: 01186e2051

mm/pmm: Add bounds check to UEFI memory map import loop

diff --git a/common/mm/pmm.s2.c b/common/mm/pmm.s2.c
index da7c025c..665d9906 100644
--- a/common/mm/pmm.s2.c
+++ b/common/mm/pmm.s2.c
@@ -387,6 +387,10 @@ void init_memmap(void) {
         uint64_t base = entry->PhysicalStart;
         uint64_t length = CHECKED_MUL(entry->NumberOfPages, (uint64_t)4096, continue);
 
+        if (memmap_entries == memmap_max_entries) {
+            panic(false, "Memory map exhausted.");
+        }
+
         memmap[memmap_entries].base = base;
         memmap[memmap_entries].length = length;
         memmap[memmap_entries].type = our_type;
tab: 248 wrap: offon