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.
This commit is contained in:
Andreas Kling 2022-04-05 22:26:37 +02:00
parent e465b59ca4
commit 9b9b05eabf
Notes: sideshowbarker 2024-07-17 14:24:21 +09:00

View file

@ -195,7 +195,7 @@ ErrorOr<FlatPtr> Process::sys$mmap(Userspace<Syscall::SC_mmap_params const*> 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 };