8000 stop_machine: Remove cpu_stop_work's from list in cpu_stop_park() · bsd-unix/linux@d308b9f · GitHub
[go: up one dir, main page]

Skip to content

Commit d308b9f

Browse files
oleg-nesterovIngo Molnar
authored andcommitted
stop_machine: Remove cpu_stop_work's from list in cpu_stop_park()
cpu_stop_park() does cpu_stop_signal_done() but leaves the work on stopper->works. The owner of this work can free/reuse this memory right after that and corrupt the list, so if this CPU becomes online again cpu_stopper_thread() will crash. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: dave@stgolabs.net Cc: der.herr@hofr.at Cc: paulmck@linux.vnet.ibm.com Cc: riel@redhat.com Cc: viro@ZenIV.linux.org.uk Link: http://lkml.kernel.org/r/20150630012958.GA23944@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 9a301f2 commit d308b9f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/stop_machine.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,15 @@ static void cpu_stop_create(unsigned int cpu)
462462
static void cpu_stop_park(unsigned int cpu)
463463
{
464464
struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu);
465-
struct cpu_stop_work *work;
465+
struct cpu_stop_work *work, *tmp;
466466
unsigned long flags;
467467

468468
/* drain remaining works */
469469
spin_lock_irqsave(&stopper->lock, flags);
470-
list_for_each_entry(work, &stopper->works, list)
470+
list_for_each_entry_safe(work, tmp, &stopper->works, list) {
471+
list_del_init(&work->list);
471472
cpu_stop_signal_done(work->done, false);
473+
}
472474
stopper->enabled = false;
473475
spin_unlock_irqrestore(&stopper->lock, flags);
474476
}

0 commit comments

Comments
 (0)
0