diff options
-rw-r--r-- | mm/mlock.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mm/mlock.c b/mm/mlock.c index 4d3fea267e0d..7b2656055d6a 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -244,9 +244,12 @@ int user_shm_lock(size_t size, struct user_struct *user) | |||
244 | 244 | ||
245 | locked = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; | 245 | locked = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; |
246 | lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; | 246 | lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; |
247 | if (lock_limit == RLIM_INFINITY) | ||
248 | allowed = 1; | ||
247 | lock_limit >>= PAGE_SHIFT; | 249 | lock_limit >>= PAGE_SHIFT; |
248 | spin_lock(&shmlock_user_lock); | 250 | spin_lock(&shmlock_user_lock); |
249 | if (locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK)) | 251 | if (!allowed && |
252 | locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK)) | ||
250 | goto out; | 253 | goto out; |
251 | get_uid(user); | 254 | get_uid(user); |
252 | user->locked_shm += locked; | 255 | user->locked_shm += locked; |