diff options
author | Daniel McNeil <daniel@osdl.org> | 2004-07-15 21:52:43 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-15 21:52:43 -0700 |
commit | bf39d18e640909b8b88318158bec1450bd178ebd (patch) | |
tree | 9ef98491501bc874e5de8335f7224fe053885ddf /mm | |
parent | d313a47f5bb40a5add4447a9ec46986e82b024de (diff) | |
download | history-bf39d18e640909b8b88318158bec1450bd178ebd.tar.gz |
[PATCH] mmap PROT_NONE fix for NX patch
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>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index f23ec33c8b7d5d..cd8eec6bdb3ab1 100644 --- 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; |