[PATCH cgroup/for-3.11 2/3] cgroup: fix RCU accesses around task->cgroups

Li Zefan lizefan at huawei.com
Tue Jun 25 02:02:38 UTC 2013


> @@ -5046,8 +5049,8 @@ static const struct file_operations proc
>  void cgroup_fork(struct task_struct *child)
>  {
>  	task_lock(current);
> +	get_css_set(task_css_set(current));
>  	child->cgroups = current->cgroups;

While we use RCU_INIT_POINTER() in cgroup_exit(), we don't need to use it here?

> -	get_css_set(child->cgroups);
>  	task_unlock(current);
>  	INIT_LIST_HEAD(&child->cg_list);
>  }
> @@ -5081,7 +5084,7 @@ void cgroup_post_fork(struct task_struct
>  		write_lock(&css_set_lock);
>  		task_lock(child);
>  		if (list_empty(&child->cg_list))
> -			list_add(&child->cg_list, &child->cgroups->tasks);
> +			list_add(&child->cg_list, &task_css_set(child)->tasks);
>  		task_unlock(child);
>  		write_unlock(&css_set_lock);
>  	}
> @@ -5163,8 +5166,8 @@ void cgroup_exit(struct task_struct *tsk
>  
>  	/* Reassign the task to the init_css_set. */
>  	task_lock(tsk);
> -	cset = tsk->cgroups;
> -	tsk->cgroups = &init_css_set;
> +	cset = task_css_set(tsk);
> +	RCU_INIT_POINTER(tsk->cgroups, &init_css_set);
>  
>  	if (run_callbacks && need_forkexit_callback) {
>  		/*



More information about the Containers mailing list