Skip to content

Commit 5c2a956

Browse files
MiaoheLintorvalds
authored andcommitted
mm/mlock: fix potential imbalanced rlimit ucounts adjustment
user_shm_lock forgets to set allowed to 0 when get_ucounts fails. So the later user_shm_unlock might do the extra dec_rlimit_ucounts. Fix this by resetting allowed to 0. Link: https://lkml.kernel.org/r/[email protected] Fixes: d7c9e99 ("Reimplement RLIMIT_MEMLOCK on top of ucounts") Signed-off-by: Miaohe Lin <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Acked-by: Hugh Dickins <[email protected]> Cc: Herbert van den Bergh <[email protected]> Cc: Chris Mason <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1e7a818 commit 5c2a956

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/mlock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ int user_shm_lock(size_t size, struct ucounts *ucounts)
839839
}
840840
if (!get_ucounts(ucounts)) {
841841
dec_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_MEMLOCK, locked);
842+
allowed = 0;
842843
goto out;
843844
}
844845
allowed = 1;

0 commit comments

Comments
 (0)