diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-11-30 03:14:15 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-12-04 14:37:08 +0100 |
commit | b83e45fd065c3cfdb8cc0179bbddf296ce4d4fda (patch) | |
tree | 13514b16ce1e7863781f00b74c0c6b5c385ba246 | |
parent | 1c21fe00eda76e4081535c739cf9f4bbb5dcb0ce (diff) | |
download | linux-b83e45fd065c3cfdb8cc0179bbddf296ce4d4fda.tar.bz2 |
random: mix in cycle counter when jitter timer fires
Rather than just relying on interaction between cache lines of the timer
and the main loop, also explicitly take into account the fact that the
timer might fire at some time that's hard to predict, due to scheduling,
interrupts, or cross-CPU conditions. Mix in a cycle counter during the
firing of the timer, in addition to the existing one during the
scheduling of the timer. It can't hurt and can only help.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | drivers/char/random.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 3db4bf6f9b43..36d29da31af0 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1251,7 +1251,9 @@ struct entropy_timer_state { static void __cold entropy_timer(struct timer_list *timer) { struct entropy_timer_state *state = container_of(timer, struct entropy_timer_state, timer); + unsigned long entropy = random_get_entropy(); + mix_pool_bytes(&entropy, sizeof(entropy)); if (atomic_inc_return(&state->samples) % state->samples_per_bit == 0) credit_init_bits(1); } |