Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • kernel
  • fork.c
Find file BlameHistoryPermalink
  • Eric W. Biederman's avatar
    ucounts: Enforce RLIMIT_NPROC not RLIMIT_NPROC+1 · 8f2f9c4d
    Eric W. Biederman authored Feb 09, 2022
    Michal Koutný <mkoutny@suse.com> wrote:
    
    > It was reported that v5.14 behaves differently when enforcing
    > RLIMIT_NPROC limit, namely, it allows one more task than previously.
    > This is consequence of the commit 21d1c5e3 ("Reimplement
    > RLIMIT_NPROC on top of ucounts") that missed the sharpness of
    > equality in the forking path.
    
    This can be fixed either by fixing the test or by moving the increment
    to be before the test.  Fix it my moving copy_creds which contains
    the increment before is_ucounts_overlimit.
    
    In the case of CLONE_NEWUSER the ucounts in the task_cred changes.
    The function is_ucounts_overlimit needs to use the final version of
    the ucounts for the new process.  Which means moving the
    is_ucounts_overlimit test after copy_creds is necessary.
    
    Both the test in fork and the test in set_user were semantically
    changed when the code moved to ucounts.  The change of the test in
    fork was bad because it was before the increment.  The test in
    set_user was wrong and the change to ucounts fixed it.  So this
    fix only restores the old behavior in one lcation not two.
    
    Link: https://lkml.kernel.org/r/20220204181144.24462-1-mkoutny@suse.com
    Link: https://lkml.kernel.org/r/20220216155832.680775-2-ebiederm@xmission.com
    
    
    Cc: stable@vger.kernel.org
    Reported-by: default avatarMichal Koutný <mkoutny@suse.com>
    Reviewed-by: default avatarMichal Koutný <mkoutny@suse.com>
    Fixes: 21d1c5e3
    
     ("Reimplement RLIMIT_NPROC on top of ucounts")
    Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
    8f2f9c4d
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7