The hwrng core asks for random data in the hwrng_register() call itself from commit d9e7972619. This doesn't play well with virtio -- the DRIVER_OK bit is only set by virtio core on a successful probe, and we're not yet out of our probe routine when this call is made. This causes the host to not acknowledge any requests we put in the virtqueue, and the insmod or kernel boot process just waits for data to arrive from the host, which never happens. The previous commit makes the hwrng core check for on an init function in the hwrng struct that's registered. If such a fn exists, the request for random data isn't made, and the stall when loading the module doesn't happen. CC: Kees Cook <keescook@xxxxxxxxxxxx> CC: Jason Cooper <jason@xxxxxxxxxxxxxx> CC: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> CC: <stable@xxxxxxxxxxxxxxx> # For 3.15 only Signed-off-by: Amit Shah <amit.shah@xxxxxxxxxx> --- drivers/char/hw_random/virtio-rng.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index f3e7150..c8471ef 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -93,6 +93,16 @@ static void virtio_cleanup(struct hwrng *rng) wait_for_completion(&vi->have_data); } +int virtio_init(struct hwrng *rng) +{ + /* + * Empty function to ensure hwrandom core does not ask us for + * randomness during hwrng_register phase. This prevents us + * from exiting to host without VIRTIO_CONFIG_S_DRIVER_OK set. + */ + return 0; +} + static int probe_common(struct virtio_device *vdev) { int err, index; @@ -111,6 +121,7 @@ static int probe_common(struct virtio_device *vdev) init_completion(&vi->have_data); vi->hwrng = (struct hwrng) { + .init = virtio_init, .read = virtio_read, .cleanup = virtio_cleanup, .priv = (unsigned long)vi, -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html