From: Eric W. Biederman Date: Sat, 16 Oct 2021 17:30:00 +0000 (-0500) Subject: ucounts: Pair inc_rlimit_ucounts with dec_rlimit_ucoutns in commit_creds X-Git-Tag: v5.15~47^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=629715adc62b0ad27ab04d0aa73a71927f886910;p=platform%2Fkernel%2Flinux-starfive.git ucounts: Pair inc_rlimit_ucounts with dec_rlimit_ucoutns in commit_creds The purpose of inc_rlimit_ucounts and dec_rlimit_ucounts in commit_creds is to change which rlimit counter is used to track a process when the credentials changes. Use the same test for both to guarantee the tracking is correct. Cc: stable@vger.kernel.org Fixes: 21d1c5e386bc ("Reimplement RLIMIT_NPROC on top of ucounts") Link: https://lkml.kernel.org/r/87v91us0w4.fsf_-_@disp2133 Tested-by: Yu Zhao Reviewed-by: Alexey Gladkov Signed-off-by: "Eric W. Biederman" --- diff --git a/kernel/cred.c b/kernel/cred.c index f784e08..3d163bf 100644 --- a/kernel/cred.c +++ b/kernel/cred.c @@ -501,7 +501,7 @@ int commit_creds(struct cred *new) inc_rlimit_ucounts(new->ucounts, UCOUNT_RLIMIT_NPROC, 1); rcu_assign_pointer(task->real_cred, new); rcu_assign_pointer(task->cred, new); - if (new->user != old->user) + if (new->user != old->user || new->user_ns != old->user_ns) dec_rlimit_ucounts(old->ucounts, UCOUNT_RLIMIT_NPROC, 1); alter_cred_subscribers(old, -2);