diff options
author | Ingo Molnar <mingo@elte.hu> | 2004-10-06 04:16:18 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-10-06 04:16:18 -0700 |
commit | ea7f7a07e901cbd7ab4d12d77e5e37dc5d974eff (patch) | |
tree | 6c5e140f7a47c965857ce24e1867d2bd70fc23da /mm | |
parent | 658591af2f5d89d880b7ea3101e9626225729544 (diff) | |
download | history-ea7f7a07e901cbd7ab4d12d77e5e37dc5d974eff.tar.gz |
[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: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index 4bd891b1bea0a4..8ccbb00c208fff 100644 --- 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; |