Commit ea7f7a07 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] NX: fix read_implies_exec() related noexec-fs breakage

mmap() done from older !pt_gnu_stack binaries on noexec mounted filesystems
could fail due to the extra PROT_EXEC bit.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 658591af
......@@ -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;
......
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