From 58392dbd53fc19f6b2f4166d8fc1078236ab0bfb Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 4 Dec 2003 06:26:06 -0800 Subject: [PATCH] [PATCH] Fix 'noexec' behaviour We should not allow mmap() with PROT_EXEC on mounts marked "noexec", since otherwise there is no way for user-supplied executable loaders (like ld.so and emulator environments) to properly honour the "noexec"ness of the target. --- mm/mmap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index 72f25b7fef6c6..7a3a68e52afeb 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -477,6 +478,9 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, if (file && (!file->f_op || !file->f_op->mmap)) return -ENODEV; + if ((prot & PROT_EXEC) && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)) + return -EPERM; + if (!len) return addr; -- 2.53.0