]> git.hungrycats.org Git - linux/commitdiff
[PATCH] mmap PROT_NONE fix for NX patch
authorDaniel McNeil <daniel@osdl.org>
Fri, 16 Jul 2004 04:52:43 +0000 (21:52 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 16 Jul 2004 04:52:43 +0000 (21:52 -0700)
This works around the current PROT_NONE problem from elf binaries that
do not have the PT_GNU_STACK so that the do not have execute permission.

The problem was that setting "def_flags" to include the VM_EXEC bit for
compatibility reasons would also make PROT_NONE pages executable, which
is obviously not correct.

Signed-off-by: Daniel McNeil <daniel@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/mmap.c

index f23ec33c8b7d5df34af83c7cc446ae963f0542e8..cd8eec6bdb3ab1f10c8826c31d05315495a85896 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -792,6 +792,12 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
        vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
                        mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
 
+       /*
+        * mm->def_flags might have VM_EXEC set, which PROT_NONE does NOT want.
+        */
+       if (prot == PROT_NONE)
+               vm_flags &= ~VM_EXEC;
+
        if (flags & MAP_LOCKED) {
                if (!capable(CAP_IPC_LOCK))
                        return -EPERM;