Hi!
We are a team of researchers studying memory safety in Rust. As part of our ongoing research, we tested ioctl-rs (version: 0.2.0) and found that the following code snippet is reported as undefined behavior by Miri:
Minimal Problematic Snippet
#![feature(allocator_api)]
extern crate alloc;
use ioctl_rs::*;
fn main() {
let v1 = 50i32;
let v2 = tiocmget(v1);
}
Miri Error Excerpt
Running `/home/rose/.rustup/toolchains/nightly-2025-12-06-x86_64-unknown-linux-gnu/bin/cargo-miri runner target/miri/x86_64-unknown-linux-gnu/debug/case10`
error: Undefined Behavior: reading memory at alloc119[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
--> /home/rose/projects/lifesonar-tests1/new_crates/analyze-poc/ioctl-rs-0.2.0/src/lib.rs:45:36
|
Root-Cause Hypothesis
After analyzing the Miri report and the source code, we assume the UB is rooted in:
- Suspect location: src/lib.rs:45
- Invariant being broken: uninitialized memory read (use of mem::uninitialized)
- Causality chain:
tiocmget uses mem::uninitialized to create bits, passes &mut bits into ioctl, Miri reports reading uninitialized memory
Command used:
MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-tree-borrows" RUSTFLAGS=-Awarnings RUST_BACKTRACE=1 cargo miri run
Possible Fix
Use MaybeUninit to replace mem::uninitialized()
We would appreciate it if you could take a look and confirm whether this behavior indicates a real issue, or if it is a false positive / expected limitation of Miri.
Thank you very much for your time and for maintaining this great project!
Hi!
We are a team of researchers studying memory safety in Rust. As part of our ongoing research, we tested ioctl-rs (version: 0.2.0) and found that the following code snippet is reported as undefined behavior by Miri:
Minimal Problematic Snippet
Miri Error Excerpt
Root-Cause Hypothesis
After analyzing the Miri report and the source code, we assume the UB is rooted in:
tiocmgetusesmem::uninitializedto createbits, passes&mut bitsintoioctl, Miri reports reading uninitialized memoryCommand used:
MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-tree-borrows" RUSTFLAGS=-Awarnings RUST_BACKTRACE=1 cargo miri runPossible Fix
Use
MaybeUninitto replacemem::uninitialized()We would appreciate it if you could take a look and confirm whether this behavior indicates a real issue, or if it is a false positive / expected limitation of Miri.
Thank you very much for your time and for maintaining this great project!