From 2d3fed3a43390ded98cf75be48b8c16cf65af1b6 Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Fri, 17 Nov 2023 09:42:19 -0800 Subject: [PATCH] ANDROID: 16K: mprotect: __PAGE_ALIGN addr and len In page-compat mode, mprotect() syscalls must be at __PAGE_ALIGN-ed addresses and of __PAGE_SIZE-multiple length. Bug: 383389337 Bug: 315325080 Bug: 302403436 Change-Id: I5ece654ea921cad692af0d3aa7dba422f54d08b8 Signed-off-by: Kalesh Singh --- mm/mprotect.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/mprotect.c b/mm/mprotect.c index 516b1d847e2c..0d37a7308cd9 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -726,11 +727,11 @@ static int do_mprotect_pkey(unsigned long start, size_t len, if (grows == (PROT_GROWSDOWN|PROT_GROWSUP)) /* can't be both */ return -EINVAL; - if (start & ~PAGE_MASK) + if (!__PAGE_ALIGNED(start)) return -EINVAL; if (!len) return 0; - len = PAGE_ALIGN(len); + len = __PAGE_ALIGN(len); end = start + len; if (end <= start) return -ENOMEM;