From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
John Ogness <john.ogness@linutronix.de>,
Mike Galbraith <efault@gmx.de>,
Peter Zijlstra <peterz@infradead.org>,
Petr Mladek <pmladek@suse.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v4 2/2] lib/vsprintf: Initialize vsprintf's pointer hash once the random core is ready.
Date: Tue, 27 Sep 2022 13:20:38 +0200 [thread overview]
Message-ID: <YzLchr32qSKgN4vC@zx2c4.com> (raw)
In-Reply-To: <20220927104912.622645-3-bigeasy@linutronix.de>
You added my Acked-by already (which is fine), but I thought I should
still add some final notes to that ack, for posterity:
On Tue, Sep 27, 2022 at 12:49:12PM +0200, Sebastian Andrzej Siewior wrote:
> The printk code invokes vnsprintf in order to compute the complete
> string before adding it into its buffer. This happens in an IRQ-off
> region which leads to a warning on PREEMPT_RT in the random code if the
> format strings contains a %p for pointer printing. This happens because
> the random core acquires locks which become sleeping locks on PREEMPT_RT
> which must not be acquired with disabled interrupts and or preemption
> disabled.
> By default the pointers are hashed which requires a random value on the
> first invocation (either by printk or another user which comes first.
>
> One could argue that there is no need for printk to disable interrupts
> during the vsprintf() invocation which would fix the just mentioned
> problem. However printk itself can be invoked in a context with
> disabled interrupts which would lead to the very same problem.
>
> Move the initialization of ptr_key into a worker and schedule it from
> subsys_initcall(). This happens early but after the workqueue subsystem
> is ready. Use get_random_bytes() to retrieve the random value if the RNG
> core is ready, otherwise schedule a worker in two seconds and try again.
>
> Reported-by: Mike Galbraith <efault@gmx.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Acked-by: Jason A. Donenfeld <Jason@zx2c4.com>
I really do hate the idea of polling every 2 seconds. But as we
discussed, this seems like the least bad solution, at least for now. If
we discover another bug in the tree that needs a gross solution like
that, then at that point, I'll move ahead with adding a notifier_block
to random.c, to avoid polling. But so long as this is a one-off (as we
understand it to be at the moment), this seems okay.
Acked-by: Jason A. Donenfeld <Jason@zx2c4.com>
Jason
next prev parent reply other threads:[~2022-09-27 11:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 10:49 [PATCH 0/2 v4] Init the hashed pointer from a worker Sebastian Andrzej Siewior
2022-09-27 10:49 ` [PATCH v4 1/2] lib/vsprintf: Remove static_branch_likely() from __ptr_to_hashval() Sebastian Andrzej Siewior
2022-09-27 14:49 ` Petr Mladek
2022-09-30 10:27 ` Sergey Senozhatsky
2022-09-27 10:49 ` [PATCH v4 2/2] lib/vsprintf: Initialize vsprintf's pointer hash once the random core is ready Sebastian Andrzej Siewior
2022-09-27 11:20 ` Jason A. Donenfeld [this message]
2022-09-27 16:40 ` Petr Mladek
2022-09-28 9:11 ` Sebastian Andrzej Siewior
2022-09-28 9:21 ` Jason A. Donenfeld
2022-09-29 8:52 ` Petr Mladek
2022-09-30 10:31 ` Sergey Senozhatsky
2022-09-29 12:43 ` [PATCH 0/2 v4] Init the hashed pointer from a worker Petr Mladek
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=YzLchr32qSKgN4vC@zx2c4.com \
--to=jason@zx2c4.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=efault@gmx.de \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox