diff --git a/CHANGELOG.md b/CHANGELOG.md index 022066e6..f46e5b60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## Upcoming Release +## v0.19.1 + +### Fixed + +- [[#298](https://github.com/rust-vmm/kvm/pull/298)]: Fixed incorrect usage of `ioctl_wit_ref` in the + `create_device` method. Replace it with `ioctl_wit_mut_ref` as the passed parameter may be mutated by the + ioctl. + ## v0.19.0 ### Added diff --git a/Cargo.toml b/Cargo.toml index 3a68b116..84e69fe3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kvm-ioctls" -version = "0.19.0" +version = "0.19.1" authors = ["Amazon Firecracker Team "] description = "Safe wrappers over KVM ioctls" repository = "https://github.com/rust-vmm/kvm-ioctls" diff --git a/src/ioctls/vm.rs b/src/ioctls/vm.rs index e4c7c02a..39938ae5 100644 --- a/src/ioctls/vm.rs +++ b/src/ioctls/vm.rs @@ -22,11 +22,11 @@ use crate::ioctls::{KvmRunWrapper, Result}; use crate::kvm_ioctls::*; use vmm_sys_util::errno; use vmm_sys_util::eventfd::EventFd; +#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] +use vmm_sys_util::ioctl::ioctl; #[cfg(target_arch = "x86_64")] use vmm_sys_util::ioctl::ioctl_with_mut_ptr; -#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] -use vmm_sys_util::ioctl::{ioctl, ioctl_with_mut_ref}; -use vmm_sys_util::ioctl::{ioctl_with_ref, ioctl_with_val}; +use vmm_sys_util::ioctl::{ioctl_with_mut_ref, ioctl_with_ref, ioctl_with_val}; /// An address either in programmable I/O space or in memory mapped I/O space. /// @@ -1306,7 +1306,7 @@ impl VmFd { /// ``` pub fn create_device(&self, device: &mut kvm_create_device) -> Result { // SAFETY: Safe because we are calling this with the VM fd and we trust the kernel. - let ret = unsafe { ioctl_with_ref(self, KVM_CREATE_DEVICE(), device) }; + let ret = unsafe { ioctl_with_mut_ref(self, KVM_CREATE_DEVICE(), device) }; if ret == 0 { // SAFETY: We validated the return of the function creating the fd and we trust the // kernel.