mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-19 12:24:34 +08:00
random: only call crng_finalize_init() for primary_crng
crng_finalize_init() returns instantly if it is called for another pool than primary_crng. The test whether crng_finalize_init() is still required can be moved to the relevant caller in crng_reseed(), and crng_need_final_init can be reset to false if crng_finalize_init() is called with workqueues ready. Then, no previous callsite will call crng_finalize_init() unless it is needed, and we can get rid of the superfluous function parameter. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
ebf7606388
commit
9d5505f1ee
@ -800,10 +800,8 @@ static void __init crng_initialize_primary(void)
|
||||
primary_crng.init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
|
||||
}
|
||||
|
||||
static void crng_finalize_init(struct crng_state *crng)
|
||||
static void crng_finalize_init(void)
|
||||
{
|
||||
if (crng != &primary_crng || crng_init >= 2)
|
||||
return;
|
||||
if (!system_wq) {
|
||||
/* We can't call numa_crng_init until we have workqueues,
|
||||
* so mark this for processing later. */
|
||||
@ -814,6 +812,7 @@ static void crng_finalize_init(struct crng_state *crng)
|
||||
invalidate_batched_entropy();
|
||||
numa_crng_init();
|
||||
crng_init = 2;
|
||||
crng_need_final_init = false;
|
||||
process_random_ready_list();
|
||||
wake_up_interruptible(&crng_init_wait);
|
||||
kill_fasync(&fasync, SIGIO, POLL_IN);
|
||||
@ -980,7 +979,8 @@ static void crng_reseed(struct crng_state *crng, bool use_input_pool)
|
||||
memzero_explicit(&buf, sizeof(buf));
|
||||
WRITE_ONCE(crng->init_time, jiffies);
|
||||
spin_unlock_irqrestore(&crng->lock, flags);
|
||||
crng_finalize_init(crng);
|
||||
if (crng == &primary_crng && crng_init < 2)
|
||||
crng_finalize_init();
|
||||
}
|
||||
|
||||
static void _extract_crng(struct crng_state *crng, u8 out[CHACHA_BLOCK_SIZE])
|
||||
@ -1697,7 +1697,7 @@ int __init rand_initialize(void)
|
||||
{
|
||||
init_std_data();
|
||||
if (crng_need_final_init)
|
||||
crng_finalize_init(&primary_crng);
|
||||
crng_finalize_init();
|
||||
crng_initialize_primary();
|
||||
crng_global_init_time = jiffies;
|
||||
if (ratelimit_disable) {
|
||||
|
Loading…
Reference in New Issue
Block a user