mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] stop_machine: check work->done while handling enqueued works
@ 2013-02-10  5:22 Hillf Danton
  2013-02-12 17:37 ` Tejun Heo
  0 siblings, 1 reply; 6+ messages in thread
From: Hillf Danton @ 2013-02-10  5:22 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Namhyung Kim, Rusty Russell, Andrew Morton, Ingo Molnar, LKML,
	Hillf Danton

In cpu_stopper_thread(), @work->done may be NULL if the cpu stop work
is queued from stop_one_cpu_nowait(); however, cpu_stopper_thread()
updates @done->ret without checking whether @done exists or not when
the work function fails.

While this can lead to oops, the only current user of
stop_one_cpu_nowait() - active_load_balance_cpu_stop() - always
returns 0 and thus there's no in-kernel user which triggers this bug.

Fix it by checking whether @done exists before updating @done->ret.

Thanks Tejun for sharing commit message.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
---

--- a/kernel/stop_machine.c	Sun Feb 10 12:51:46 2013
+++ b/kernel/stop_machine.c	Sun Feb 10 12:58:58 2013
@@ -279,7 +279,7 @@ repeat:
 		preempt_disable();

 		ret = fn(arg);
-		if (ret)
+		if (ret && done)
 			done->ret = ret;

 		/* restore preemption and check it's still balanced */
--

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH 1/2] stop_machine: check work->done while handling enqueued works
@ 2013-02-08  3:39 Hillf Danton
  2013-02-08  8:21 ` Namhyung Kim
  2013-02-09 19:08 ` Tejun Heo
  0 siblings, 2 replies; 6+ messages in thread
From: Hillf Danton @ 2013-02-08  3:39 UTC (permalink / raw)
  To: Rusty Russell, Tejun Heo; +Cc: Andrew Morton, Ingo Molnar, Hillf Danton, LKML

The comment just above cpu_stop_signal_done() says it is uncertain that
the input @done is valid, and the works enqueued through the function
stop_one_cpu_nowait() do carry no done, thus we have to check if it is
valid when updating work result.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
---

--- a/kernel/stop_machine.c	Thu Feb  7 20:03:10 2013
+++ b/kernel/stop_machine.c	Fri Feb  8 11:07:40 2013
@@ -279,7 +279,7 @@ repeat:
 		preempt_disable();

 		ret = fn(arg);
-		if (ret)
+		if (ret && done != NULL)
 			done->ret = ret;

 		/* restore preemption and check it's still balanced */
--

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-12 17:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-10  5:22 [PATCH 1/2] stop_machine: check work->done while handling enqueued works Hillf Danton
2013-02-12 17:37 ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2013-02-08  3:39 Hillf Danton
2013-02-08  8:21 ` Namhyung Kim
2013-02-09 19:08 ` Tejun Heo
2013-02-10  4:18   ` Hillf Danton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®