[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176202647299.2601451.467843181214566256.tip-bot2@tip-bot2>
Date: Sat, 01 Nov 2025 19:47:52 -0000
From: tip-bot2 for Thomas Weißschuh <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: thomas.weissschuh@...utronix.de, Thomas Gleixner <tglx@...utronix.de>,
Andreas Larsson <andreas@...sler.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: timers/vdso] random: vDSO: Only access vDSO datapage after
random_init()
The following commit has been merged into the timers/vdso branch of tip:
Commit-ID: e5ec11b3da6d37dc2150007b34afca871c6b8fb4
Gitweb: https://git.kernel.org/tip/e5ec11b3da6d37dc2150007b34afca871c6b8fb4
Author: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
AuthorDate: Tue, 14 Oct 2025 08:49:05 +02:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Sat, 01 Nov 2025 20:44:05 +01:00
random: vDSO: Only access vDSO datapage after random_init()
Upcoming changes to the generic vDSO library will mean that the vDSO
datapage will not yet be usable during early boot.
Introduce a static key which prevents early accesses.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Tested-by: Andreas Larsson <andreas@...sler.com>
Reviewed-by: Andreas Larsson <andreas@...sler.com>
Link: https://patch.msgid.link/20251014-vdso-sparc64-generic-2-v4-19-e0607bf49dea@linutronix.de
---
drivers/char/random.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 73c53a4..f39524f 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -88,6 +88,7 @@ static DEFINE_STATIC_KEY_FALSE(crng_is_ready);
static DECLARE_WAIT_QUEUE_HEAD(crng_init_wait);
static struct fasync_struct *fasync;
static ATOMIC_NOTIFIER_HEAD(random_ready_notifier);
+static DEFINE_STATIC_KEY_FALSE(random_vdso_is_ready);
/* Control how we warn userspace. */
static struct ratelimit_state urandom_warning =
@@ -252,6 +253,9 @@ static void random_vdso_update_generation(unsigned long next_gen)
if (!IS_ENABLED(CONFIG_VDSO_GETRANDOM))
return;
+ if (!static_branch_likely(&random_vdso_is_ready))
+ return;
+
/* base_crng.generation's invalid value is ULONG_MAX, while
* vdso_k_rng_data->generation's invalid value is 0, so add one to the
* former to arrive at the latter. Use smp_store_release so that this
@@ -274,6 +278,9 @@ static void random_vdso_set_ready(void)
if (!IS_ENABLED(CONFIG_VDSO_GETRANDOM))
return;
+ if (!static_branch_likely(&random_vdso_is_ready))
+ return;
+
WRITE_ONCE(vdso_k_rng_data->is_ready, true);
}
@@ -925,6 +932,9 @@ void __init random_init(void)
_mix_pool_bytes(&entropy, sizeof(entropy));
add_latent_entropy();
+ if (IS_ENABLED(CONFIG_VDSO_GETRANDOM))
+ static_branch_enable(&random_vdso_is_ready);
+
/*
* If we were initialized by the cpu or bootloader before jump labels
* or workqueues are initialized, then we should enable the static
@@ -934,8 +944,10 @@ void __init random_init(void)
crng_set_ready(NULL);
/* Reseed if already seeded by earlier phases. */
- if (crng_ready())
+ if (crng_ready()) {
crng_reseed(NULL);
+ random_vdso_set_ready();
+ }
WARN_ON(register_pm_notifier(&pm_notifier));
Powered by blists - more mailing lists