[PATCH next 7/7] random32: Simplify prandom_seed_full_state()
From: David Laight
Date: Mon Nov 02 2026 - 15:08:04 EST
Instead of offsetting values that would be treated as zero, just set
a bit that ensures they wont be treated as zero.
Reduces the number of initial states from just under 2**113 to 2**109.
This really shouldn't matter.
Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
---
lib/random32.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/random32.c b/lib/random32.c
index 1d6468045267..2c5c3519a0f8 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -118,13 +118,13 @@ void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state)
for_each_possible_cpu(i) {
struct rnd_state *state = per_cpu_ptr(pcpu_state, i);
- u32 seeds[4];
- get_random_bytes(&seeds, sizeof(seeds));
- state->s1 = __seed(seeds[0], 2U);
- state->s2 = __seed(seeds[1], 8U);
- state->s3 = __seed(seeds[2], 16U);
- state->s4 = __seed(seeds[3], 128U);
+ get_random_bytes(state, sizeof(state));
+ /* The values must not be near zero. */
+ state->s1 |= 0x100;
+ state->s2 |= 0x100;
+ state->s3 |= 0x100;
+ state->s4 |= 0x100;
prandom_warmup(state);
}
--
2.39.5