From: Petr Mladek <pmladek@suse.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-efi@vger.kernel.org, linux-crypto@vger.kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
Lennart Poettering <lennart@poettering.net>,
Mike Galbraith <efault@gmx.de>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [PATCH RFC v1 2/6] vsprintf: initialize siphash key using notifier
Date: Fri, 18 Nov 2022 15:16:49 +0100 [thread overview]
Message-ID: <Y3eT0fd/t270Qeaj@alley> (raw)
In-Reply-To: <20221116161642.1670235-3-Jason@zx2c4.com>
On Wed 2022-11-16 17:16:38, Jason A. Donenfeld wrote:
> Rather than polling every second, use the new notifier to do this at
> exactly the right moment.
Great news!
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -752,26 +753,21 @@ early_param("debug_boot_weak_hash", debug_boot_weak_hash_enable);
>
> static bool filled_random_ptr_key __read_mostly;
> static siphash_key_t ptr_key __read_mostly;
> -static void fill_ptr_key_workfn(struct work_struct *work);
> -static DECLARE_DELAYED_WORK(fill_ptr_key_work, fill_ptr_key_workfn);
>
> -static void fill_ptr_key_workfn(struct work_struct *work)
> +static int fill_ptr_key(struct notifier_block *nb, unsigned long action, void *data)
> {
> - if (!rng_is_initialized()) {
> - queue_delayed_work(system_unbound_wq, &fill_ptr_key_work, HZ * 2);
> - return;
> - }
> -
> get_random_bytes(&ptr_key, sizeof(ptr_key));
>
> /* Pairs with smp_rmb() before reading ptr_key. */
> smp_wmb();
> WRITE_ONCE(filled_random_ptr_key, true);
> + return 0;
I believe that we should rather return NOTIFY_DONE here.
It is rather a formal change. The value is 0 as well.
That said, I have never really understood the difference between
NOTIFY_OK and NOTIFY_DONE.
> }
>
> static int __init vsprintf_init_hashval(void)
> {
> - fill_ptr_key_workfn(NULL);
> + static struct notifier_block fill_ptr_key_nb = { .notifier_call = fill_ptr_key };
> + notify_on_rng_initialized(&fill_ptr_key_nb);
> return 0;
> }
> subsys_initcall(vsprintf_init_hashval)
Anyway, the code looks good to me:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
next prev parent reply other threads:[~2022-11-18 14:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 16:16 [PATCH RFC v1 0/6] Use EFI variables for random seed Jason A. Donenfeld
2022-11-16 16:16 ` [PATCH RFC v1 1/6] random: add back async readiness notifier Jason A. Donenfeld
2022-11-16 16:16 ` [PATCH RFC v1 2/6] vsprintf: initialize siphash key using notifier Jason A. Donenfeld
2022-11-18 14:16 ` Petr Mladek [this message]
2022-11-18 14:20 ` Jason A. Donenfeld
2022-11-16 16:16 ` [PATCH RFC v1 3/6] efi: random: combine bootloader provided RNG seed with RNG protocol output Jason A. Donenfeld
2022-11-16 16:16 ` [PATCH RFC v1 4/6] efi: stub: use random seed from EFI variable Jason A. Donenfeld
2022-11-16 16:16 ` [PATCH RFC v1 5/6] efi: efivarfs: prohibit reading random seed variables Jason A. Donenfeld
2022-11-16 17:04 ` Ard Biesheuvel
2022-11-16 18:56 ` Jason A. Donenfeld
2022-11-16 19:42 ` James Bottomley
2022-11-16 20:08 ` Jason A. Donenfeld
2022-11-27 21:36 ` James Bottomley
2022-11-16 16:16 ` [PATCH RFC v1 6/6] efi: refresh non-volatile random seed when RNG is initialized Jason A. Donenfeld
2022-11-16 17:59 ` [PATCH RFC v1 0/6] Use EFI variables for random seed Lennart Poettering
2022-11-16 18:57 ` Jason A. Donenfeld
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=Y3eT0fd/t270Qeaj@alley \
--to=pmladek@suse.com \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=efault@gmx.de \
--cc=lennart@poettering.net \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
/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