]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwrng: virtio - add an internal buffer
authorLaurent Vivier <lvivier@redhat.com>
Thu, 28 Oct 2021 10:11:08 +0000 (12:11 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2023 06:37:17 +0000 (08:37 +0200)
commit6fe732764a58d3729bd22dde789f11bf3a645be6
tree6603d3f30a1a358e46789e51861950478729ac57
parent2cbfb51d2c7e2b7d56a1d90e343a3794b6601b16
hwrng: virtio - add an internal buffer

[ Upstream commit bf3175bc50a3754dc427e2f5046e17a9fafc8be7 ]

hwrng core uses two buffers that can be mixed in the
virtio-rng queue.

If the buffer is provided with wait=0 it is enqueued in the
virtio-rng queue but unused by the caller.
On the next call, core provides another buffer but the
first one is filled instead and the new one queued.
And the caller reads the data from the new one that is not
updated, and the data in the first one are lost.

To avoid this mix, virtio-rng needs to use its own unique
internal buffer at a cost of a data copy to the caller buffer.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Link: https://lore.kernel.org/r/20211028101111.128049-2-lvivier@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Stable-dep-of: ac52578d6e8d ("hwrng: virtio - Fix race on data_avail and actual data")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/char/hw_random/virtio-rng.c