aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-05-30 17:11:23 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-06-01 10:37:01 -0400
commit8b3ec6814c83d76b85bd13badc48552836c24839 (patch)
tree2430a4511c7ea41f67b0d841f4c42eac43828db3 /mm/mmap.c
parente5467859f7f79b69fc49004403009dfdba3bec53 (diff)
take security_mmap_file() outside of ->mmap_sem
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 49283da9a2ae..34b280f4238d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -979,7 +979,6 @@ static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
979 struct inode *inode; 979 struct inode *inode;
980 vm_flags_t vm_flags; 980 vm_flags_t vm_flags;
981 int error; 981 int error;
982 unsigned long reqprot = prot;
983 982
984 /* 983 /*
985 * Does the application expect PROT_READ to imply PROT_EXEC? 984 * Does the application expect PROT_READ to imply PROT_EXEC?
@@ -1105,10 +1104,6 @@ static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1105 if (error) 1104 if (error)
1106 return error; 1105 return error;
1107 1106
1108 error = security_mmap_file(file, reqprot, prot, flags);
1109 if (error)
1110 return error;
1111
1112 return mmap_region(file, addr, len, flags, vm_flags, pgoff); 1107 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
1113} 1108}
1114 1109
@@ -1130,9 +1125,12 @@ unsigned long vm_mmap(struct file *file, unsigned long addr,
1130 unsigned long ret; 1125 unsigned long ret;
1131 struct mm_struct *mm = current->mm; 1126 struct mm_struct *mm = current->mm;
1132 1127
1133 down_write(&mm->mmap_sem); 1128 ret = security_mmap_file(file, prot, flag);
1134 ret = do_mmap(file, addr, len, prot, flag, offset); 1129 if (!ret) {
1135 up_write(&mm->mmap_sem); 1130 down_write(&mm->mmap_sem);
1131 ret = do_mmap(file, addr, len, prot, flag, offset);
1132 up_write(&mm->mmap_sem);
1133 }
1136 return ret; 1134 return ret;
1137} 1135}
1138EXPORT_SYMBOL(vm_mmap); 1136EXPORT_SYMBOL(vm_mmap);
@@ -1168,9 +1166,12 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
1168 1166
1169 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 1167 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1170 1168
1171 down_write(&current->mm->mmap_sem); 1169 retval = security_mmap_file(file, prot, flags);
1172 retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); 1170 if (!retval) {
1173 up_write(&current->mm->mmap_sem); 1171 down_write(&current->mm->mmap_sem);
1172 retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1173 up_write(&current->mm->mmap_sem);
1174 }
1174 1175
1175 if (file) 1176 if (file)
1176 fput(file); 1177 fput(file);