@@ -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;