public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk: defer_console_output: do not assume interrupts disabled
@ 2022-02-03 11:29 John Ogness
  2022-02-03 11:33 ` Sebastian Andrzej Siewior
  2022-02-04  7:04 ` Sergey Senozhatsky
  0 siblings, 2 replies; 11+ messages in thread
From: John Ogness @ 2022-02-03 11:29 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Sergey Senozhatsky, Steven Rostedt, linux-kernel,
	Sebastian Andrzej Siewior

With commit 458df9fd4815 ("printk: remove separate printk_sched
buffers and use printk buf instead") defer_console_output() was
changed to no longer disable interrupts. However, it used the
function __this_cpu_or(), which assumes interrupts disabled. That
also should have been changed to this_cpu_or().

Although defer_console_output() is mostly used when interrupts are
disabled, this is not always the case. One example is
get_random_bytes(), which is often called with interrupts enabled.

  get_random_bytes()
    warn_unseeded_randomness()
      printk_deferred()

Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 kernel/printk/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 82abfaf3c2aa..164ccdb9423e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3262,7 +3262,7 @@ void defer_console_output(void)
 		return;
 
 	preempt_disable();
-	__this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
+	this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
 	irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
 	preempt_enable();
 }

base-commit: 88808fbbead481aedb46640a5ace69c58287f56a
-- 
2.30.2


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

end of thread, other threads:[~2022-02-15 15:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-03 11:29 [PATCH] printk: defer_console_output: do not assume interrupts disabled John Ogness
2022-02-03 11:33 ` Sebastian Andrzej Siewior
2022-02-04  7:04 ` Sergey Senozhatsky
2022-02-07  9:46   ` [PATCH v2] printk: defer_console_output: use atomic update John Ogness
2022-02-10 15:47     ` Petr Mladek
2022-02-11 11:22       ` John Ogness
2022-02-11 11:23         ` [PATCH v3] printk: use atomic updates for klogd work John Ogness
2022-02-14  5:35           ` Sergey Senozhatsky
2022-02-15 15:26           ` Petr Mladek
2022-02-14  5:32         ` [PATCH v2] printk: defer_console_output: use atomic update Sergey Senozhatsky
2022-02-14  5:35           ` Sergey Senozhatsky

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