cgroups: add lock for child->cgroups in cgroup_post_fork()
PATCH 1/1 cgroups: add lock for child->cgroups in cgroup_post_fork()
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.
---
kernel/cgroup.c +2 -0
@@ -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); } }
A message that is not in the archive (sent off-list or not yet received): [email protected]
Paul Menage
Reviewed-byQuoted 8 lines · Lai Jiangshan
when
cgroup_post_fork()called, child is seen byfind_task_by_vpid(), sochild->cgroupsmaybe be changed, It'll incorrect.child->cgroups<old>'s refcnt is decreased child->cgroups<new>'s refcnt is increased
butchild->cg_listis added to child->cgroups<old>'s list.Signed-off-by Lai Jiangshan <[email protected]>
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
Quoted 8 lines · Lai Jiangshan
when
cgroup_post_fork()called, child is seen byfind_task_by_vpid(), sochild->cgroupsmaybe be changed, It'll incorrect.child->cgroups<old>'s refcnt is decreased child->cgroups<new>'s refcnt is increased
butchild->cg_listis added to child->cgroups<old>'s list.Signed-off-by Lai Jiangshan <[email protected]>
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