diff options
author | Linux Build Service Account <lnxbuild@quicinc.com> | 2017-07-03 07:57:48 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-07-03 07:57:48 -0700 |
commit | d219ff30f86ed140b2fb75b69c72981ae22b3cd8 (patch) | |
tree | 6101bc6a96551ebb08a79ee39984fba13856d740 /kernel | |
parent | bc399a65c4e048d98b6304272e32402bfca59dda (diff) | |
parent | 98a54eb4ab9a34b343b171cf3a33e50a30c947c0 (diff) |
Merge "cgroup: Fix potential race between cgroup_exit and migrate path"
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 25cf44889559..077bb52e2d47 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -717,10 +717,10 @@ static void css_set_move_task(struct task_struct *task, if (to_cset) { /* - * We are synchronized through cgroup_threadgroup_rwsem - * against PF_EXITING setting such that we can't race - * against cgroup_exit() changing the css_set to - * init_css_set and dropping the old one. + * We are synchronized through css_set_lock against + * PF_EXITING setting such that we can't race against + * cgroup_exit() disassociating the task from the + * css_set. */ WARN_ON_ONCE(task->flags & PF_EXITING); @@ -5701,19 +5701,22 @@ void cgroup_exit(struct task_struct *tsk) int i; /* - * Unlink from @tsk from its css_set. As migration path can't race - * with us, we can check css_set and cg_list without synchronization. + * Avoid potential race with the migrate path. + */ + spin_lock_irq(&css_set_lock); + /* + * Unlink from @tsk from its css_set. */ cset = task_css_set(tsk); if (!list_empty(&tsk->cg_list)) { - spin_lock_irq(&css_set_lock); css_set_move_task(tsk, cset, NULL, false); - spin_unlock_irq(&css_set_lock); } else { get_css_set(cset); } + spin_unlock_irq(&css_set_lock); + /* see cgroup_post_fork() for details */ for_each_subsys_which(ss, i, &have_exit_callback) ss->exit(tsk); |