Skip to content

Commit 0cbae9e

Browse files
committed
ucounts: Handle wrapping in is_ucounts_overlimit
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: [email protected] Fixes: 21d1c5e ("Reimplement RLIMIT_NPROC on top of ucounts") Link: https://lkml.kernel.org/r/[email protected] Reviewed-by: Shuah Khan <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent c923a8e commit 0cbae9e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/ucount.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ bool is_ucounts_overlimit(struct ucounts *ucounts, enum ucount_type type, unsign
350350
if (rlimit > LONG_MAX)
351351
max = LONG_MAX;
352352
for (iter = ucounts; iter; iter = iter->ns->ucounts) {
353-
if (get_ucounts_value(iter, type) > max)
353+
long val = get_ucounts_value(iter, type);
354+
if (val < 0 || val > max)
354355
return true;
355356
max = READ_ONCE(iter->ns->ucount_max[type]);
356357
}

0 commit comments

Comments
 (0)