From 7852452429dea364bcc921aefdbbb783d7aa9455 Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Mon, 20 Nov 2023 11:51:28 -0800 Subject: [PATCH] ANDROID: 16K: mlock: __PAGE_ALIGN addr and len In page-compat mode, mlock() syscalls must be at __PAGE_ALIGN-ed addresses and of __PAGE_SIZE-multiple length. Bug: 383389337 Bug: 315325080 Bug: 302403436 Change-Id: Iddc74af7c3f7fbd5051b3f1537155dda513405ad Signed-off-by: Kalesh Singh --- mm/mlock.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/mlock.c b/mm/mlock.c index cde076fa7d5e..817ff7737e52 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "internal.h" @@ -518,8 +519,8 @@ static int apply_vma_lock_flags(unsigned long start, size_t len, struct vm_area_struct *vma, *prev; VMA_ITERATOR(vmi, current->mm, start); - VM_BUG_ON(offset_in_page(start)); - VM_BUG_ON(len != PAGE_ALIGN(len)); + VM_BUG_ON(__offset_in_page_log(start)); + VM_BUG_ON(len != __PAGE_ALIGN(len)); end = start + len; if (end < start) return -EINVAL; @@ -620,8 +621,8 @@ static __must_check int do_mlock(unsigned long start, size_t len, vm_flags_t fla if (!can_do_mlock()) return -EPERM; - len = PAGE_ALIGN(len + (offset_in_page(start))); - start &= PAGE_MASK; + len = __PAGE_ALIGN(len + (__offset_in_page(start))); + start &= __PAGE_MASK; lock_limit = rlimit(RLIMIT_MEMLOCK); lock_limit >>= PAGE_SHIFT; @@ -680,8 +681,8 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len) start = untagged_addr(start); - len = PAGE_ALIGN(len + (offset_in_page(start))); - start &= PAGE_MASK; + len = __PAGE_ALIGN(len + (__offset_in_page(start))); + start &= __PAGE_MASK; if (mmap_write_lock_killable(current->mm)) return -EINTR;