# RUSTSEC-2024-0428: Undefined behaviour in kvm\_ioctls::ioctls::vm::VmFd::create\_device

- Database: RustSec
- Published: 2024-12-05
- Modified: 2025-10-28

## Also published as

- [GHSA-3QX8-RV27-J6GP](https://cve.now/GHSA-3QX8-RV27-J6GP.md) (GitHub)

## Affected versions

- kvm-ioctls (crates.io): fixed in 0.19.1

## Description

An issue was identified in the `VmFd::create_device function`, leading to undefined behavior and miscompilations on rustc 1.82.0 and newer due to the function's violation of Rust's pointer safety rules.

The function downcasted a mutable reference to its `struct kvm_create_device` argument to an immutable pointer, and then proceeded to pass this pointer to a mutating system call. Rustc 1.82.0 and newer elides subsequent reads of this structure's fields, meaning code will not see the value written by the kernel into the `fd` member. Instead, the code will observe the value that this field was initialized to prior to calling `VmFd::create_device` (usually, 0).

The issue started in kvm-ioctls 0.1.0 and was fixed in 0.19.1 by correctly using
a mutable pointer.

## References

- https://crates.io/crates/kvm-ioctls
- https://rustsec.org/advisories/RUSTSEC-2024-0428.html
- https://github.com/rust-vmm/kvm/pull/298

Page: https://cve.now/RUSTSEC-2024-0428

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
