Repository navigation
Description
Summary
fuse::ReplySender::send_arg_data sends three slices (fuse_out_header, the serialized arg struct, and data), but computes fuse_out_header.len using only size_of_val(&arg) and omits data.len(). Any reply sent via send_arg_data with a non-empty data buffer therefore carries a fuse_out_header.len field smaller than the actual message written to the client. Found by static code inspection and unit testing.
Root Cause
In vm/devices/support/fs/fuse/src/reply.rs#L56-L72, ReplySender::send_arg_data constructs the reply header via make_header on reply.rs#L64 with extra_len = size_of_val(&arg), omitting data.len() even though IoSlice::new(data) is transmitted on line 70:
fn send_arg_data<T: std::fmt::Debug + IntoBytes + Immutable + KnownLayout>(
&mut self,
unique: u64,
arg: T,
data: &[u8],
) -> io::Result<()> {
tracing::trace!(unique, ?arg, len = data.len(), "reply");
let header = make_header(unique, size_of_val(&arg), 0);
let header = header.as_bytes();
let arg = arg.as_bytes();
self.send(&[
io::IoSlice::new(header),
io::IoSlice::new(arg),
io::IoSlice::new(data),
])
}By contrast, send_arg, send_data, and send_string in the same trait include their full payload sizes in make_header.
Consequence
When send_arg_data sends a non-empty data buffer, the FUSE client receives a reply whose fuse_out_header.len understates the wire message length by data.len() bytes (for example, len = 32 for a 36-byte FUSE_IOCTL reply consisting of a 16-byte fuse_out_header, a 16-byte fuse_ioctl_out, and 4 bytes of data), causing the client to truncate or reject the reply. Within fuse::Session, only the FuseOperation::Ioctl arm in vm/devices/support/fs/fuse/src/session.rs#L343-L352 invokes send_arg_data, and current built-in filesystems in virtiofs (VirtioFs, DormantMicrovmFs, and SectionFs) leave Fuse::ioctl at its default ENOSYS implementation, so only Fuse implementations with a custom ioctl returning output data (or direct callers of ReplySender::send_arg_data) hit this mismatch.
Reproduction
Call ReplySender::send_arg_data(1, fuse_ioctl_out { result: 42, flags: 0, in_iovs: 0, out_iovs: 0 }, &[9, 9, 9, 9]) on a capturing ReplySender implementation and compare the len field of the resulting fuse_out_header with the total length of the sent buffer.
The regression test reply::tests::reply_header_len_is_reply_len in fix.patch checks all six ReplySender helpers via cargo nextest run --profile agent -p fuse. Before the fix, send_empty, send_error, send_arg, send_data, and send_string pass, while send_arg_data fails with left: 32 vs right: 36; after the fix, all assertions pass.
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Update
ReplySender::send_arg_datato callmake_header(unique, size_of_val(&arg) + data.len(), 0)so thatfuse_out_header.lenincludes the header, the serialized argument struct, and the trailingdataslice. Add unit tests verifying that everyReplySenderhelper setsfuse_out_header.lenequal to the total number of bytes sent.Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch