cgroup: unify attach permission checking
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 5 Feb 2020 13:26:18 +0000 (14:26 +0100)
committerTejun Heo <tj@kernel.org>
Wed, 12 Feb 2020 22:57:51 +0000 (17:57 -0500)
commit6df970e4f5d2c273554550d40d8b92cea9bec1a0
treea7734ff12f7dbb720c60a80c4b4519cb2d6b2809
parenta49e4629b5edf1db856de05fbf1aae05502ef1af
cgroup: unify attach permission checking

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: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup.c