• Eric W. Biederman's avatar
    ucounts: Base set_cred_ucounts changes on the real user · a55d0729
    Eric W. Biederman authored
    Michal Koutný <mkoutny@suse.com> wrote:
    > Tasks are associated to multiple users at once. Historically and as per
    > setrlimit(2) RLIMIT_NPROC is enforce based on real user ID.
    >
    > The commit 21d1c5e3 ("Reimplement RLIMIT_NPROC on top of ucounts")
    > made the accounting structure "indexed" by euid and hence potentially
    > account tasks differently.
    >
    > The effective user ID may be different e.g. for setuid programs but
    > those are exec'd into already existing task (i.e. below limit), so
    > different accounting is moot.
    >
    > Some special setresuid(2) users may notice the difference, justifying
    > this fix.
    
    I looked at cred->ucount and it is only used for rlimit operations
    that were previously stored in cred->user.  Making the fact
    cred->ucount can refer to a different user from cred->user a bug,
    affecting all uses of cred->ulimit not just RLIMIT_NPROC.
    
    Fix set_cred_ucounts to always use the real uid not the effective uid.
    
    Further simplify set_cred_u...
    a55d0729
cred.c 24.2 KB