This replaces commit
4d75a68d22d7 ("UBUNTU: SAUCE: random: Make
getrandom() ready earlier") with a proper implementation.
We want to make getrandom() available when crng is initialized at least
to the first stage (not necessarily initialized from input_pool). To do
so we need to check this in wait_for_random_bytes() using a wait_event
with a proper timeout and try to generate some entropy when the timeout
expires to prevent the system to get stuck indefinitely.
This indefinite wait issue has been systematically reproduced on some
arm64 ThunderX boards. With this new patch applied the problem doesn't
seem to happen anymore.
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
do {
int ret;
- ret = wait_event_interruptible_timeout(crng_init_wait, crng_ready(), HZ);
+ ret = wait_event_interruptible_timeout(crng_init_wait, crng_init > 0, HZ);
if (ret)
return ret > 0 ? 0 : ret;
if (count > INT_MAX)
count = INT_MAX;
- if (!(flags & GRND_INSECURE) && !crng_ready()) {
+ if (!(flags & GRND_INSECURE) && (crng_init == 0)) {
if (flags & GRND_NONBLOCK)
return -EAGAIN;
ret = wait_for_random_bytes();