linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw_random: don't wait on add_early_randomness()
@ 2019-09-17  9:54 Laurent Vivier
  2019-09-17 12:40 ` Herbert Xu
  2019-09-17 15:36 ` Theodore Y. Ts'o
  0 siblings, 2 replies; 5+ messages in thread
From: Laurent Vivier @ 2019-09-17  9:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: Amit Shah, linux-crypto, Matt Mackall, Herbert Xu, Laurent Vivier

add_early_randomness() is called by hwrng_register() when the
hardware is added. If this hardware and its module are present
at boot, and if there is no data available the boot hangs until
data are available and can't be interrupted.

To avoid that, call rng_get_data() in non-blocking mode (wait=0)
from add_early_randomness().

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 drivers/char/hw_random/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 9044d31ab1a1..8d53b8ef545c 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -67,7 +67,7 @@ static void add_early_randomness(struct hwrng *rng)
 	size_t size = min_t(size_t, 16, rng_buffer_size());
 
 	mutex_lock(&reading_mutex);
-	bytes_read = rng_get_data(rng, rng_buffer, size, 1);
+	bytes_read = rng_get_data(rng, rng_buffer, size, 0);
 	mutex_unlock(&reading_mutex);
 	if (bytes_read > 0)
 		add_device_randomness(rng_buffer, bytes_read);
-- 
2.21.0


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

end of thread, other threads:[~2019-09-20 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-17  9:54 [PATCH] hw_random: don't wait on add_early_randomness() Laurent Vivier
2019-09-17 12:40 ` Herbert Xu
2019-09-17 13:02   ` Laurent Vivier
2019-09-20 13:03     ` Herbert Xu
2019-09-17 15:36 ` Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).