From: Herbert Xu <herbert...@redhat.com>

not upstream: Set vdso is_ready later during boot process

Instead of setting vdso is_ready when the CRNG becomes ready, do
it later in the boot process as FIPS mode itself may not have been
set yet during the early-boot stages.

In particular, the CRNG gets initialised very early on arm64, even
before the early boot paramaters are parsed.

Delaying vdso is_ready setting on the other hand is harmless as
there is always a fallback code path that leads to getrandom(2).

Signed-off-by: Herbert Xu <herbert...@redhat.com>

diff --git a/drivers/char/random.c b/drivers/char/random.c
index blahblah..blahblah 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -121,6 +121,10 @@ EXPORT_SYMBOL(rng_is_initialized);
 static void __cold crng_set_ready(struct work_struct *work)
 {
        static_branch_enable(&crng_is_ready);
+#ifdef CONFIG_VDSO_GETRANDOM
+       if (!fips_enabled)
+               WRITE_ONCE(__arch_get_k_vdso_rng_data()->is_ready, true);
+#endif
 }
 
 /* Used by wait_for_random_bytes(), and considered an entropy collector, 
below. */
@@ -749,10 +753,6 @@ static void __cold _credit_init_bits(size_t bits)
                if (static_key_initialized && system_unbound_wq)
                        queue_work(system_unbound_wq, &set_ready);
                atomic_notifier_call_chain(&random_ready_notifier, 0, NULL);
-#ifdef CONFIG_VDSO_GETRANDOM
-               if (!fips_enabled)
-                       WRITE_ONCE(__arch_get_k_vdso_rng_data()->is_ready, 
true);
-#endif
                wake_up_interruptible(&crng_init_wait);
                kill_fasync(&fasync, SIGIO, POLL_IN);
                pr_notice("crng init done\n");

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3667

-- 
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to