From 097353e77925804e1075262d95c81819b0eb9f5f Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 7 Aug 2023 22:49:00 +0200 Subject: [PATCH] kernel: Properly check memory bounds while touching user memory Before this patch, one byte of each page was being accessed without checking the page's permissions. --- kernel/src/memory/MemoryManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index 2c86a8b8..d597f397 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -562,7 +562,7 @@ namespace MemoryManager while (size--) { // Crossed a page boundary, gotta check the page tables again before touching any memory!! - if (user_ptr % ARCH_PAGE_SIZE) + if ((user_ptr % ARCH_PAGE_SIZE) == 0) { if (!validate_page_access(user_ptr, MMU::ReadWrite | MMU::User)) return false; } @@ -590,7 +590,7 @@ namespace MemoryManager while (size--) { // Crossed a page boundary, gotta check the page tables again before touching any memory!! - if (user_ptr % ARCH_PAGE_SIZE) + if ((user_ptr % ARCH_PAGE_SIZE) == 0) { if (!validate_page_access(user_ptr, MMU::User)) return false; }