Skip to content

RFC RLIMIT_NPROC in ucounts fixups

Michal Koutný containers linux-api linux-kselftest lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 23 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6set_user: Perform RLIMIT_NPROC capability check against new user credentialskernel/sys.c+2 -15 replies
2/6set*uid: Check RLIMIT_PROC against new credentialsfs/exec.c include/linux/cred.h kernel/cred.c +3 more+28 -250 replies
3/6cred: Count tasks by their real uid into RLIMIT_NPROCkernel/cred.c+3 -20 replies
4/6ucounts: Allow root to override RLIMIT_NPROCkernel/ucount.c+3 -01 reply
5/6selftests: Challenge RLIMIT_NPROC in user namespacestools/testing/selftests/rlimits/rlimits-per-userns.c+125 -292 replies
6/6selftests: Test RLIMIT_NPROC in clone-created user namespacestools/testing/selftests/rlimits/rlimits-per-userns.c+101 -402 replies

Reviews trailers per patch

None of the 6 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMichal KoutnýShuah KhanSolar DesignerKees Cook
SeriesR-b R-b R-b R-b R-b R-b R-b R-b R-b R-b
1/6
2/6
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [RFC PATCH 0/6] RLIMIT_NPROC in ucounts fixups

This series is a result of looking deeper into breakage of tools/testing/selftests/rlimits/rlimits-per-userns.c after
https://lore.kernel.org/r/[email protected]/
is applied.

The description of the original problem that lead to RLIMIT_NPROC et al. ucounts rewrite could be ambiguously interpretted as supporting either the case of:
- never-fork service or
- fork (RLIMIT_NPROC-1) times service.

The scenario is weird anyway given existence of pids controller.

The realization of that scenario relies not only on tracking number of processes per user_ns but also newly allows the root to override limit through set*uid. The commit message didn't mention that, so it's unclear if it was the intention too.

I also noticed that the RLIMIT_NPROC enforcing in fork seems subject to TOCTOU race (check(nr_tasks),...,nr_tasks++) so the limit is rather advisory (but that's not a new thing related to ucounts rewrite).

This series is RFC to discuss relevance of the subtle changes RLIMIT_NPROC to ucounts rewrite introduced.

Michal Koutný (6):
set_user: Perform RLIMIT_NPROC capability check against new user
credentials
set*uid: Check RLIMIT_PROC against new credentials
cred: Count tasks by their real uid into RLIMIT_NPROC
ucounts: Allow root to override RLIMIT_NPROC
selftests: Challenge RLIMIT_NPROC in user namespaces
selftests: Test RLIMIT_NPROC in clone-created user namespaces

 fs/exec.c                                     |   2 +-
 include/linux/cred.h                          |   2 +-
 kernel/cred.c                                 |  29 ++-
 kernel/fork.c                                 |   2 +-
 kernel/sys.c                                  |  20 +-
 kernel/ucount.c                               |   3 +
 kernel/user_namespace.c                       |   2 +-
 .../selftests/rlimits/rlimits-per-userns.c    | 233 +++++++++++++++---
 8 files changed, 229 insertions(+), 64 deletions(-)
Signature · 1 line
2.34.1