Re: [PATCH 0/2 v4] Init the hashed pointer from a worker.

From: Petr Mladek
Date: Thu Sep 29 2022 - 08:43:46 EST


On Tue 2022-09-27 12:49:10, Sebastian Andrzej Siewior wrote:
> This is a mini series to initialize the random value, needed for the %p
> format argument, upfront during boot instead on demand. The latter is
> problematic on PREEMPT_RT if the first user happens to be in an atomic
> region.
>
> v3…v4:
> - Added a __read_mostly.
> - Added Jason's Acked-by for 2/2 after talking to him at Plumbers.
> While we were discussion several ways of tackling this differently
> and the possible problems/ side effects that this may cause we
> happen to notice that the current way of doing things is also a
> problem if the first printk("%p\n") user happens to be in NMI
> context.
> Therefore I leave it to the vsprintf/ printk maintainer to decide
> if this is -stable material or not. I'm not aware of any NMI code
> path using %p but then it is not officially forbidden.
> Assuming unknown_nmi_error() contains %p format the string, then
> the backtrace at the end of the email will be printed.

JFYI, both patches are committed into printk/linux.git,
branch for-6.1-hash-pointer-init

I have just added a note into the 2nd patch about that it also
prevents deadlock when printk("%p", ptr) is called under the lock
used by get_random_bytes(), see
https://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git/commit/?h=for-6.1-hash-pointer-init&id=6f0ac3b52a9075b7291a72fb338d08491c1f0a64

I did not modify the code. The system_unbound_wq can and should be
fixed separately.

Best Regards,
Petr