Repository navigation
Description
Summary
fuse::Fuse::write and fuse::Fuse::copy_file_range both return lx::Result<usize>, and fuse_copy_file_range_in::len is a u64, but Session::dispatch_core converts the returned byte count into fuse_write_out.size (u32) with out.try_into().unwrap(). On 64-bit hosts, a Fuse implementation returning a count larger than u32::MAX panics and aborts the VMM process instead of replying with -EIO. Found by formal verification.
Root Cause
In vm/devices/support/fs/fuse/src/session.rs and vm/devices/support/fs/fuse/src/session.rs, both FuseOperation::Write and FuseOperation::CopyFileRange unwrap out.try_into() when populating fuse_write_out:
FuseOperation::Write { arg, data } => {
let out = self.fs.write(&request, arg, data)?;
sender.send_arg(
request.unique(),
fuse_write_out {
size: out.try_into().unwrap(),
padding: 0,
},
)?;
} FuseOperation::CopyFileRange { arg } => {
let out = self.fs.copy_file_range(&request, arg)?;
sender.send_arg(
request.unique(),
fuse_write_out {
size: out.try_into().unwrap(),
padding: 0,
},
)?;
}The Fuse trait signatures for write and copy_file_range both return lx::Result<usize> without documenting a u32::MAX bound, and fuse_copy_file_range_in carries a 64-bit pub len: u64 even though its reply reuses fuse_write_out (pub size: u32).
Consequence
Because OpenVMM configures panic = 'abort' in both [profile.dev] and [profile.release] (Cargo.toml), any Fuse implementation on a 64-bit target whose write or copy_file_range returns a count above u32::MAX terminates the VMM process instead of failing the FUSE operation cleanly. OpenVMM's built-in VirtioFs implementation caps guest write buffers at 1 MiB (MAX_GUEST_BUFFER_SIZE) and leaves copy_file_range unimplemented (ENOSYS), so this is not reachable through VirtioFs today.
Reproduction
Initialize a fuse::Session over a minimal Fuse implementation whose write and copy_file_range return Ok(u32::MAX as usize + 1), then dispatch a FUSE_WRITE or FUSE_COPY_FILE_RANGE request. On commit 9d64daad3cbe14fb0591081b73c6c9648e18d0fb, Session::dispatch panics at vm/devices/support/fs/fuse/src/session.rs:213:46 (or session.rs:396:46) with called Result::unwrap() on an Err value: TryFromIntError(PosOverflow). Running cargo nextest run --profile agent -p fuse -E 'test(dispatch_write_and_copy_beyond_u32_fail)' reproduces the panic before fix.patch and passes afterward.
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Add a
Session::reply_count(count: usize) -> lx::Result<u32>helper that convertscountviatry_into()and, on overflow, logs a rate-limited error viatracelimit::error_ratelimited!and returnsErr(lx::Error::EIO), and use it in bothFuseOperation::WriteandFuseOperation::CopyFileRangeso oversized counts produce a standard-EIOFUSE error reply instead of panicking.Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch