Skip to content
  • Eric W. Biederman's avatar
    cgroupns: Close race between cgroup_post_fork and copy_cgroup_ns · eedd0f4c
    Eric W. Biederman authored
    In most code paths involving cgroup migration cgroup_threadgroup_rwsem
    is taken.  There are two exceptions:
    
    - remove_tasks_in_empty_cpuset calls cgroup_transfer_tasks
    - vhost_attach_cgroups_work calls cgroup_attach_task_all
    
    With cgroup_threadgroup_rwsem held it is guaranteed that cgroup_post_fork
    and copy_cgroup_ns will reference the same css_set from the process calling
    fork.
    
    Without such an interlock there process after fork could reference one
    css_set from it's new cgroup namespace and another css_set from
    task->cgroups, which semantically is nonsensical.
    
    Cc: stable@vger.kernel.org
    Fixes: a79a908f
    
     ("cgroup: introduce cgroup namespaces")
    Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    eedd0f4c