• Michal Koutný's avatar
    cgroup: cgroup: Honor caller's cgroup NS when resolving cgroup id · 4534dee9
    Michal Koutný authored
    Cgroup ids are resolved in the global scope. That may be needed sometime
    (in future) but currently it violates virtual view provided through
    cgroup namespaces.
    
    There are currently following users of the resolution:
    - fc_appid_store
    - bpf_iter_attach_cgroup
    - mem_cgroup_get_from_ino
    
    None of the is a called on behalf of kernel but the resolution is made
    with proper userspace context, hence the default to current->nsproxy
    makes sens. (This doesn't rule out cgroup_get_from_id with cgroup NS
    parameter in the future.)
    
    Since cgroup ids are defined on v2 hierarchy only, we simply check
    existence in the cgroup namespace by looking at ancestry on the default
    hierarchy.
    
    Fixes: 6b658c48 ("scsi: cgroup: Add cgroup_get_from_id()")
    Signed-off-by: default avatarMichal Koutný <mkoutny@suse.com>
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    4534dee9
cgroup.c 178 KB