All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] random: mix build-time latent entropy into pool at init
@ 2022-03-31 15:07 Jason A. Donenfeld
  2022-03-31 15:26 ` [PATCH v2] " Jason A. Donenfeld
  0 siblings, 1 reply; 8+ messages in thread
From: Jason A. Donenfeld @ 2022-03-31 15:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jason A. Donenfeld, Dominik Brodowski, Theodore Ts'o

Prior, the "input_pool_data" array needed no real initialization, and so
it was easy to mark it with __latent_entropy to populate it during
compile-time. In switching to using a hash function, this required us to
specifically initialize it to some specific state, which means we
dropped the __latent_entropy attribute. An unfortunate side effect was
this meant the pool was no longer seeded using compile-time random data.
In order to bring this back, we declare an array in rand_initialize()
with __latent_entropy and call mix_pool_bytes() on that at init, which
accomplishes the same thing as before.

Fixes: 6e8ec2552c7d ("random: use computational hash for entropy extraction")
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/char/random.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 40107f8b9e9e..3a245686809c 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -975,6 +975,11 @@ int __init rand_initialize(void)
 	bool arch_init = true;
 	unsigned long rv;
 
+#if defined(LATENT_ENTROPY_PLUGIN)
+	static u8 init_latent_entropy[BLAKE2S_BLOCK_SIZE] __latent_entropy;
+	_mix_pool_bytes(init_latent_entropy, sizeof(init_latent_entropy));
+#endif
+
 	for (i = 0; i < BLAKE2S_BLOCK_SIZE; i += sizeof(rv)) {
 		if (!arch_get_random_seed_long_early(&rv) &&
 		    !arch_get_random_long_early(&rv)) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-04 23:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 15:07 [PATCH] random: mix build-time latent entropy into pool at init Jason A. Donenfeld
2022-03-31 15:26 ` [PATCH v2] " Jason A. Donenfeld
2022-03-31 16:02   ` Michael Brooks
2022-03-31 18:21     ` Theodore Ts'o
2022-03-31 17:55   ` Theodore Ts'o
2022-04-02  4:44   ` Sandy Harris
2022-04-02 13:48     ` Jason A. Donenfeld
2022-04-04 23:27     ` Eric Biggers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.