diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2021-10-16 12:30:00 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-10-27 09:59:44 +0200 |
commit | f7f7e4dbc41cc99f5293788ec0cc0a9c7558edfd (patch) | |
tree | 616b643ea11afeb10d490ea637c0b3d3220e8a94 /kernel | |
parent | 32880dcecb51d50f969caa8525031bd043b1abc9 (diff) |
ucounts: Pair inc_rlimit_ucounts with dec_rlimit_ucoutns in commit_creds
commit 629715adc62b0ad27ab04d0aa73a71927f886910 upstream.
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 <yuzhao@google.com>
Reviewed-by: Alexey Gladkov <legion@kernel.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cred.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/cred.c b/kernel/cred.c index ccbc8d32c45c..bab013d4570b 100644 --- a/kernel/cred.c +++ b/kernel/cred.c @@ -499,7 +499,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); |