Messages in this thread Patch in this message | | | From | Jan Varho <> | Subject | [PATCH] random: fix add_hwgenerator_randomness entropy accounting | Date | Mon, 4 Apr 2022 18:04:42 +0300 |
| |
add_hwgenerator_randomness tries to only use the required amound of input for fast init, but credits all the entropy if even a byte was left over.
Fix by not crediting entropy if any input was consumed for fast init.
Signed-off-by: Jan Varho <jan.varho@gmail.com> --- drivers/char/random.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c index 1d8242969751..fb20178f1044 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1141,12 +1141,10 @@ void add_hwgenerator_randomness(const void *buffer, size_t count, size_t entropy) { if (unlikely(crng_init == 0 && entropy < POOL_MIN_BITS)) { - size_t ret = crng_pre_init_inject(buffer, count, true); - mix_pool_bytes(buffer, ret); - count -= ret; - buffer += ret; - if (!count || crng_init == 0) + if (crng_pre_init_inject(buffer, count, true) > 0) { + mix_pool_bytes(buffer, count); return; + } } /* -- 2.25.1
| |