From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754930AbbHCRK7 (ORCPT ); Mon, 3 Aug 2015 13:10:59 -0400 Received: from terminus.zytor.com ([198.137.202.10]:40541 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754700AbbHCRKz (ORCPT ); Mon, 3 Aug 2015 13:10:55 -0400 Date: Mon, 3 Aug 2015 10:10:01 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de, peterz@infradead.org, oleg@redhat.com, linux-kernel@vger.kernel.org, efault@gmx.de, torvalds@linux-foundation.org, tj@kernel.org Reply-To: tj@kernel.org, torvalds@linux-foundation.org, efault@gmx.de, linux-kernel@vger.kernel.org, tglx@linutronix.de, oleg@redhat.com, peterz@infradead.org, hpa@zytor.com, mingo@kernel.org In-Reply-To: <20150630012958.GA23944@redhat.com> References: <20150630012958.GA23944@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] stop_machine: Remove cpu_stop_work' s from list in cpu_stop_park() Git-Commit-ID: d308b9f1e4412bcf583c82c4ca15ef97cb8b0e6f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d308b9f1e4412bcf583c82c4ca15ef97cb8b0e6f Gitweb: http://git.kernel.org/tip/d308b9f1e4412bcf583c82c4ca15ef97cb8b0e6f Author: Oleg Nesterov AuthorDate: Tue, 30 Jun 2015 03:29:58 +0200 Committer: Ingo Molnar CommitDate: Mon, 3 Aug 2015 12:21:28 +0200 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Tejun Heo Cc: Thomas Gleixner 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 --- kernel/stop_machine.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 9a70def..12484e5 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -462,13 +462,15 @@ static void cpu_stop_create(unsigned int cpu) static void cpu_stop_park(unsigned int cpu) { struct cpu_stopper *stopper = &per_cpu(cpu_stopper, cpu); - struct cpu_stop_work *work; + struct cpu_stop_work *work, *tmp; unsigned long flags; /* drain remaining works */ spin_lock_irqsave(&stopper->lock, flags); - list_for_each_entry(work, &stopper->works, list) + list_for_each_entry_safe(work, tmp, &stopper->works, list) { + list_del_init(&work->list); cpu_stop_signal_done(work->done, false); + } stopper->enabled = false; spin_unlock_irqrestore(&stopper->lock, flags); }