Kernel: Allow munmap on non-page aligned address

This commit is contained in:
Bananymous 2025-11-10 03:53:34 +02:00
parent f1d12c330e
commit a39aa73e21
1 changed files with 6 additions and 3 deletions

View File

@ -2326,9 +2326,12 @@ namespace Kernel
if (len == 0) if (len == 0)
return BAN::Error::from_errno(EINVAL); return BAN::Error::from_errno(EINVAL);
const vaddr_t vaddr = reinterpret_cast<vaddr_t>(addr); vaddr_t vaddr = reinterpret_cast<vaddr_t>(addr);
if (vaddr % PAGE_SIZE != 0) if (auto rem = vaddr % PAGE_SIZE)
return BAN::Error::from_errno(EINVAL); {
vaddr -= rem;
len += PAGE_SIZE - rem;
}
if (auto rem = len % PAGE_SIZE) if (auto rem = len % PAGE_SIZE)
len += PAGE_SIZE - rem; len += PAGE_SIZE - rem;