diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-15 17:09:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-15 17:09:55 -0400 |
commit | 80c5606c3b45e0176c32d3108ade1e1cb0b954f3 (patch) | |
tree | 441944cc1c2e47e2d34cabb5313c25e03f3284d3 /mm/mmap.c | |
parent | a7a0d86f5aa40a2215e36fe21d7911cf718ba428 (diff) |
Fix VM_MAYEXEC calculation
.. and clean up the file mapping code while at it. No point in having a
"if (file)" repeated twice, and generally doing similar checks in two
different sections of the same code
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -900,17 +900,6 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, | |||
900 | int accountable = 1; | 900 | int accountable = 1; |
901 | unsigned long charged = 0, reqprot = prot; | 901 | unsigned long charged = 0, reqprot = prot; |
902 | 902 | ||
903 | if (file) { | ||
904 | if (is_file_hugepages(file)) | ||
905 | accountable = 0; | ||
906 | |||
907 | if (!file->f_op || !file->f_op->mmap) | ||
908 | return -ENODEV; | ||
909 | |||
910 | if ((prot & PROT_EXEC) && | ||
911 | (file->f_vfsmnt->mnt_flags & MNT_NOEXEC)) | ||
912 | return -EPERM; | ||
913 | } | ||
914 | /* | 903 | /* |
915 | * Does the application expect PROT_READ to imply PROT_EXEC? | 904 | * Does the application expect PROT_READ to imply PROT_EXEC? |
916 | * | 905 | * |
@@ -1000,6 +989,16 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, | |||
1000 | case MAP_PRIVATE: | 989 | case MAP_PRIVATE: |
1001 | if (!(file->f_mode & FMODE_READ)) | 990 | if (!(file->f_mode & FMODE_READ)) |
1002 | return -EACCES; | 991 | return -EACCES; |
992 | if (file->f_vfsmnt->mnt_flags & MNT_NOEXEC) { | ||
993 | if (vm_flags & VM_EXEC) | ||
994 | return -EPERM; | ||
995 | vm_flags &= ~VM_MAYEXEC; | ||
996 | } | ||
997 | if (is_file_hugepages(file)) | ||
998 | accountable = 0; | ||
999 | |||
1000 | if (!file->f_op || !file->f_op->mmap) | ||
1001 | return -ENODEV; | ||
1003 | break; | 1002 | break; |
1004 | 1003 | ||
1005 | default: | 1004 | default: |