ucounts: Handle wrapping in is_ucounts_overlimit
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 10 Feb 2022 00:09:41 +0000 (18:09 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 11:06:03 +0000 (12:06 +0100)
commitce6c0486317269b3e914a0af51a8ef2011ee0c81
tree1933249a1a0085bac60d5604042682001578ce41
parent0c6c4d6d9e52387b58529ee4125e8448c270b088
ucounts: Handle wrapping in is_ucounts_overlimit

commit 0cbae9e24fa7d6c6e9f828562f084da82217a0c5 upstream.

While examining is_ucounts_overlimit and reading the various messages
I realized that is_ucounts_overlimit fails to deal with counts that
may have wrapped.

Being wrapped should be a transitory state for counts and they should
never be wrapped for long, but it can happen so handle it.

Cc: stable@vger.kernel.org
Fixes: 21d1c5e386bc ("Reimplement RLIMIT_NPROC on top of ucounts")
Link: https://lkml.kernel.org/r/20220216155832.680775-5-ebiederm@xmission.com
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/ucount.c