android_kernel_oneplus_msm8998/drivers/char/hw_random
Laurent Vivier c648d43500 hwrng: core - don't wait on add_early_randomness()
commit 78887832e76541f77169a24ac238fccb51059b63 upstream.

add_early_randomness() is called by hwrng_register() when the
hardware is added. If this hardware and its module are present
at boot, and if there is no data available the boot hangs until
data are available and can't be interrupted.

For instance, in the case of virtio-rng, in some cases the host can be
not able to provide enough entropy for all the guests.

We can have two easy ways to reproduce the problem but they rely on
misconfiguration of the hypervisor or the egd daemon:

- if virtio-rng device is configured to connect to the egd daemon of the
host but when the virtio-rng driver asks for data the daemon is not
connected,

- if virtio-rng device is configured to connect to the egd daemon of the
host but the egd daemon doesn't provide data.

The guest kernel will hang at boot until the virtio-rng driver provides
enough data.

To avoid that, call rng_get_data() in non-blocking mode (wait=0)
from add_early_randomness().

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Fixes: d9e7972619 ("hwrng: add randomness to system from rng...")
Cc: <stable@vger.kernel.org>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-05 12:27:55 +02:00
..
amd-rng.c
atmel-rng.c
bcm63xx-rng.c
bcm2835-rng.c
core.c hwrng: core - don't wait on add_early_randomness() 2019-10-05 12:27:55 +02:00
exynos-rng.c hwrng: exynos - use __maybe_unused to hide pm functions 2018-02-25 11:03:47 +01:00
geode-rng.c
intel-rng.c
iproc-rng200.c
ixp4xx-rng.c
Kconfig hwrng: stm32 - add support for STM32 HW RNG 2015-10-14 22:23:36 +08:00
Makefile hwrng: stm32 - add support for STM32 HW RNG 2015-10-14 22:23:36 +08:00
msm-rng.c
mxc-rnga.c hwrng: mxc-rnga - Use the preferred format for kzalloc 2015-09-21 22:00:39 +08:00
n2-asm.S
n2-drv.c
n2rng.h
nomadik-rng.c
octeon-rng.c hwrng: octeon - Use devm_hwrng_register 2015-09-21 22:00:38 +08:00
omap-rng.c hwrng: omap - Only fail if pm_runtime_get_sync returns < 0 2016-10-31 04:14:00 -06:00
omap3-rom-rng.c
pasemi-rng.c hwrng: Fix module autoload for OF platform drivers 2015-09-21 22:00:39 +08:00
powernv-rng.c
ppc4xx-rng.c hwrng: Fix module autoload for OF platform drivers 2015-09-21 22:00:39 +08:00
pseries-rng.c
st-rng.c hwrng: st - Improve FIFO size/depth description 2015-10-08 21:42:25 +08:00
stm32-rng.c hwrng: stm32 - add reset during probe 2018-05-30 07:49:14 +02:00
timeriomem-rng.c
tpm-rng.c
tx4939-rng.c
via-rng.c x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros 2018-06-16 09:54:24 +02:00
virtio-rng.c hwrng: virtio - Avoid repeated init of completion 2019-04-27 09:33:52 +02:00
xgene-rng.c hwrng: xgene - fix handling platform_get_irq 2015-09-21 22:57:37 +08:00