mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
02f146fef8
DeviceFd::get_device_attr should be marked as unsafe, because it allows writing to an arbitrary address. I have opened a kvm-ioctls PR[1] to fix this. The hypervisor crate was using the function unsafely by passing it addresses of immutable variables. I noticed this because an optimisation change[2] in Rust 1.80.0 caused the kvm::aarch64::gic::tests::test_get_set_icc_regs test to start failing when built in release mode. To fix this, I've broken up the _access functions into _set and _get variants, with the _get variant using a pointer to a mutable variable. This has the side effect of making these functions a bit nicer to use, because the caller now has no need to use references at all, for either getting or setting. [1]: https://github.com/rust-vmm/kvm-ioctls/pull/273 [2]: https://github.com/rust-lang/rust/commit/d2d24e395a1e4fcee62ca17bf4cbddb1f903af97 Signed-off-by: Alyssa Ross <hi@alyssa.is>