[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230519011915.846407-4-jeffxu@chromium.org>
Date: Fri, 19 May 2023 01:19:11 +0000
From: jeffxu@...omium.org
To: dave.hansen@...el.com, luto@...nel.org, jorgelo@...omium.org,
keescook@...omium.org, groeck@...omium.org, jannh@...gle.com,
sroettger@...gle.com
Cc: akpm@...ux-foundation.org, jeffxu@...gle.com,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-mm@...ck.org, linux-hardening@...r.kernel.org
Subject: [PATCH v1 3/6] PKEY: Apply PKEY_ENFORCE_API to mprotect
From: Jeff Xu <jeffxu@...gle.com>
This patch enables PKEY_ENFORCE_API for the mprotect and
mprotect_pkey syscalls.
Signed-off-by: Jeff Xu<jeffxu@...gle.com>
---
mm/mprotect.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 8a68fdca8487..1db30b8baac3 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -794,6 +794,17 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
}
}
+ /*
+ * arch_check_pkey_enforce_api checks if current thread
+ * has the PKEY permission to modify the memory mapping.
+ * Note: this should only apply to the cases that do_mprotect_pkey
+ * is called from syscall entry. Ref. to munmap for other cases.
+ */
+ if (arch_check_pkey_enforce_api(current->mm, start, end) < 0) {
+ error = -EACCES;
+ goto out;
+ }
+
prev = vma_prev(&vmi);
if (start > vma->vm_start)
prev = vma;
--
2.40.1.606.ga4b1b128d6-goog
Powered by blists - more mailing lists