Skip to content

openvmm: pin directory listings that close a refused descriptor - #2220

Merged
Pedro Henrique Penna (ppenna) merged 2 commits into
devfrom
agents/issue-2124-lxutil-fdopendir-leak
Nov 26, 2026
Merged

Pedro Henrique Penna (ppenna) merged 2 commits into
devfrom
agents/issue-2124-lxutil-fdopendir-leak

Conversation

@ppenna

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

Copy link
Copy Markdown
Contributor

Fixes #2124

What does this pull request change?

Pins OpenVMM at ee66d23117a9ebdd358686d8d9bacd1218d7dac0, the head of microsoft/openvmm#5293, whose one commit keeps lxutil's Unix DirectoryEnumerator::new from leaking a descriptor that fdopendir refuses, and maps it as position 399 in the OpenVMM upstream roadmap.

The OpenVMM commit is a cherry-pick of upstream's microsoft/openvmm#5291 (7417a033b, by Jitendra Bansal (@Jbansal2)), whose changed file it matches byte for byte. Start the review at vm/devices/support/fs/lxutil/src/unix/util.rs in microsoft/openvmm#5293. Nothing in nvx, the guest, or the host tooling changes.

Why is this change needed?

DirectoryEnumerator::new passed fd.into().into_raw_fd() to fdopendir, which takes ownership of a descriptor only when it succeeds. For a descriptor that is not a directory it fails with ENOTDIR, and nothing closed the raw descriptor. Upstream's virtio-fs FUSE_READDIR on a regular file's handle (LxFile::read_dir gives it a duplicate) and Plan9 Treaddir on a file's fid both reach it, so a guest could repeat the request until OpenVMM ran out of descriptors. The fix keeps the OwnedFd until fdopendir succeeds and only then releases it to the DIR*, which closedir closes in Drop.

NVX's microVMs were not exposed: the microVM's listing, build_microvm_directory_snapshot_within, checks S_IFDIR and refuses with ENOTDIR before it opens a directory stream. The pin still matters because NVX ships this OpenVMM and every successful listing goes through the changed constructor.

Alternatives: the issue's suggested patch is the same change as microsoft/openvmm#5291, so it is taken as proposed. A directory check in VirtioFs::read_dir alone would leave the Plan9 path and any other caller leaking, so the fix belongs in the constructor that owns the descriptor.

How was this change validated?

Checks and results:

Where Revision Command Result
azure-intel-kvm-7 OpenVMM 5f4a47b83 (base) + the test only cargo test -p lxutil --lib directory_enumerator_on_non_directory FAILED: 200 failed enumerations: 4 -> 204 descriptors open
azure-intel-kvm-7 OpenVMM ee66d2311 (pin) same, 3 runs ok, 3 of 3
azure-intel-kvm-7 OpenVMM ee66d2311 cargo check -p lxutil; cargo clippy --all-targets -p lxutil -- -D warnings; cargo doc --no-deps -p lxutil; cargo xtask fmt passed
azure-intel-kvm-7 OpenVMM ee66d2311 cargo nextest run --profile agent -p lxutil -p virtiofs -p plan9 324 passed, 4 skipped
azure-intel-kvm-7 upstream 7417a033b on 8d4e03132 cargo check -p lxutil; cargo test -p lxutil --lib passed, 38 tests
azure-intel-kvm-7 NVX 5018b2c80, OpenVMM built at the pin python3 scripts/nvx.py test-microvm --backend kvm --scenario filesystem-shares --scenario filesystem-snapshot --scenario platform-aggregate-export passed
Windows workstation NVX 5018b2c80 python scripts/local_gates.py --base origin/dev --run test-changes, markdown-links, test-layout, openvmm-vectors, openvmm-cpu-profiles, and nvx-cli passed; openvmm-ci reported 6 required OpenVMM jobs of the pin pending at the time; they have since passed
Windows workstation NVX 5018b2c80 python scripts/openvmm_pin.py check-roadmap --worktree; python scripts/openvmm_pin.py check-branch --topic passed

Backend, host OS, host type, and guest: azure-intel-kvm-7 is Linux KVM (Azure Linux 3.0), a virtual machine; the microVM scenarios used the Alpine guest and the artifacts of release v0.1.0-dev.5cf6a6950684, with openvmm rebuilt at the pin (SHA-256 d2209407… → 9fa25177…).

Left to CI: the microVM scenarios on MSHV and WHP and the rest of the KVM suite, which the gitlink selects, and OpenVMM's own CI of the pin. NVX run 45851494234 of 5018b2c80 passed, including KVM, MSHV, and WHP and the openvmm-ci job.

OpenVMM's run 45846860334 of the pin passed openvmm checkin gates, the unit tests, and every Linux and Windows vmm-tests job except two Windows Hyper-V OpenHCL jobs, which cannot reach Unix-only lxutil:

  • x64-windows-intel-tdx lost its test node ("remote node disconnected") and passed on the one rerun.
  • x64-windows-amd-snp, which is not required, failed vmgstool_copy_igvmfile in both attempts because the Hyper-V VM "failed to start". The same test fails in the SNP jobs of unrelated OpenVMM pull requests (runs 45732387857, 45720932312, 45686974502, and 45681589406), and SNP also fails, on other tests, in the base 5f4a47b83's runs 45744513828 and 45669616533.

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.

OpenVMM pin

lxutil's DirectoryEnumerator::new gave its descriptor to fdopendir as a
raw descriptor, but fdopendir takes ownership only when it succeeds, so
each listing of a descriptor that is not a directory, such as a
virtio-fs FUSE_READDIR on a regular file's handle or a Plan9 Treaddir
on a file's fid, failed with ENOTDIR and leaked the descriptor, and a
guest could repeat it until OpenVMM ran out of descriptors (#2124).
The microVM's file system refuses such a handle with its own S_IFDIR
check before it reaches lxutil, so NVX's microVMs were not exposed.

Pin microsoft/openvmm ee66d23117a9ebdd358686d8d9bacd1218d7dac0, the
head of microsoft/openvmm#5293, one commit on 5f4a47b83, which NVX pins
below this commit, a cherry-pick of microsoft/openvmm#5291's
7417a033b0e50aec3b16cac48f814441b0c7e47c, whose changed file it
matches:

- lxutil: close the descriptor when fdopendir fails in
  DirectoryEnumerator::new. The OwnedFd stays owned until fdopendir
  succeeds, so a failure drops and closes it. Its test, 200 listings
  of a regular file, fails at 5f4a47b83 on azure-intel-kvm-7 (Linux
  KVM, virtual machine) with "4 -> 204 descriptors open", and passes
  with the fix. At the pin, there, cargo check, clippy, and doc of
  lxutil and cargo xtask fmt pass, and nextest runs the 324 tests of
  lxutil, virtiofs, and plan9, which all pass.

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>
…enVMM roadmap

Map position 399, the commit of microsoft/openvmm#5293, which NVX now
pins at ee66d2311, 273 commits past the mapped tip, on 5f4a47b83,
position 398, the head of feature/microvm/dev since
microsoft/openvmm#5283-#5290 landed positions 391-398:

- 399, lxutil: close the descriptor when fdopendir fails in
  DirectoryEnumerator::new. The constructor keeps its OwnedFd until
  fdopendir succeeds, so a listing of a descriptor that is not a
  directory, which upstream's virtio-fs FUSE_READDIR and Plan9
  Treaddir reach, no longer leaks it (#2124).

Position 399 is not assigned to a PR, and no chain commit changes the
file that it changes. It is a cherry-pick of microsoft/openvmm#5291's
7417a033b, which proposes it on upstream main 8d4e03132, where lxutil
type-checks and its tests pass on azure-intel-kvm-7, so it can go
upstream on its own. The Scope now records that positions 391-398
landed on feature/microvm/dev.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 15:40

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 are recorded for the OpenVMM pin and roadmap updates.

No open issues 🎉

What changed in this PR

Pins OpenVMM to a fix for #2124 that closes descriptors when Unix directory enumeration fails, and updates NVX’s upstream roadmap to track the change.

Changes:

  • Advances the OpenVMM pin to ee66d2311 from microsoft/openvmm#5293.
  • Maps position 399 across the roadmap and records positions 391–398 as landed.
  • Documents the fix’s upstream origin, affected callers, regression coverage, and why microVMs were not exposed to the leak.
File Description
doc/​openvmm-upstream-roadmap.md Updates the pin, chain counts, diagram, commit mapping, and descriptor-leak fix details.

Review effort: Balanced

@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 26, 2026
Merged via the queue into dev with commit 6b8e0ae Nov 26, 2026
54 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-2124-lxutil-fdopendir-leak branch November 26, 2026 19:54
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.

lxutil: read_dir on a file that is not a directory leaks a descriptor, so a virtio-fs guest can exhaust OpenVMM's descriptors

2 participants