aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nsproxy.h
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2008-07-25 04:47:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:37 -0400
commite885dcde75685e09f23cffae1f6d5169c105b8a0 (patch)
tree711a91e83fad632c194700839d3e47631aee677a /include/linux/nsproxy.h
parent856c13aa1ff6136c1968414fdea5938ea9d5ebf2 (diff)
cgroup_clone: use pid of newly created task for new cgroup
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 pid by which t2 knows t3. (Thanks to Dan Smith for finding the main bug) Changelog: June 11: Incorporate Paul Menage's feedback: don't pass NULL to ns_cgroup_clone from unshare, and reduce patch size by using 'nodename' in cgroup_clone. June 10: Original version [akpm@linux-foundation.org: build fix] [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Serge Hallyn <serge@us.ibm.com> Acked-by: Paul Menage <menage@google.com> Tested-by: Dan Smith <danms@us.ibm.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/nsproxy.h')
-rw-r--r--include/linux/nsproxy.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
index 0e66b57631fc..c8a768e59640 100644
--- a/include/linux/nsproxy.h
+++ b/include/linux/nsproxy.h
@@ -82,9 +82,12 @@ static inline void get_nsproxy(struct nsproxy *ns)
82} 82}
83 83
84#ifdef CONFIG_CGROUP_NS 84#ifdef CONFIG_CGROUP_NS
85int ns_cgroup_clone(struct task_struct *tsk); 85int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid);
86#else 86#else
87static inline int ns_cgroup_clone(struct task_struct *tsk) { return 0; } 87static inline int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid)
88{
89 return 0;
90}
88#endif 91#endif
89 92
90#endif 93#endif