cloud-hypervisor/virtio-devices
Alyssa Ross 46d2e22e3a
virtio-devices: fix vhost-user connection double close
Closing a file descriptor while the std object representing it still
exists is a violation of the invariants of those APIs.  After
shutdown() returns, the device will be dropped, and because that
object still exists, it will try to close the file descriptor again.
This is unsafe, because the file descriptor number might have been
reused, so an unrelated file descriptor could be unexpectedly closed.

As a result, the following error was being produced if debug
assertions were enabled when shutting down a VM with a vhost-user
device:

	fatal runtime error: IO Safety violation: owned file descriptor already closed

In all cases, the device is dropped shortly after shutdown() is
called, so it shouldn't make any difference to close the descriptor in
shutdown() instead of just letting the file object be dropped when the
device is.  Even when migrating, shutdown() isn't called until after
the snapshot is taken, so it should be fine to wait for drop, though
I'm haven't tested this as I don't know any vhost-user devices that
support VHOST_F_LOG_ALL.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-09-25 19:19:27 +02:00
..
src virtio-devices: fix vhost-user connection double close 2024-09-25 19:19:27 +02:00
build.rs build: Add "fuzzing" as a valid cfg(..) attribute 2024-05-08 08:10:28 +00:00
Cargo.toml build: Bump anyhow from 1.0.86 to 1.0.87 2024-09-10 00:03:10 +00:00