Skip to contentSkip to conversation

cgroups: use task_lock() for access tsk->cgroups safe in cgroup_clone()

PATCH In review Lai Jiangshan 3 participants 3 messages Nov 21, 2008 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroups: use task_lock() for access tsk->cgroups safe in cgroup_clone()

use task_lock() protect tsk->cgroups and get_css_set(tsk->cgroups)

---

kernel/cgroup.c +2 -0
index 358e775..ddc10ac 100644
@@ -2933,6 +2943,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 		mutex_unlock(&cgroup_mutex);
 		return 0;
 	}
+	task_lock(tsk);
 	cg = tsk->cgroups;
 	parent = task_cgroup(tsk, subsys->subsys_id);
 
@@ -2941,6 +2952,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 
 	/* Keep the cgroup alive */
 	get_css_set(cg);
+	task_unlock(tsk);
 	mutex_unlock(&cgroup_mutex);
 
 	/* Now do the VFS work to create a cgroup */

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#2 lore raw
Quoted 5 lines · Lai Jiangshan

use task_lock() protect tsk->cgroups and get_css_set(tsk->cgroups)

Sounds reasonable, given the race with cgroup_exit()

Thanks,

Paul

Quoted 23 lines

---

kernel/cgroup.c +2 -0
index 358e775..ddc10ac 100644
@@ -2933,6 +2943,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
               mutex_unlock(&cgroup_mutex);
               return 0;
       }
+       task_lock(tsk);
       cg = tsk->cgroups;
       parent = task_cgroup(tsk, subsys->subsys_id);
 
@@ -2941,6 +2952,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 
       /* Keep the cgroup alive */
       get_css_set(cg);
+       task_unlock(tsk);
       mutex_unlock(&cgroup_mutex);
 
       /* Now do the VFS work to create a cgroup */
Reviewed-by on v1 1/1
#3 lore raw
In reply to Lai Jiangshan
Quoted 5 lines · Lai Jiangshan

use task_lock() protect tsk->cgroups and get_css_set(tsk->cgroups)

Sounds reasonable, given the race with cgroup_exit()

Thanks,

Paul

Quoted 23 lines

---

kernel/cgroup.c +2 -0
index 358e775..ddc10ac 100644
@@ -2933,6 +2943,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
               mutex_unlock(&cgroup_mutex);
               return 0;
       }
+       task_lock(tsk);
       cg = tsk->cgroups;
       parent = task_cgroup(tsk, subsys->subsys_id);
 
@@ -2941,6 +2952,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 
       /* Keep the cgroup alive */
       get_css_set(cg);
+       task_unlock(tsk);
       mutex_unlock(&cgroup_mutex);
 
       /* Now do the VFS work to create a cgroup */