* [PATCH] cgroups: add lock for child->cgroups in cgroup_post_fork()
@ 2008-11-21 8:49 Lai Jiangshan
2008-11-21 17:59 ` Paul Menage
0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2008-11-21 8:49 UTC (permalink / raw)
To: Andrew Morton, Paul Menage, Linux Kernel Mailing List,
Linux Containers
when cgroup_post_fork() 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>
---
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 358e775..ddc10ac 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2823,8 +2831,10 @@ void cgroup_post_fork(struct task_struct *child)
{
if (use_task_css_set_links) {
write_lock(&css_set_lock);
+ task_lock(child);
if (list_empty(&child->cg_list))
list_add(&child->cg_list, &child->cgroups->tasks);
+ task_unlock(child);
write_unlock(&css_set_lock);
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] cgroups: add lock for child->cgroups in cgroup_post_fork()
2008-11-21 8:49 [PATCH] cgroups: add lock for child->cgroups in cgroup_post_fork() Lai Jiangshan
@ 2008-11-21 17:59 ` Paul Menage
0 siblings, 0 replies; 2+ messages in thread
From: Paul Menage @ 2008-11-21 17:59 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: Andrew Morton, Linux Kernel Mailing List, Linux Containers
On Fri, Nov 21, 2008 at 12:49 AM, Lai Jiangshan <laijs@cn.fujitsu.com> wrote:
> when cgroup_post_fork() 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>
Yeah, I guess this was a place where I equated "holding css_set_lock"
with "cgroups can't change". But in fact they can partially change.
Paul
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-21 17:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21 8:49 [PATCH] cgroups: add lock for child->cgroups in cgroup_post_fork() Lai Jiangshan
2008-11-21 17:59 ` Paul Menage
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox