[PATCH] RLIMIT_AS checking fix
[linux-2.6.git] / mm / mremap.c
index 0d1c1b9..0dd7ace 100644 (file)
@@ -347,10 +347,10 @@ unsigned long do_mremap(unsigned long addr,
                if (locked > lock_limit && !capable(CAP_IPC_LOCK))
                        goto out;
        }
-       ret = -ENOMEM;
-       if ((current->mm->total_vm << PAGE_SHIFT) + (new_len - old_len)
-           > current->signal->rlim[RLIMIT_AS].rlim_cur)
+       if (!may_expand_vm(current->mm, (new_len - old_len) >> PAGE_SHIFT)) {
+               ret = -ENOMEM;
                goto out;
+       }
 
        if (vma->vm_flags & VM_ACCOUNT) {
                charged = (new_len - old_len) >> PAGE_SHIFT;