]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
mm/mlock: fix potential imbalanced rlimit ucounts adjustment
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 22 Mar 2022 21:44:56 +0000 (14:44 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:22:03 +0000 (09:22 +0200)
commitbb00d3141f6a979d885ff9f9f81c2030df856a04
tree376eb7b8cc5d034b5b482fba1501f1460c1894dd
parent8601e3667d0003d6af4b36ed10834ad7cd777ef9
mm/mlock: fix potential imbalanced rlimit ucounts adjustment

BugLink: https://bugs.launchpad.net/bugs/1980277
commit 5c2a956c3eea173b2bc89f632507c0eeaebf6c4a upstream.

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/20220310132417.41189-1-linmiaohe@huawei.com
Fixes: d7c9e99aee48 ("Reimplement RLIMIT_MEMLOCK on top of ucounts")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Herbert van den Bergh <herbert.van.den.bergh@oracle.com>
Cc: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
mm/mlock.c