Patch "hwrng: virtio - don't wait on cleanup" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    hwrng: virtio - don't wait on cleanup

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     hwrng-virtio-don-t-wait-on-cleanup.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a406077dac0b95e2a23e07bd5b7c2612d68b3bb0
Author: Laurent Vivier <lvivier@xxxxxxxxxx>
Date:   Thu Oct 28 12:11:09 2021 +0200

    hwrng: virtio - don't wait on cleanup
    
    [ Upstream commit 2bb31abdbe55742c89f4dc0cc26fcbc8467364f6 ]
    
    When virtio-rng device was dropped by the hwrng core we were forced
    to wait the buffer to come back from the device to not have
    remaining ongoing operation that could spoil the buffer.
    
    But now, as the buffer is internal to the virtio-rng we can release
    the waiting loop immediately, the buffer will be retrieve and use
    when the virtio-rng driver will be selected again.
    
    This avoids to hang on an rng_current write command if the virtio-rng
    device is blocked by a lack of entropy. This allows to select
    another entropy source if the current one is empty.
    
    Signed-off-by: Laurent Vivier <lvivier@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20211028101111.128049-3-lvivier@xxxxxxxxxx
    Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Stable-dep-of: ac52578d6e8d ("hwrng: virtio - Fix race on data_avail and actual data")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index 23149e94d621f..c8f5a3392e48c 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -81,6 +81,11 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
 		ret = wait_for_completion_killable(&vi->have_data);
 		if (ret < 0)
 			return ret;
+		/* if vi->data_avail is 0, we have been interrupted
+		 * by a cleanup, but buffer stays in the queue
+		 */
+		if (vi->data_avail == 0)
+			return read;
 
 		chunk = min_t(unsigned int, size, vi->data_avail);
 		memcpy(buf + read, vi->data, chunk);
@@ -104,7 +109,7 @@ static void virtio_cleanup(struct hwrng *rng)
 	struct virtrng_info *vi = (struct virtrng_info *)rng->priv;
 
 	if (vi->busy)
-		wait_for_completion(&vi->have_data);
+		complete(&vi->have_data);
 }
 
 static int probe_common(struct virtio_device *vdev)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux