random: do not split fast init input in add_hwgenerator_randomness()
authorJan Varho <jan.varho@gmail.com>
Mon, 4 Apr 2022 16:42:30 +0000 (19:42 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 09:46:37 +0000 (11:46 +0200)
commit8a4646c15d4fbf2afaea29bbbafaf48b8554034e
tree1c4e57ba040be8e7b60354cc0081c7cea4dbecf0
parentbba3aac2241f5f3792c405e5a01e7a9fdbc5e249
random: do not split fast init input in add_hwgenerator_randomness()

commit 527a9867af29ff89f278d037db704e0ed50fb666 upstream.

add_hwgenerator_randomness() tries to only use the required amount of input
for fast init, but credits all the entropy, rather than a fraction of
it. Since it's hard to determine how much entropy is left over out of a
non-unformly random sample, either give it all to fast init or credit
it, but don't attempt to do both. In the process, we can clean up the
injection code to no longer need to return a value.

Signed-off-by: Jan Varho <jan.varho@gmail.com>
[Jason: expanded commit message]
Fixes: 73c7733f122e ("random: do not throw away excess input to crng_fast_load")
Cc: stable@vger.kernel.org # 5.17+, requires af704c856e88
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c