• Christian Brauner's avatar
    cgroup: unify attach permission checking · 6df970e4
    Christian Brauner authored
    The core codepaths to check whether a process can be attached to a
    cgroup are the same for threads and thread-group leaders. Only a small
    piece of code verifying that source and destination cgroup are in the
    same domain differentiates the thread permission checking from
    thread-group leader permission checking.
    Since cgroup_migrate_vet_dst() only matters cgroup2 - it is a noop on
    cgroup1 - we can move it out of cgroup_attach_task().
    All checks can now be consolidated into a new helper
    cgroup_attach_permissions() callable from both cgroup_procs_write() and
    cgroup_threads_write().
    
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Li Zefan <lizefan@huawei.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: cgroups@vger.kernel.org
    Acked-by: default avatarMichal Koutný <mkoutny@suse.com>
    Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    6df970e4
cgroup.c 167 KB