Skip to contentSkip to conversation

lib/random32: Use random_ready_callback for seeding.

RFC PATCH In review George Spelvin 1 participant 1 message Mar 28, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 22/50 lib/random32: Use random_ready_callback for seeding.

The whole seeding code was a mess, and triggered boot-time warnings about crng_init=0. Clean it up to use the random_ready_callback exported from drivers/char/random.c.

Particular changes:
* prandom_reseed_late() was dead code
* All the locking in __prandom_reseed is unnecessary and deleted
* Moved __prandom_timer to a more logical place, in addition to other changes. Sorry for the larger diff.
* Use round_jiffies on the reseed timer
* Use mod_timer is simpler to use than add_timer

Cc Daniel Borkmann <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Hannes Frederic Sowa <[email protected]>
---
 include/linux/random.h |   1 -
 lib/random32.c         | 157 +++++++++++++++++++----------------------
 2 files changed, 71 insertions(+), 87 deletions(-)
include/linux/random.h +0 -1
index 9e30f0bb3e50b..4a325f5cf298f 100644
@@ -112,7 +112,6 @@ unsigned long randomize_page(unsigned long start, unsigned long range);
 u32 prandom_u32(void);
 void prandom_bytes(void *buf, size_t nbytes);
 void prandom_seed(u32 seed);
-void prandom_reseed_late(void);
 
 struct rnd_state {
 	__u32 s[4];
lib/random32.c +71 -86

205 lines not on this page · raw message

Signature · 1 line
2.26.0