Commit bf39d18e authored by Daniel McNeil's avatar Daniel McNeil Committed by Linus Torvalds

[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: default avatarDaniel McNeil <daniel@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d313a47f
...@@ -792,6 +792,12 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, ...@@ -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) | vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC; 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 (flags & MAP_LOCKED) {
if (!capable(CAP_IPC_LOCK)) if (!capable(CAP_IPC_LOCK))
return -EPERM; return -EPERM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment