From f072d8f9d7a1a41e1fe38990ab8a9d1606e2b0e5 Mon Sep 17 00:00:00 2001 From: Marcus Weiner Date: Sun, 10 Sep 2023 16:02:10 +0200 Subject: [PATCH] Check page table bounds Signed-off-by: Marcus Weiner --- riscv64/src/mem.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/riscv64/src/mem.rs b/riscv64/src/mem.rs index 6431a0c..be3ac9b 100644 --- a/riscv64/src/mem.rs +++ b/riscv64/src/mem.rs @@ -86,6 +86,7 @@ impl PageTable { } pub fn dump_entry(&self, at: u16) -> PageTableEntry { + assert!(at < 512, "index out of range: page tables always have 512 entries"); let addr = self.addr + (at as u64 * Self::ENTRY_SIZE); let val = unsafe { read_volatile(addr as *const u64) }; val.into()