From: Linus Torvalds Date: Sat, 6 Dec 2003 06:34:40 +0000 (-0800) Subject: Fix the PROT_EXEC breakage on anonymous mmap. X-Git-Tag: v2.6.0~21 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=8255b24478d1f83818bc48dc6a5d97828f4a1979;p=history.git Fix the PROT_EXEC breakage on anonymous mmap. Clean up the tests while at it. --- diff --git a/mm/mmap.c b/mm/mmap.c index 7a3a68e52afe..5b2e70ba6450 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -475,11 +475,13 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, struct rb_node ** rb_link, * rb_parent; unsigned long charged = 0; - if (file && (!file->f_op || !file->f_op->mmap)) - return -ENODEV; + if (file) { + if (!file->f_op || !file->f_op->mmap) + return -ENODEV; - if ((prot & PROT_EXEC) && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)) - return -EPERM; + if ((prot & PROT_EXEC) && (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)) + return -EPERM; + } if (!len) return addr;