Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

random: vDSO: Remove ifdeffery

Recent cleanups of the vDSO headers allow the unconditional inclusion of
vdso/datapage.h and the declarations it provides. This also means that
the declaration of vdso_k_rng_data is always visible and its usage does
not need to be guarded by ifdefs anymore. Instead use IS_ENABLED().

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Link: https://patch.msgid.link/20260227-vdso-header-cleanups-v2-15-35d60acf7410@linutronix.de

authored by

Thomas Weißschuh and committed by
Borislav Petkov (AMD)
260b98f7 fc880ff1

+6 -8
+6 -8
drivers/char/random.c
··· 56 56 #include <linux/sched/isolation.h> 57 57 #include <crypto/chacha.h> 58 58 #include <crypto/blake2s.h> 59 - #ifdef CONFIG_VDSO_GETRANDOM 60 59 #include <vdso/datapage.h> 61 - #endif 62 60 #include <asm/archrandom.h> 63 61 #include <asm/processor.h> 64 62 #include <asm/irq.h> ··· 265 267 if (next_gen == ULONG_MAX) 266 268 ++next_gen; 267 269 WRITE_ONCE(base_crng.generation, next_gen); 268 - #ifdef CONFIG_VDSO_GETRANDOM 270 + 269 271 /* base_crng.generation's invalid value is ULONG_MAX, while 270 272 * vdso_k_rng_data->generation's invalid value is 0, so add one to the 271 273 * former to arrive at the latter. Use smp_store_release so that this ··· 279 281 * because the vDSO side only checks whether the value changed, without 280 282 * actually using or interpreting the value. 281 283 */ 282 - smp_store_release((unsigned long *)&vdso_k_rng_data->generation, next_gen + 1); 283 - #endif 284 + if (IS_ENABLED(CONFIG_VDSO_GETRANDOM)) 285 + smp_store_release((unsigned long *)&vdso_k_rng_data->generation, next_gen + 1); 286 + 284 287 if (!static_branch_likely(&crng_is_ready)) 285 288 crng_init = CRNG_READY; 286 289 spin_unlock_irqrestore(&base_crng.lock, flags); ··· 731 732 if (system_dfl_wq) 732 733 queue_work(system_dfl_wq, &set_ready); 733 734 atomic_notifier_call_chain(&random_ready_notifier, 0, NULL); 734 - #ifdef CONFIG_VDSO_GETRANDOM 735 - WRITE_ONCE(vdso_k_rng_data->is_ready, true); 736 - #endif 735 + if (IS_ENABLED(CONFIG_VDSO_GETRANDOM)) 736 + WRITE_ONCE(vdso_k_rng_data->is_ready, true); 737 737 wake_up_interruptible(&crng_init_wait); 738 738 kill_fasync(&fasync, SIGIO, POLL_IN); 739 739 pr_notice("crng init done\n");