openvmm: virtiofs: aggregate synthetic root returns empty EOF reply instead of EINVAL when buffer fits no entry
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- operating-systems
Research direction
Start in vm/devices/virtio/virtiofs/src/aggregate.rs at read_synthetic_root_dir_with (around L314-L366); follow the loop that breaks on !fit and returns Ok(buffer). Compare with the EINVAL handling in VirtioFsFile::read_dir_with (src/file.rs, ~L236-L238) and read_dir_microvm (src/microvm/file.rs, ~L83-L85) to match the existing error convention. Done means an empty buffer with entries still pending returns Err(lx::Error::EINVAL) for both READDIR and READDIRPLUS, with unit tests using the reproduction steps (size 31 / 159, and the offset-2 continuation case).
Written by the indexing model from the issue text.
Description
Summary
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
VirtioFsviaVirtioFs::new_microvm_aggregatewith 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_diratoffset = 0withsize = 31(orFuse::read_dir_pluswithsize = 159), or first read.and..withsize = 64(next_cookie = 2) and then callFuse::read_diratoffset = 2withsize = 31. - Observe
Ok(vec![])instead ofErr(lx::Error::EINVAL).
Related: #1598, #1632, #1624.
- Dominant language
- Rust
- Stars
- 848
- Forks
- 63
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 571
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/nvx
-
area: ci
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area: ci
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
openvmm: virtiofs: aggregate synthetic root st_nlink counts single-file shares as subdirectoriesOpenarea: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/nvx#1632 · 1 comment ·
Maintainers usually reply within 1 day
-
area: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/nvx#1628 · 1 comment ·
Maintainers usually reply within 1 day
-
area: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
microsoft/nvx#1629 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
obi1kenobi/cargo-semver-checks#1814 ·
Maintainers usually reply within 1 day
-
community differential help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
hffgzktbcc-blip/ounce-core#489 · 1 comment ·
Maintainers usually reply within 1 day
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pbakaus/impeccable#1560 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
pact-foundation/pact-plugins#125 ·