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.
This commit is contained in:
apio 2023-08-07 22:49:00 +02:00
parent 10c892d606
commit 097353e779
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -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;
}