kernel: Make sure addresses allocated by mmap() are ALWAYS page-aligned
All checks were successful
continuous-integration/drone/push Build is passing

Fixes a kernel crash. Thanks a lot, sysfuzz!
This commit is contained in:
apio 2023-06-18 20:29:32 +02:00
parent 04322d9ff7
commit 36e6787415
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -41,9 +41,9 @@ Result<u64> sys_mmap(Registers*, SyscallArgs args)
else
{
// FIXME: We should be more flexible if MAP_FIXED was not specified.
if (!TRY(current->vm_allocator->test_and_alloc_region((u64)addr, get_blocks_from_size(len, ARCH_PAGE_SIZE))))
address = align_down<ARCH_PAGE_SIZE>((u64)addr);
if (!TRY(current->vm_allocator->test_and_alloc_region(address, get_blocks_from_size(len, ARCH_PAGE_SIZE))))
return err(ENOMEM);
address = (u64)addr;
}
int mmu_flags = MMU::User | MMU::NoExecute;