aboutsummaryrefslogtreecommitdiffstats
path: root/mm/nommu.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/nommu.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/nommu.c')
-rw-r--r--mm/nommu.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/mm/nommu.c b/mm/nommu.c
index acfe419785db..8cbfd623b04a 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -889,7 +889,6 @@ static int validate_mmap_request(struct file *file,
889 unsigned long *_capabilities) 889 unsigned long *_capabilities)
890{ 890{
891 unsigned long capabilities, rlen; 891 unsigned long capabilities, rlen;
892 unsigned long reqprot = prot;
893 int ret; 892 int ret;
894 893
895 /* do the simple checks first */ 894 /* do the simple checks first */
@@ -1050,9 +1049,6 @@ static int validate_mmap_request(struct file *file,
1050 ret = security_mmap_addr(addr); 1049 ret = security_mmap_addr(addr);
1051 if (ret < 0) 1050 if (ret < 0)
1052 return ret; 1051 return ret;
1053 ret = security_mmap_file(file, reqprot, prot, flags);
1054 if (ret < 0)
1055 return ret;
1056 1052
1057 /* looks okay */ 1053 /* looks okay */
1058 *_capabilities = capabilities; 1054 *_capabilities = capabilities;
@@ -1492,9 +1488,12 @@ unsigned long vm_mmap(struct file *file, unsigned long addr,
1492 unsigned long ret; 1488 unsigned long ret;
1493 struct mm_struct *mm = current->mm; 1489 struct mm_struct *mm = current->mm;
1494 1490
1495 down_write(&mm->mmap_sem); 1491 ret = security_mmap_file(file, prot, flag);
1496 ret = do_mmap(file, addr, len, prot, flag, offset); 1492 if (!ret) {
1497 up_write(&mm->mmap_sem); 1493 down_write(&mm->mmap_sem);
1494 ret = do_mmap(file, addr, len, prot, flag, offset);
1495 up_write(&mm->mmap_sem);
1496 }
1498 return ret; 1497 return ret;
1499} 1498}
1500EXPORT_SYMBOL(vm_mmap); 1499EXPORT_SYMBOL(vm_mmap);
@@ -1515,9 +1514,12 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
1515 1514
1516 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 1515 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1517 1516
1518 down_write(&current->mm->mmap_sem); 1517 ret = security_mmap_file(file, prot, flags);
1519 retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); 1518 if (!ret) {
1520 up_write(&current->mm->mmap_sem); 1519 down_write(&current->mm->mmap_sem);
1520 retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1521 up_write(&current->mm->mmap_sem);
1522 }
1521 1523
1522 if (file) 1524 if (file)
1523 fput(file); 1525 fput(file);