cgroup: separate out cgroup_procs_write_permission() from __cgroup_procs_write()
authorTejun Heo <tj@kernel.org>
Thu, 18 Jun 2015 20:54:28 +0000 (16:54 -0400)
committerTejun Heo <tj@kernel.org>
Thu, 18 Jun 2015 20:54:28 +0000 (16:54 -0400)
commitdedf22e9e66ef3fbefd1b8c750d2db11b690ade3
treedf98e0293fb57ab616f700cf56681023a57d5435
parentfb02915f47181e824339d91f8e385fd4bd746d6a
cgroup: separate out cgroup_procs_write_permission() from __cgroup_procs_write()

Separate out task / process migration permission check from
__cgroup_procs_write() into cgroup_procs_write_permission().

* Permission check is moved right above the actual migration and no
  longer performed while holding rcu_read_lock().
  cgroup_procs_write_permission() uses get_task_cred() / put_cred()
  instead of __task_cred().  Also, !root trying to migrate kthreadd or
  PF_NO_SETAFFINITY tasks will now fail with -EINVAL rather than
  -EACCES which should be fine.

* The same permission check is now performed even when moving self by
  specifying 0 as pid.  This always succeeds so there's no functional
  difference.  We'll add more permission checks later and the benefits
  of keeping both cases consistent outweigh the minute overhead of
  doing perm checks on pid 0 case.

Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup.c