• Serge E. Hallyn's avatar
    cgroup_clone: use pid of newly created task for new cgroup · e885dcde
    Serge E. Hallyn authored
    cgroup_clone creates a new cgroup with the pid of the task.  This works
    correctly for unshare, but for clone cgroup_clone is called from
    copy_namespaces inside copy_process, which happens before the new pid is
    created.  As a result, the new cgroup was created with current's pid.
    This patch:
    
    	1. Moves the call inside copy_process to after the new pid
    	   is created
    	2. Passes the struct pid into ns_cgroup_clone (as it is not
    	   yet attached to the task)
    	3. Passes a name from ns_cgroup_clone() into cgroup_clone()
    	   so as to keep cgroup_clone() itself simpler
    	4. Uses pid_vnr() to get the process id value, so that the
    	   pid used to name the new cgroup is always the pid as it
    	   would be known to the task which did the cloning or
    	   unsharing.  I think that is the most intuitive thing to
    	   do.  This way, task t1 does clone(CLONE_NEWPID) to get
    	   t2, which does clone(CLONE_NEWPID) to get t3, then the
    	   cgroup for t3 will be named for the...
    e885dcde
nsproxy.c 5.45 KB