diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2009-01-07 21:07:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-08 11:31:02 -0500 |
commit | b12b533fa523e94e0cc9dc23274ae4f9439f1313 (patch) | |
tree | 00a08a34388e835ae3103a6f00c96129d3fa59a4 /kernel | |
parent | c9d5409f8d46fd0d18b4a4481d9caa04076d87fc (diff) |
cgroups: add lock for child->cgroups in cgroup_post_fork()
When cgroup_post_fork() is called, child is seen by find_task_by_vpid(),
so child->cgroups maybe be changed, It'll incorrect.
child->cgroups<old>'s refcnt is decreased
child->cgroups<new>'s refcnt is increased
but child->cg_list is added to child->cgroups<old>'s list.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Reviewed-by: Paul Menage <menage@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 220e0fd659fa..d7ab4ffd8fd9 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2792,8 +2792,10 @@ void cgroup_post_fork(struct task_struct *child) | |||
2792 | { | 2792 | { |
2793 | if (use_task_css_set_links) { | 2793 | if (use_task_css_set_links) { |
2794 | write_lock(&css_set_lock); | 2794 | write_lock(&css_set_lock); |
2795 | task_lock(child); | ||
2795 | if (list_empty(&child->cg_list)) | 2796 | if (list_empty(&child->cg_list)) |
2796 | list_add(&child->cg_list, &child->cgroups->tasks); | 2797 | list_add(&child->cg_list, &child->cgroups->tasks); |
2798 | task_unlock(child); | ||
2797 | write_unlock(&css_set_lock); | 2799 | write_unlock(&css_set_lock); |
2798 | } | 2800 | } |
2799 | } | 2801 | } |