]> git.hungrycats.org Git - linux/commitdiff
[PATCH] NX: fix read_implies_exec() related noexec-fs breakage
authorIngo Molnar <mingo@elte.hu>
Wed, 6 Oct 2004 11:16:18 +0000 (04:16 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 6 Oct 2004 11:16:18 +0000 (04:16 -0700)
mmap() done from older !pt_gnu_stack binaries on noexec mounted filesystems
could fail due to the extra PROT_EXEC bit.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/mmap.c

index 4bd891b1bea0a4de3fc5a05f6c7d7b6519f1ef93..8ccbb00c208ffff415bdd825751dcda94bfb9fc6 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -773,13 +773,6 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
        int accountable = 1;
        unsigned long charged = 0;
 
-       /*
-        * Does the application expect PROT_READ to imply PROT_EXEC:
-        */
-       if (unlikely((prot & PROT_READ) &&
-                       (current->personality & READ_IMPLIES_EXEC)))
-               prot |= PROT_EXEC;
-
        if (file) {
                if (is_file_hugepages(file))
                        accountable = 0;
@@ -791,6 +784,15 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
                    (file->f_vfsmnt->mnt_flags & MNT_NOEXEC))
                        return -EPERM;
        }
+       /*
+        * Does the application expect PROT_READ to imply PROT_EXEC?
+        *
+        * (the exception is when the underlying filesystem is noexec
+        *  mounted, in which case we dont add PROT_EXEC.)
+        */
+       if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
+               if (!(file && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)))
+                       prot |= PROT_EXEC;
 
        if (!len)
                return addr;