ANDROID: 16K: munmap: __PAGE_ALIGN addr and len

In page-compat mode, munmap() syscalls must be at __PAGE_ALIGN-ed
addresses and of __PAGE_SIZE-multiple length.

Note: These checks are only added in the syscall and not in the usual
__do_vmi_munmap(). This is becuase we need to allow the kernel to
mmap() to handle filemap faults in the case of an emulated page size.
Unaligned mmap() implicitly means we need to also allow the kernel to
perform  unaligned munmaps():

    do_mmap()
        map_region()
            do_munmap()
                do_vmi_munmap()

Bug: 383389337
Bug: 315325080
Bug: 302403436
Change-Id: I97d207d0582467c4031ac986f534ef8e79ad5f45
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2023-11-10 02:06:58 -08:00
committed by Carlos Llamas
parent a9e38ff89a
commit 397425965f

View File

@@ -1667,6 +1667,12 @@ EXPORT_SYMBOL(vm_munmap);
SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
{
addr = untagged_addr(addr);
if (!__PAGE_ALIGNED(addr))
return -EINVAL;
len = __PAGE_ALIGN(len);
profile_munmap(addr);
return __vm_munmap(addr, len, true);
}