]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
virtio_random(4): Fix random(4) integration
authorcem <cem@FreeBSD.org>
Tue, 4 Jun 2019 00:01:37 +0000 (00:01 +0000)
committercem <cem@FreeBSD.org>
Tue, 4 Jun 2019 00:01:37 +0000 (00:01 +0000)
commite114a5fd29b0a505f8796295f0fed416d7802a6f
tree7a337d31cdf681c3b011297f469fb27d68a977fc
parent286888d78c54e76fa12bc953a58aa0526f58b7cb
virtio_random(4): Fix random(4) integration

random(4) masks unregistered entropy sources.  Prior to this revision,
virtio_random(4) did not correctly register a random_source and did not
function as a source of entropy.

Random source registration for loadable pure sources requires registering a
poll callback, which is invoked periodically by random(4)'s harvestq
kthread.  The periodic poll makes virtio_random(4)'s periodic entropy
collection redundant, so this revision removes the callout.

The current random source API is somewhat limiting, so simply fail to attach
any virtio_random devices if one is already registered as a source.  This
scenario is expected to be uncommon.

While here, handle the possibility of short reads from the hypervisor random
device gracefully / correctly.  It is not clear why a hypervisor would
return a short read or if it is allowed by spec, but we may as well handle
it.

Reviewed by: bryanv (earlier version), markm
Security: yes (note: many other "pure" random sources remain broken)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20419
sys/dev/virtio/random/virtio_random.c