From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>
Cc: paulmck@linux.vnet.ibm.com, mingo@redhat.com, der.herr@hofr.at,
dave@stgolabs.net, riel@redhat.com, viro@ZenIV.linux.org.uk,
torvalds@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/5] stop_machine: cpu_stop_park() should remove cpu_stop_work's from list
Date: Tue, 30 Jun 2015 03:29:58 +0200 [thread overview]
Message-ID: <20150630012958.GA23944@redhat.com> (raw)
In-Reply-To: <20150630012931.GA23904@redhat.com>
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>
---
kernel/stop_machine.c | 6 ++++--
1 files 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);
}
--
1.5.5.1
next prev parent reply other threads:[~2015-06-30 1:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 1:29 [PATCH 0/5] stop_machine: cleanups and fix Oleg Nesterov
2015-06-30 1:29 ` [PATCH 1/5] stop_machine: move cpu_stopper_task and stop_cpus_work into struct cpu_stopper Oleg Nesterov
2015-08-03 17:08 ` [tip:sched/core] stop_machine: Move 'cpu_stopper_task' and ' stop_cpus_work' into 'struct cpu_stopper' tip-bot for Oleg Nesterov
2015-06-30 1:29 ` [PATCH 2/5] stop_machine: don't do for_each_cpu() twice in queue_stop_cpus_work() Oleg Nesterov
2015-08-03 17:09 ` [tip:sched/core] stop_machine: Don't " tip-bot for Oleg Nesterov
2015-06-30 1:29 ` [PATCH 3/5] stop_machine: unexport __stop_machine() Oleg Nesterov
2015-08-03 17:09 ` [tip:sched/core] stop_machine: Unexport __stop_machine() tip-bot for Oleg Nesterov
2015-06-30 1:29 ` [PATCH 4/5] stop_machine: use cpu_stop_fn_t where possible Oleg Nesterov
2015-06-30 14:28 ` Peter Zijlstra
2015-08-03 17:09 ` [tip:sched/core] stop_machine: Use 'cpu_stop_fn_t' " tip-bot for Oleg Nesterov
2015-06-30 1:29 ` Oleg Nesterov [this message]
2015-08-03 17:10 ` [tip:sched/core] stop_machine: Remove cpu_stop_work' s from list in cpu_stop_park() tip-bot for Oleg Nesterov
2015-06-30 12:52 ` [PATCH 0/5] stop_machine: cleanups and fix Oleg Nesterov
2015-07-01 19:22 ` Oleg Nesterov
2015-07-01 19:23 ` [PATCH 6/5] stop_machine: kill stop_cpus_lock and lg_double_lock/unlock() Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150630012958.GA23944@redhat.com \
--to=oleg@redhat.com \
--cc=dave@stgolabs.net \
--cc=der.herr@hofr.at \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.