You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
openvmm: virtiofs: aggregate synthetic root returns empty EOF reply instead of EINVAL when buffer fits no entry #1617
When a guest issues FUSE_READDIR or FUSE_READDIRPLUS on an aggregate mount's synthetic root directory with a non-zero buffer size too small to hold the next directory entry, VirtioFs::read_synthetic_root_dir_with returns Ok(Vec::new()) instead of Err(lx::Error::EINVAL). Because FUSE defines an empty directory read reply as end-of-directory, the guest truncates the synthetic root's directory listing instead of receiving EINVAL. Found by testing.
Root Cause
In vm/devices/virtio/virtiofs/src/aggregate.rs#L314-L366, VirtioFs::read_synthetic_root_dir_with breaks out of the entry-serialization loop as soon as write_synthetic_dot or write_child_entry reports !fit, and unconditionally returns Ok(buffer) even when buffer is still empty:
if !fit {break;}
index = next;}Ok(buffer)
For example, a plain FUSE_READDIR entry for . requires fuse_dirent_align(size_of::<fuse_dirent>() + 1) = 32 bytes (fuse_direntplus requires 160 bytes), so any size in 1..=31 (1..=159 for FUSE_READDIRPLUS), or any continuation read whose size cannot hold the aligned entry of the next child share name, causes !fit on the first attempted entry and returns a 0-byte buffer. By contrast, real share directories reject undersized buffers that have remaining entries but fit none with EINVAL in both VirtioFsFile::read_dir_with and VirtioFsFile::read_dir_microvm.
Consequence
FUSE and getdents64 treat a 0-byte FUSE_READDIR / FUSE_READDIRPLUS reply as end-of-directory rather than a short-buffer error. A caller supplying a small buffer at offset 0 sees an empty root directory, and a caller whose continuation buffer fits . and .. (64 bytes) or short share names before hitting a longer share name receives a silent early EOF that hides the remaining shares instead of failing with EINVAL as Linux getdents64 and regular share directories do.
Reproduction
Construct an aggregate VirtioFs via VirtioFs::new_microvm_aggregate with at least one child share (for example "work").
Open the synthetic root directory via Fuse::open_dir(&fs, &request(FUSE_ROOT_ID), lx::O_RDONLY as u32).
Call Fuse::read_dir at offset = 0 with size = 31 (or Fuse::read_dir_plus with size = 159), or first read . and .. with size = 64 (next_cookie = 2) and then call Fuse::read_dir at offset = 2 with size = 31.
Observe Ok(vec![]) instead of Err(lx::Error::EINVAL).
Track whether read_synthetic_root_dir_with broke out of the loop because an entry did not fit (!fit) rather than because index reached the end of aggregate.registry.read().entries. Before returning Ok(buffer), return Err(lx::Error::EINVAL) if an entry failed to fit and buffer.is_empty(), matching VirtioFsFile::read_dir_with and VirtioFsFile::read_dir_microvm. Note that read_synthetic_root_dir_with is also modified at the top of the function when bounding guest buffer allocations against MAX_GUEST_BUFFER_SIZE.
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Track whether
read_synthetic_root_dir_withbroke out of the loop because an entry did not fit (!fit) rather than becauseindexreached the end ofaggregate.registry.read().entries. Before returningOk(buffer), returnErr(lx::Error::EINVAL)if an entry failed to fit andbuffer.is_empty(), matchingVirtioFsFile::read_dir_withandVirtioFsFile::read_dir_microvm. Note thatread_synthetic_root_dir_withis also modified at the top of the function when bounding guest buffer allocations againstMAX_GUEST_BUFFER_SIZE.Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch