From 9b9b05eabf047942edb8a3c8846fc76b6592d310 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 5 Apr 2022 22:26:37 +0200 Subject: [PATCH] Kernel: Make sys$mmap() round requested VM size to page size multiple This fixes an issue where File::mmap() overrides would fail because they were expecting to be called with a size evenly divisible by PAGE_SIZE. --- Kernel/Syscalls/mmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index 8c95eb9a07..896616cd7f 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -195,7 +195,7 @@ ErrorOr Process::sys$mmap(Userspace use if (map_fixed) TRY(address_space().unmap_mmap_range(VirtualAddress(addr), size)); - Memory::VirtualRange requested_range { VirtualAddress { addr }, size }; + Memory::VirtualRange requested_range { VirtualAddress { addr }, rounded_size }; if (addr && !(map_fixed || map_fixed_noreplace)) { // If there's an address but MAP_FIXED wasn't specified, the address is just a hint. requested_range = { {}, 0 };