aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2012-02-12 22:58:52 -0500
committerJames Morris <jmorris@namei.org>2012-02-13 18:45:39 -0500
commit191c542442fdf53cc3c496c00be13367fd9cd42d (patch)
tree4aef9e33a1d99e6530b704243efbe373bb314d61 /mm
parentbbd36568594d091e682a1975ef4ee41d808de0bc (diff)
mm: collapse security_vm_enough_memory() variants into a single function
Collapse security_vm_enough_memory() variants into a single function. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/mmap.c4
-rw-r--r--mm/mprotect.c2
-rw-r--r--mm/mremap.c2
-rw-r--r--mm/shmem.c4
-rw-r--r--mm/swapfile.c4
5 files changed, 9 insertions, 7 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 3f758c7f4c81..db05495d6d0a 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1235,7 +1235,7 @@ munmap_back:
1235 */ 1235 */
1236 if (accountable_mapping(file, vm_flags)) { 1236 if (accountable_mapping(file, vm_flags)) {
1237 charged = len >> PAGE_SHIFT; 1237 charged = len >> PAGE_SHIFT;
1238 if (security_vm_enough_memory(charged)) 1238 if (security_vm_enough_memory_mm(mm, charged))
1239 return -ENOMEM; 1239 return -ENOMEM;
1240 vm_flags |= VM_ACCOUNT; 1240 vm_flags |= VM_ACCOUNT;
1241 } 1241 }
@@ -2169,7 +2169,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
2169 if (mm->map_count > sysctl_max_map_count) 2169 if (mm->map_count > sysctl_max_map_count)
2170 return -ENOMEM; 2170 return -ENOMEM;
2171 2171
2172 if (security_vm_enough_memory(len >> PAGE_SHIFT)) 2172 if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
2173 return -ENOMEM; 2173 return -ENOMEM;
2174 2174
2175 /* Can we just expand an old private anonymous mapping? */ 2175 /* Can we just expand an old private anonymous mapping? */
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 5a688a2756be..9599fa2d0e92 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -168,7 +168,7 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
168 if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_HUGETLB| 168 if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_HUGETLB|
169 VM_SHARED|VM_NORESERVE))) { 169 VM_SHARED|VM_NORESERVE))) {
170 charged = nrpages; 170 charged = nrpages;
171 if (security_vm_enough_memory(charged)) 171 if (security_vm_enough_memory_mm(mm, charged))
172 return -ENOMEM; 172 return -ENOMEM;
173 newflags |= VM_ACCOUNT; 173 newflags |= VM_ACCOUNT;
174 } 174 }
diff --git a/mm/mremap.c b/mm/mremap.c
index 87bb8393e7d2..db8d983b5a7d 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -329,7 +329,7 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
329 329
330 if (vma->vm_flags & VM_ACCOUNT) { 330 if (vma->vm_flags & VM_ACCOUNT) {
331 unsigned long charged = (new_len - old_len) >> PAGE_SHIFT; 331 unsigned long charged = (new_len - old_len) >> PAGE_SHIFT;
332 if (security_vm_enough_memory(charged)) 332 if (security_vm_enough_memory_mm(mm, charged))
333 goto Efault; 333 goto Efault;
334 *p = charged; 334 *p = charged;
335 } 335 }
diff --git a/mm/shmem.c b/mm/shmem.c
index 269d049294ab..d9c293952755 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -127,7 +127,7 @@ static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb)
127static inline int shmem_acct_size(unsigned long flags, loff_t size) 127static inline int shmem_acct_size(unsigned long flags, loff_t size)
128{ 128{
129 return (flags & VM_NORESERVE) ? 129 return (flags & VM_NORESERVE) ?
130 0 : security_vm_enough_memory_kern(VM_ACCT(size)); 130 0 : security_vm_enough_memory_mm(current->mm, VM_ACCT(size));
131} 131}
132 132
133static inline void shmem_unacct_size(unsigned long flags, loff_t size) 133static inline void shmem_unacct_size(unsigned long flags, loff_t size)
@@ -145,7 +145,7 @@ static inline void shmem_unacct_size(unsigned long flags, loff_t size)
145static inline int shmem_acct_block(unsigned long flags) 145static inline int shmem_acct_block(unsigned long flags)
146{ 146{
147 return (flags & VM_NORESERVE) ? 147 return (flags & VM_NORESERVE) ?
148 security_vm_enough_memory_kern(VM_ACCT(PAGE_CACHE_SIZE)) : 0; 148 security_vm_enough_memory_mm(current->mm, VM_ACCT(PAGE_CACHE_SIZE)) : 0;
149} 149}
150 150
151static inline void shmem_unacct_blocks(unsigned long flags, long pages) 151static inline void shmem_unacct_blocks(unsigned long flags, long pages)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index d999f090dfda..f0d79296dd55 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1563,6 +1563,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1563 if (!capable(CAP_SYS_ADMIN)) 1563 if (!capable(CAP_SYS_ADMIN))
1564 return -EPERM; 1564 return -EPERM;
1565 1565
1566 BUG_ON(!current->mm);
1567
1566 pathname = getname(specialfile); 1568 pathname = getname(specialfile);
1567 err = PTR_ERR(pathname); 1569 err = PTR_ERR(pathname);
1568 if (IS_ERR(pathname)) 1570 if (IS_ERR(pathname))
@@ -1590,7 +1592,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1590 spin_unlock(&swap_lock); 1592 spin_unlock(&swap_lock);
1591 goto out_dput; 1593 goto out_dput;
1592 } 1594 }
1593 if (!security_vm_enough_memory(p->pages)) 1595 if (!security_vm_enough_memory_mm(current->mm, p->pages))
1594 vm_unacct_memory(p->pages); 1596 vm_unacct_memory(p->pages);
1595 else { 1597 else {
1596 err = -ENOMEM; 1598 err = -ENOMEM;