]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Fix 'noexec' behaviour
authorUlrich Drepper <drepper@redhat.com>
Thu, 4 Dec 2003 14:26:06 +0000 (06:26 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 4 Dec 2003 14:26:06 +0000 (06:26 -0800)
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

index 72f25b7fef6c6003daab757951d496c7033f5128..7a3a68e52afebcd072155a523a161acb51b45239 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -19,6 +19,7 @@
 #include <linux/hugetlb.h>
 #include <linux/profile.h>
 #include <linux/module.h>
+#include <linux/mount.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgalloc.h>
@@ -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;