@@ -32,6 +32,7 @@
#include <linux/sched/sysctl.h>
#include <linux/userfaultfd_k.h>
#include <linux/memory-tiers.h>
+#include <uapi/linux/mman.h>
#include <asm/cacheflush.h>
#include <asm/mmu_context.h>
#include <asm/tlbflush.h>
@@ -753,6 +754,20 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
}
}
+ /*
+ * do_mprotect_pkey() currently called from two places:
+ * SYSCALL_DEFINE3(mprotect,...)
+ * SYSCALL_DEFINE4(pkey_mprotect, ...)
+ * and not from other places.
+ * Therefore, omit changing the signature of do_mprotect_pkey().
+ * Otherwise, we might need to add checkSeals and pass it
+ * from all callers of do_mprotect_pkey().
+ */
+ if (!can_modify_mm(current->mm, start, end, MM_SEAL_MPROTECT)) {
+ error = -EACCES;
+ goto out;
+ }
+
prev = vma_prev(&vmi);
if (start > vma->vm_start)
prev = vma;