virtio/rng: return at least one byte of entropy
In contrast to the original v0.9 virtio spec (which was rather vague),
the virtio 1.0+ spec demands that a RNG request returns at least one
byte:
"The device MUST place one or more random bytes into the buffer, but it
MAY use less than the entire buffer length."
Our current implementation does not prevent returning zero bytes, which
upsets an assert in EDK II. /dev/urandom should always return at least
256 bytes of entropy, unless interrupted by a signal.
Repeat the read if that happens, and give up if that fails as well.
This makes sure we return some entropy and become spec compliant.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reported-by: Sami Mujawar <sami.mujawar@arm.com>
Link: https://lore.kernel.org/r/20230524112207.586101-3-andre.przywara@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
1 file changed