Commit 7d9ace4c authored by Chris Wright's avatar Chris Wright Committed by Linus Torvalds

[PATCH] mlockall() take mmap_sem a bit later

In sys_mlockall(), flags validation and can_do_mlock() check don't
require holding mmap_sem.  Move down_write() down a bit, and adjust
appropriately.
Signed-off-by: default avatarChris Wright <chrisw@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ead942ce
......@@ -119,7 +119,7 @@ asmlinkage long sys_mlock(unsigned long start, size_t len)
lock_limit >>= PAGE_SHIFT;
/* check against resource limits */
if ( (locked <= lock_limit) || capable(CAP_IPC_LOCK))
if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
error = do_mlock(start, len, 1);
up_write(&current->mm->mmap_sem);
return error;
......@@ -167,7 +167,6 @@ asmlinkage long sys_mlockall(int flags)
unsigned long lock_limit;
int ret = -EINVAL;
down_write(&current->mm->mmap_sem);
if (!flags || (flags & ~(MCL_CURRENT | MCL_FUTURE)))
goto out;
......@@ -175,6 +174,8 @@ asmlinkage long sys_mlockall(int flags)
if (!can_do_mlock())
goto out;
down_write(&current->mm->mmap_sem);
lock_limit = current->rlim[RLIMIT_MEMLOCK].rlim_cur;
lock_limit >>= PAGE_SHIFT;
......@@ -182,8 +183,8 @@ asmlinkage long sys_mlockall(int flags)
if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
capable(CAP_IPC_LOCK))
ret = do_mlockall(flags);
out:
up_write(&current->mm->mmap_sem);
out:
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment