diff options
-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: |