Skip to content

openvmm: pin microVM listing bounds that count only shown entries - #2120

Merged
Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-2093-virtiofs-hidden-entries
Nov 25, 2026
Merged

Pedro Henrique Penna (ppenna) merged 3 commits into
devfrom
agents/issue-2093-virtiofs-hidden-entries

Conversation

@ppenna

@ppenna Pedro Henrique Penna (ppenna) commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2093

Stacked on #2119 (agents/issue-1909-io-uring-start), itself stacked on #2118 and the pull requests below it; only the top three commits belong to this pull request (see OpenVMM pin for the landing order).

What does this pull request change?

A microVM guest's virtio-fs listing of a host directory now counts only the entries that the share's access policy shows toward a handle's bounds of 4,096 entries and 64 KiB of names. Before, an entry that --mount-deny hides, or that a traverse-only directory of --mount-allow hides, counted toward the 4,096 entries too, so a directory whose shown entries, . and .. included, filled that bound failed the guest's first READDIR or READDIRPLUS with E2BIG when the host listed a hidden entry after them, and listed them all when the host listed the hidden entries first. The outcome thus depended on the host's enumeration order, which the guest cannot control: hiding the last name failed the listing on NTFS, which lists names in order, and hiding whichever name its hash order puts last failed it on ext4. A guest's busybox ls -a of such a share printed no name. A directory that shows more than 4,096 entries, or more than 64 KiB of names, still fails with E2BIG.

The fix is in OpenVMM, microsoft/openvmm#5279, which this pull request pins:

  • virtiofs: count only shown entries toward a microVM listing's bound. VirtioFsFile::build_microvm_directory_snapshot (vm/devices/virtio/virtiofs/src/microvm/file.rs), which lists a handle's directory at its first read, checks the bound of 4,096 entries where an entry is about to join the listing, after the access-policy filter and beside the existing check of 64 KiB of names, rather than at the top of its read_dir callback. It lists through a new build_microvm_directory_snapshot_within, whose bound a test can lower. One regression test in microvm/fs_tests.rs.

The NVX commits are the gitlink-only pin; the mapping of the commit, position 385, in the OpenVMM roadmap; and two sentences of Nodes, Handles, and Listings that say that the entries that the policy hides count toward neither bound, and that a name longer than 255 bytes fails a listing with EINVAL whether the policy hides it or not. Start with the OpenVMM diff: git diff --submodule=diff origin/agents/issue-1909-io-uring-start...HEAD.

Left out and limitations:

  • The check of an entry's name still runs before the policy filter, so an entry whose name is empty or longer than 255 bytes fails the listing with EINVAL even when the policy hides it; this pull request leaves that check as it is.
  • The bounds keep their values, and the saved listings of open handles their format, so a snapshot restores as before.

Why is this change needed?

Root cause: position 083 of the microVM chain (6315c16c5, in PR18 of the OpenVMM roadmap), which introduced the listings of microVM directory handles, checked the bound of 4,096 entries at the top of the callback that LxFile::read_dir calls for each entry, before the filter that skips the entries that the policy hides: those that child_path refuses with EACCES, as PR22's position 102 (9f1580ceb) made denied paths do, and, since position 160 (2ea6f1e0b), those that entry_listable leaves out of a traverse-only directory. A hidden entry thus counted toward the bound as if it were listed, while the check of 64 KiB of names, which runs after the filter, never counted hidden names. Position 371 (2bb009b01, #2096), which reads a listing on to the end of the directory on Windows, kept that order; its pull request recorded this defect as a known limitation and tracked it here.

Alternatives rejected:

  • A regression test at the real bound: it needs a directory of more than 4,096 entries, which takes seconds to create on Windows (about 2 s for files on this workstation, and 16 s for directories), past the 1 s after which OpenVMM's CI test profile calls a test slow and close to the 10 s after which it ends one. So the builder takes the bound as a parameter, which the test lowers, and the one-off test at the real bound below was not committed.
  • A smaller bound for tests through cfg(test): it would change the bound for every other test of the package, among them those of the saved-state bounds.

How was this change validated?

Checks and results. "Before" is OpenVMM d44a113be, the head of feature/microvm/dev when this work started, or the release built from it; "after" is the fix, as 5066e2c84 on d44a113be and, after its rebase onto microsoft/openvmm#5278, as the pinned 043083f40, whose patch git range-diff reports equal.

Check Before After
cargo nextest run --profile agent -p virtiofs -E 'test(microvm_listings_count_only_the_entries_that_the_policy_shows)' (new test), on Windows 11 (NTFS) and Linux (tmpfs) fails with E2BIG for the file that the host lists last, c on NTFS and a on tmpfs passes on both
One-off test at the real bound, not committed: 4,095 files and . and .., the policy hiding no file, the first that the host lists, or the last, then the first READDIR and READDIRPLUS of the root, on Windows and Linux none and last: E2BIG; first: 4,096 entries none: E2BIG; first and last: 4,096 entries
cargo check, cargo clippy --all-targets, and, on Windows, cargo doc --no-deps, each -p virtiofs no warnings on Windows and Linux with the fix on d44a113be, and clippy again on Windows at 043083f40
cargo nextest run --profile agent -p virtiofs Windows: 240 passed, 3 skipped (043083f40); Linux: 242 passed, 1 skipped (the fix on d44a113be)
cargo xtask fmt --fix no changes (5066e2c84)
cargo test --locked --manifest-path nvx/Cargo.toml --no-default-features --test openvmm_vectors -- --ignored, and the same with --test openvmm_cpu_profiles pass, 4 and 1 tests: the vectors and CPU profiles that nvx copies are unchanged
python scripts/openvmm_pin.py check-branch --topic --target origin/agents/issue-1909-io-uring-start, python scripts/openvmm_pin.py check-roadmap --worktree, python scripts/check_markdown_links.py, git diff --check pass; the three commits are signed
python scripts/local_gates.py --base origin/agents/issue-1909-io-uring-start --run --only test-changes markdown-links test-layout openvmm-vectors openvmm-cpu-profiles openvmm-ci all pass; no change to existing tests
python scripts/nvx.py check-openvmm-ci --revision 043083f4059c7dfda9d021a8cf983ac65017c91e the six required jobs pass, in run 45527765719

Backend, host OS, host type, and guest: KVM on nvx-kvm-test (Azure Linux 3, kernel 6.18, x86_64), a virtual machine; WHP on the local Windows 11 Enterprise (build 26300) workstation, whose host type is not classified; the Alpine guest and kernel of release v0.1.0-dev.86984fe72c05, whose OpenVMM CI built from d44a113be (the "before" OpenVMM). The "after" OpenVMM was built from 5066e2c84 on KVM (python3 scripts/nvx.py build-openvmm --backend kvm) and from 043083f40 on WHP (python scripts\nvx.py build-openvmm --backend whp).

Guest ls -a | wc -l of a read-only share of 4,095 files KVM before KVM after WHP before WHP after
No file hidden (4,097 entries) 0 0 0 0
The first file that the host lists hidden by --mount-deny 4,096 4,096 4,096 4,096
The last file that the host lists hidden by --mount-deny 0 4,096 0 4,096

With the "after" OpenVMM on KVM, python3 scripts/nvx.py test-microvm --backend kvm with the filesystem-shares, filesystem-snapshot, filesystem-policy, filesystem-owner, denied-filesystem-paths, filesystem-comma-paths, platform-filesystem, and platform-aggregate-export scenarios passed. On WHP, with OpenVMM built from the pin and nvx from this branch, python scripts\nvx.py test-microvm --backend whp with the same scenarios but filesystem-owner, which needs a Linux host, passed.

OpenVMM's CI of the pin, run 45527765719, passed the six jobs that NVX requires on its second attempt. The first lost run vmm-tests [x64-linux-amd-kvm] to the 600 s timeout of multiarch::pcie::openvmm_uefi_x64_windows_datacenter_core_2025_x64_virtio_net_kdnet_windows, a Windows guest whose frame buffer stopped changing, a test that this change does not reach and that the same job passed at 44747bf1c for microsoft/openvmm#5278; one rerun of the failed jobs passed it. run vmm-tests [x64-windows-amd-snp], which NVX does not require, fails at microsoft/openvmm#5277 and #5278 too.

nvx-kvm-test stopped responding after the rebase, so the Linux runs of the virtiofs tests at the rebased 043083f40 are OpenVMM CI's unit tests [x64-linux], which passed.

NVX CI run 45549635881 of the head 16b520dad passed, its KVM, MSHV, and WHP microVM jobs with OpenVMM built from the pin and its NVX CLI jobs on Linux and Windows among them; MSHV, which no host here ran, is covered only there.

The nvx-cli local gate, whose Python tests this branch does not change, since it changes no script, was stopped in favor of CI's NVX CLI jobs after 1,011 of its tests had passed on this loaded workstation and four had failed. Rerun alone, two of the four passed; test_private_network_ingress_script_checks_policy_and_traffic timed out its guest script after 10 s, as such script tests do on this loaded host, and test_build_refuses_inputs_that_the_source_identity_omits expects its "file outside the checkout" to be outside it, while these runs kept their temporary directories inside the worktree.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

Changes to existing tests

None: python scripts/check_test_changes.py --base origin/agents/issue-1909-io-uring-start lists no change to an existing test, and the OpenVMM pull request adds one test and changes none.

OpenVMM pin

A microVM's virtio-fs listing of a host directory whose shown entries,
`.` and `..` included, filled a handle's 4,096 entries failed the
guest's first FUSE_READDIR or FUSE_READDIRPLUS of the handle with E2BIG
when the host listed an entry that the share's access policy hides
after them, and listed them all when the host listed it first, so the
outcome depended on the host's enumeration order, which the guest
cannot control (#2093). A guest's busybox `ls -a` of such a share
printed nothing. The listing checked its bound of 4,096 entries before
the policy filter, so a hidden entry counted toward it.

Pin microsoft/openvmm 043083f4059c7dfda9d021a8cf983ac65017c91e, the head
of microsoft/openvmm#5279, one commit on 44747bf1c, the head of
microsoft/openvmm#5278, which NVX pins below this commit:

- virtiofs: count only shown entries toward a microVM listing's bound.
  The check of the 4,096 entries per handle runs after the policy
  filter, beside the check of 64 KiB of names, so only the entries
  that the guest can list count toward either bound, and a 4,097th of
  them still fails the listing with E2BIG. Its test fails without the
  fix, for the file that the host lists last, and passes with it, on
  Windows and Linux. The virtiofs package's tests pass at the pin on
  Windows, and on Linux at 5066e2c84, the same commit on d44a113be
  before its rebase onto microsoft/openvmm#5278 and the commits below
  it, which touch none of its files.

In an Alpine guest of release v0.1.0-dev.86984fe72c05, whose OpenVMM
CI built from d44a113be, `ls -a` of a read-only share of 4,095 files
whose policy hides the last file that the host lists printed no name,
on KVM (nvx-kvm-test, ext4) and on WHP (Windows 11, NTFS). With
OpenVMM built from the fix, 5066e2c84 on KVM and the pinned 043083f40
on WHP, it printed all 4,096 names, and the filesystem-shares,
filesystem-snapshot, filesystem-policy, filesystem-owner,
denied-filesystem-paths, filesystem-comma-paths, platform-filesystem,
and platform-aggregate-export scenarios passed on KVM.

No saved-state, protocol, or ABI format, and no version of any of
them, changes. The protocol vectors and CPU profiles that nvx copies
are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…the OpenVMM roadmap

Map position 385, the commit of microsoft/openvmm#5279, which NVX now
pins at 043083f40, 259 commits past the mapped tip, on 44747bf1c,
position 384, the head of microsoft/openvmm#5278:

- 385, virtiofs: count only shown entries toward a microVM listing's
  bound. The listing that the first read of a microVM directory handle
  takes checks its bound of 4,096 entries after the access-policy
  filter, beside its bound of 64 KiB of names, so that an entry that
  the policy hides no longer fails with E2BIG a listing whose shown
  entries fill the bound (#2093). Its test lowers the bound through
  the new build_microvm_directory_snapshot_within.

Position 385 is not yet assigned to a PR. It fixes a defect of PR18's
position 083, whose build_microvm_directory_snapshot checked the bound
before the filter that skips the entries that PR22's position 102's
denied paths and position 160's traverse-only directories hide, but
its code follows position 371's loop and its test needs PR22's
position 102 and positions 164 and 335, so it is not a PR18 fixup.
Positions 160, 330, 346, 349, 354, 355, and 371 also change the
microVM's file.rs, and none of positions 372-384 changes its files.
Upstream main, 8d4e03132, lacks the defect, since it lacks the
microVM's listings, and replaying the commit there conflicts in the
microVM's file.rs and fs_tests.rs, which upstream main lacks, so it
cannot go upstream on its own. The Scope also names the head of
feature/microvm/dev, fa239c823, since microsoft/openvmm#5275,
microsoft/openvmm#5276, and microsoft/openvmm#5277 landed positions
381-383.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The host filesystem's design said that the first directory read on a
handle lists the host directory into at most 4,096 entries and 64 KiB
of names, without the entries that the access policy hides, and that
listing a larger directory fails with E2BIG. OpenVMM checked the entry
bound before the policy filter, so a directory whose shown entries
filled a listing failed with E2BIG once the host listed a hidden entry
after them (#2093). With the OpenVMM fix, only the shown entries count
toward either bound, so say so, and say that a directory fails the
listing when it shows more than the bounds hold. Say too that a name
longer than 255 bytes fails a listing with EINVAL whether the policy
hides it or not, since the listing checks names before the filter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the OpenVMM pin and directory-listing documentation updates.

No open issues 🎉

What changed in this PR

This PR pins the OpenVMM fix for #2093, making microVM directory-listing bounds count only policy-visible entries. This removes failures that depended on whether the host enumerated hidden entries before or after visible ones.

Changes:

  • Updates the OpenVMM roadmap for revision 043083f40, chain position 385, including its dependencies and upstream status.
  • Clarifies that hidden entries consume neither listing bound, while names longer than 255 bytes still cause EINVAL even when hidden.
File Description
doc/​openvmm-upstream-roadmap.md Records the new pin, updates chain counts, and explains the listing-bound fix.
doc/​design/​3.6-host-filesystem.md Clarifies policy-filtered listing limits and oversized-name errors.

Review effort: Balanced

Base automatically changed from agents/issue-1909-io-uring-start to dev November 25, 2026 05:52
@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 25, 2026
Merged via the queue into dev with commit f0adde9 Nov 25, 2026
52 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-2093-virtiofs-hidden-entries branch November 25, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openvmm: virtiofs: a hidden entry past 4,096 listed entries fails a microVM directory listing with E2BIG

2 participants