Repository navigation
Description
Summary
fuse::Request::read_operation subtracts size_of::<fuse_in_header>() (40 bytes) from header.len as usize without checking that header.len is at least the header size when parsing FUSE_INIT. A guest-supplied FUSE_INIT message with header.len < 40 triggers an unsigned subtraction underflow, panicking in builds with overflow checks enabled and wrapping payload_len in release builds. Found by testing (also blocks formal verification).
Root Cause
In vm/devices/support/fs/fuse/src/request.rs#L133-L160, Request::read_operation only checks whether header.len exceeds the total bytes available in the message (reader.remaining_len() + size_of_val(header)), and never checks the lower bound header.len as usize >= size_of::<fuse_in_header>() before computing payload_len at request.rs#L150:
fn read_operation(header: &fuse_in_header, mut reader: impl RequestReader) -> FuseOperation {
if header.len as usize > reader.remaining_len() + size_of_val(header) {
tracelimit::error_ratelimited!(
opcode = header.opcode,
unique = header.unique,
header_len = header.len,
len = reader.remaining_len() + size_of_val(header),
"Invalid message length",
);
return FuseOperation::Invalid;
}
// ...
if header.opcode == FUSE_INIT {
let payload_len = (header.len as usize) - size_of::<fuse_in_header>();
let available = payload_len.min(size_of::<fuse_init_in>());
if available < FUSE_COMPAT_INIT_IN_SIZE as usize {
// ...
return FuseOperation::Invalid;
}When reader.read_type::<fuse_in_header>() succeeds in Request::new, at least 40 bytes were present in the input buffer, so any header.len in 0..40 passes the upper-bound check on line 134 and underflows (header.len as usize) - 40 on line 150.
Consequence
Every virtio-fs request from the guest is parsed by fuse::Request::new in vm/devices/virtio/virtiofs/src/virtio.rs#L482. Any guest with a virtio-fs device can send a 40-byte fuse_in_header with opcode = FUSE_INIT and len < 40 (for example 0, 8, or 39). In builds with integer overflow checks enabled (such as dev builds, where panic = 'abort' is configured), this panics with attempt to subtract with overflow and aborts the VMM or device process. In release builds without overflow checks, payload_len wraps to usize::MAX - 39..=usize::MAX, clamping available to size_of::<fuse_init_in>() (64 bytes) and attempting to read a 64-byte fuse_init_in payload from trailing descriptor bytes despite the invalid header.len.
Reproduction
Construct a FUSE request buffer containing a fuse_in_header with opcode = FUSE_INIT and len set to 0, 8, or 39 (size_of::<fuse_in_header>() as u32 - 1), optionally followed by 16 payload bytes, and call fuse::Request::new(data.as_slice()).
The regression test request::tests::parse_init_len_below_header_size_is_invalid in fix.patch exercises len values 0, 8, and 39 with cargo nextest run --profile agent -p fuse. Before the fix, the test fails with a panic (attempt to subtract with overflow at vm/devices/support/fs/fuse/src/request.rs:150:31); after the fix, it passes and each malformed request decodes to FuseOperation::Invalid (for which Session replies EIO).
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Replace the unchecked subtraction in
Request::read_operationwith(header.len as usize).saturating_sub(size_of::<fuse_in_header>()). Whenheader.lenis smaller thansize_of::<fuse_in_header>(),payload_lenandavailableevaluate to0, which is less thanFUSE_COMPAT_INIT_IN_SIZE(16) and is cleanly rejected by the existing minimum-payload check asFuseOperation::Invalid. ValidFUSE_INITmessages (header.len >= 56) are unaffected.Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch