ucounts: Move RLIMIT_NPROC handling after set_user
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 14 Feb 2022 15:40:25 +0000 (09:40 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 11:03:20 +0000 (12:03 +0100)
commit2b2be95b6013ed3739d26352f1f7799d97f8fa70
treea1a8ec7d21b57ede6b3553e57fea46adda272708
parentb5f949d9a9c3620ca2d0918e304934e946705c30
ucounts: Move RLIMIT_NPROC handling after set_user

commit c923a8e7edb010da67424077cbf1a6f1396ebd2e upstream.

During set*id() which cred->ucounts to charge the the current process
to is not known until after set_cred_ucounts.  So move the
RLIMIT_NPROC checking into a new helper flag_nproc_exceeded and call
flag_nproc_exceeded after set_cred_ucounts.

This is very much an arbitrary subset of the places where we currently
change the RLIMIT_NPROC accounting, designed to preserve the existing
logic.

Fixing the existing logic will be the subject of another series of
changes.

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