From: Ingo Molnar 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 Signed-off-by: Andrew Morton --- 25-akpm/mm/mmap.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff -puN mm/mmap.c~nx-fix-read_implies_exec-related-noexec-fs-breakage mm/mmap.c --- 25/mm/mmap.c~nx-fix-read_implies_exec-related-noexec-fs-breakage 2004-10-03 16:03:11.160490360 -0700 +++ 25-akpm/mm/mmap.c 2004-10-03 16:03:11.164489752 -0700 @@ -786,13 +786,6 @@ unsigned long do_mmap_pgoff(struct file 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; @@ -804,6 +797,15 @@ unsigned long do_mmap_pgoff(struct file (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; _