Repository navigation
Description
Summary
In fuse::Session::dispatch_helper, the FuseOperation::Ioctl arm calls self.fs.ioctl(&request, arg, data)? and validates the returned output buffer out.1 against arg.out_size, but then passes the request's input buffer data instead of &out.1 to sender.send_arg_data(...). As a result, successful FUSE_IOCTL replies echo the request's input bytes rather than returning the filesystem's ioctl output. Found by static code inspection and unit testing.
Root Cause
In vm/devices/support/fs/fuse/src/session.rs#L336-L353, Session::dispatch_helper unpacks FuseOperation::Ioctl { arg, data }, receives out: (i32, Vec<u8>) from self.fs.ioctl(...), checks out.1.len() > arg.out_size as usize, and then mistakenly passes data on session.rs#L351:
FuseOperation::Ioctl { arg, data } => {
let out = self.fs.ioctl(&request, arg, data)?;
if out.1.len() > arg.out_size as usize {
return Err(lx::Error::EINVAL.into());
}
// As far as I can tell, the fields other than result are only used for CUSE.
sender.send_arg_data(
request.unique(),
fuse_ioctl_out {
result: out.0,
flags: 0,
in_iovs: 0,
out_iovs: 0,
},
data,
)?;
}Consequence
Any fuse::Fuse implementation whose ioctl callback succeeds receives wrong reply data on the wire: the fuse_ioctl_out.result field carries out.0, but the trailing payload bytes carry the request's input data (arg.in_size bytes) instead of the filesystem's output out.1 (and can even exceed arg.out_size when arg.in_size > arg.out_size). Current built-in filesystems in virtiofs (VirtioFs, DormantMicrovmFs, and SectionFs) do not override Fuse::ioctl, which defaults to Err(lx::Error::ENOSYS), so they return ENOSYS before reaching send_arg_data. Note that ReplySender::send_arg_data also has a separate defect where fuse_out_header.len omits the trailing data length, tracked in the related issue below.
Reproduction
Implement fuse::Fuse with an ioctl method returning Ok((42, vec![9, 9, 9, 9])), initialize a Session, and dispatch a FUSE_IOCTL request with in_size = 8, out_size = 4, and input payload [1, 2, 3, 4, 5, 6, 7, 8].
The regression test session::tests::dispatch_ioctl_replies_with_file_system_output in fix.patch runs this scenario via cargo nextest run --profile agent -p fuse. Before the fix, the test fails because the reply payload bytes following fuse_ioctl_out are [1, 2, 3, 4, 5, 6, 7, 8] instead of [9, 9, 9, 9]; after the fix, the test passes and the reply payload carries [9, 9, 9, 9].
Related: #1616.
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Pass
&out.1instead ofdataas the data slice argument tosender.send_arg_datain theFuseOperation::Ioctlarm ofSession::dispatch_helper. Becauseout.1.len() <= arg.out_size as usizeis already checked immediately beforehand, the reply payload will carry the filesystem's output bounded byarg.out_size.Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch