Skip to content

Commit 0a815d0

Browse files
committed
Merge tag 'ucount-rlimit-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull shm ucounts fix from Eric Biederman: "The introduction of a new failure mode when the code was converted to ucounts resulted in user_shm_lock misbehaving. The change simplifies the code to make the code easier to follow and removes the known misbehaviors" * tag 'ucount-rlimit-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: mm/mlock: fix two bugs in user_shm_lock()
2 parents d717e4c + e97824f commit 0a815d0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

mm/mlock.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,13 +721,12 @@ int user_shm_lock(size_t size, struct ucounts *ucounts)
721721

722722
locked = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
723723
lock_limit = rlimit(RLIMIT_MEMLOCK);
724-
if (lock_limit == RLIM_INFINITY)
725-
allowed = 1;
726-
lock_limit >>= PAGE_SHIFT;
724+
if (lock_limit != RLIM_INFINITY)
725+
lock_limit >>= PAGE_SHIFT;
727726
spin_lock(&shmlock_user_lock);
728727
memlock = inc_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_MEMLOCK, locked);
729728

730-
if (!allowed && (memlock == LONG_MAX || memlock > lock_limit) && !capable(CAP_IPC_LOCK)) {
729+
if ((memlock == LONG_MAX || memlock > lock_limit) && !capable(CAP_IPC_LOCK)) {
731730
dec_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_MEMLOCK, locked);
732731
goto out;
733732
}

0 commit comments

Comments
 (0)