Skip to content

openvmm: pin the bound on FUSE write and copy counts - #1864

Merged
Pedro Henrique Penna (ppenna) merged 2 commits into
devfrom
agents/issue-1631-write-count-u32
Nov 21, 2026
Merged

Pedro Henrique Penna (ppenna) merged 2 commits into
devfrom
agents/issue-1631-write-count-u32

Conversation

@ppenna

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

Copy link
Copy Markdown
Contributor

Fixes #1631

What does this pull request change?

It pins microsoft/openvmm#5198, which makes OpenVMM's fuse::Session fail a FUSE_WRITE or FUSE_COPY_FILE_RANGE whose file system reports more bytes than the reply can carry with EIO instead of panicking. Both requests are answered with a fuse_write_out, whose size is a u32, and the session converted the usize that Fuse::write and Fuse::copy_file_range return into it with try_into().unwrap(), so a count above u32::MAX panicked, which aborts the VMM. Now a new Session::write_out builds both replies, and for a count that does not fit it logs a rate-limited error and fails the request with EIO, which Session::dispatch sends as the request's error reply; a count that fits is replied as before. Fuse::write and Fuse::copy_file_range now document the bound, and that a copy should copy at most u32::MAX bytes, a short copy, even when its 64-bit len is larger.

NVX's virtio-fs file systems never report such a count: VirtioFs refuses a write of more than 1 MiB and implements no copy_file_range, and SectionFs and the dormant microVM file system implement neither request. So NVX's guests see no change, and their writes are answered with the same counts, now through write_out. The fix matters to any other Fuse implementation that a fuse::Session serves.

No version is created or bumped: no ABI, machine-contract, time-ABI, snapshot, manifest, saved-state, or protocol version changes, in NVX or in OpenVMM, and no saved state or on-disk format changes.

Commits:

  • openvmm: pin the bound on FUSE write and copy counts moves the gitlink from 3eb7500fd to 51e9af75dc7d4a3a9bd40ae52c996a822d3311cf, the head of [DO NOT REVIEW] fuse: reply EIO when a write or copy count overflows u32 openvmm#5198, and changes nothing else. The protocol vectors and CPU profiles that nvx copies are unchanged.
  • doc: map the bound on FUSE write and copy counts in the OpenVMM roadmap maps the new chain position, 330.

Start with Session::write_out and the Write and CopyFileRange arms of dispatch_helper in microsoft/openvmm#5198's vm/devices/support/fs/fuse/src/session.rs, then its tests in src/session/tests/write_out.rs.

It leaves FUSE_INIT's assertions to #1630. It does not clamp a copy's len before calling the file system, and it does not implement FUSE_COPY_FILE_RANGE_64. No NVX documentation describes these replies: doc/design/3.6-host-filesystem.md describes VirtioFs, whose behavior does not change. So no NVX documentation changes.

Why is this change needed?

The session converted the file system's byte count into the reply's u32 with try_into().unwrap(), and OpenVMM sets panic = 'abort' in both its dev and release profiles, so a Fuse file system whose write or copy_file_range returned more than u32::MAX aborted the whole VMM instead of failing the one request. The Fuse trait returns lx::Result<usize> from both methods and documented no bound. A guest can drive a copy's count that far: fuse_copy_file_range_in.len is 64-bit, and Linux passed the caller's length on unclamped from 4.20 until 6.17 (torvalds/linux@1e08938c3694, "fuse: prevent overflow in copy_file_range return value"), so a file system that copies all that it is asked to counts more than the reply holds. The code is upstream OpenVMM's: upstream main, bf353460f, has the same try_into().unwrap() in both replies.

The fix fails the request with EIO, which is what the Linux FUSE driver gives a write whose reply counts more bytes than the write carried (fuse_send_write()), and, in current kernels, a copy whose reply counts more than it asked for. The error log is rate-limited, since a guest can repeat the request.

Rejected: saturating the count at u32::MAX, which would tell the guest that fewer bytes were written than were; clamping the copy's len before calling the file system, which changes what the file system is asked to do and is not needed to stop the abort; and the issue's test, which reads replies through CapturingSender, which keeps only the last one, and checks only the overflow, so it would also pass if the session refused every count or sent two replies. The tests instead use the session's test harness, which requires exactly one reply to each request, and also check that counts up to u32::MAX, the bound itself included, are replied unchanged, in a test file of their own. The fix itself is the one that the issue proposes, with a helper that builds the whole reply.

How was this change validated?

Checks and results:

  • OpenVMM, with Rust 1.97.1, cargo nextest run --profile agent -p fuse, with the fix reverted (session.rs and lib.rs of 3eb7500fd, with the new test module declared) and with it:

    Host With the fix reverted With the fix
    Windows 11, local, at the pin 2 of 46 fail: write_count_beyond_u32_fails_with_eio and copy_count_beyond_u32_fails_with_eio panic with called Result::unwrap() on an Err value: TryFromIntError(PosOverflow), at session.rs:213:46 and session.rs:396:46 all 46 pass
    Azure Linux 3.0, virtual machine (nvx-mshv-test), at the pin the same two failures, with the same panics, at the same lines 46 pass, 1 skipped (fuse_hello, which needs root)
  • At the pin, on both hosts, cargo check, cargo clippy --all-targets, and cargo doc --no-deps for fuse pass, with no warning but, on Windows, the LNK4199 linker message that every linked artifact gets on this machine, and on Windows cargo xtask fmt --fix changes nothing. Before the rebase onto 3eb7500fd, the same fix and tests behaved the same on 85c3698f9 on both hosts.

  • python scripts/local_gates.py --base origin/dev --only test-changes markdown-links test-layout openvmm-vectors openvmm-cpu-profiles --run on Windows: all five pass.

  • python scripts/openvmm_pin.py check-branch --topic, against b5689cc9ca1, this branch's base on dev, and check-roadmap --worktree pass, python scripts/openvmm_pin.py source 51e9af75dc7d4a3a9bd40ae52c996a822d3311cf --pr 5198 reports a good signature and the pull request's head, and python scripts/nvx.py verify and python scripts/check_markdown_links.py pass.

  • MicroVM scenarios at this head on nvx-mshv-test, with OpenVMM built from the pin by python3 scripts/nvx.py build-openvmm --backend mshv (its provenance names 51e9af75d, clean) and the other artifacts of release v0.1.0-dev.c1e6adb3dbb4, from nvx download --hypervisor mshv: the virtio-fs scenarios platform-filesystem, filesystem-snapshot, filesystem-shares, filesystem-policy, filesystem-owner, denied-filesystem-paths, platform-aggregate-export, and filesystem-comma-paths pass, each with python3 scripts/nvx.py test-microvm --backend mshv --scenario NAME. Their guest writes reach VirtioFs through FUSE_WRITE, whose replies write_out now builds. filesystem-owner ran unprivileged, so OpenVMM could not assume other host identities, and it checked that guest root and foreign callers fail with EPERM.

Backend, host OS, host type, and guest: the unit tests ran on Windows 11 (local) and on Azure Linux 3.0 (nvx-mshv-test, an MSHV virtual machine); the microVM scenarios ran on nvx-mshv-test, on MSHV, with the Alpine guest.

Left to CI: the full NVX matrix, on KVM, MSHV, and WHP, which passed for this head in run 44864555400; and OpenVMM's CI of the pin, run 44863866339, which passed every job that the openvmm-ci job requires, as python scripts/nvx.py check-openvmm-ci --revision 51e9af75dc7d4a3a9bd40ae52c996a822d3311cf confirms: unit tests [x64-linux], unit tests [x64-windows], and run vmm-tests of x64-linux-amd-kvm, x64-linux-intel-mshv, x64-windows-intel, and x64-windows-amd. Its other unit-test jobs, on aarch64 Linux and Windows and on x64 and aarch64 musl, passed too, and so did its quick check, cargo hack, and binary-size jobs. One job that NVX does not require failed, run vmm-tests [x64-windows-amd-snp], in three Hyper-V SEV-SNP OpenHCL tests, snp_vmgstool_copy_igvmfile, snp_ak_refresh, and snp_ak_cert_cache, none of them a virtio-fs test.

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-rs/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

OpenVMM's FUSE session converted the byte count that a file system
returns for a write or a copy into the u32 of the reply with
try_into().unwrap() (#1631), so a file system that
reported more than u32::MAX bytes panicked, which aborts the VMM. A
guest can drive a copy's count that far, since FUSE_COPY_FILE_RANGE
carries a 64-bit length. Of the file systems that NVX runs, VirtioFs
refuses writes of more than 1 MiB and implements no copy, and
SectionFs and the dormant microVM file system implement neither
request, so NVX's guests never reached the panic.

Pin microsoft/openvmm 51e9af75dc7d4a3a9bd40ae52c996a822d3311cf, one
commit on feature/microvm/dev 3eb7500fd:

- fuse: reply EIO when a write or copy count overflows u32.
  Session::write_out builds both replies, and fails the request with
  EIO and a rate-limited error when the count does not fit, and
  Fuse::write and Fuse::copy_file_range document the bound. Its tests
  pass with the fix; without it, the two overflow tests panic with
  "TryFromIntError(PosOverflow)", on Windows and on Linux
  (nvx-mshv-test).

No saved state, protocol, ABI, or 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>
Map position 330, the commit of microsoft/openvmm#5198, which NVX now
pins at 51e9af75d, 204 commits past the mapped tip:

- 330, fuse: reply EIO when a write or copy count overflows u32.
  Session::write_out builds the replies to FUSE_WRITE and
  FUSE_COPY_FILE_RANGE, and fails with EIO a byte count from the file
  system that the u32 size of their fuse_write_out cannot hold, which
  it logs with a rate-limited error. The session converted the count
  with try_into().unwrap(), so a larger count panicked, which aborts
  the VMM.

It is not a fixup of a mapped PR. Position 330 changes the two
replies in session.rs, which upstream main has and no earlier chain
commit changes, adds write_out after send_max_size, which position 329
changes, documents the bound on two Fuse methods in lib.rs, which
positions 047, 324, 326, and 329 also change, and adds its tests,
which use the harness, in a new file that it declares in the session's
test module. Upstream main, bf353460f, has the defect, in the same two
replies, but the commit does not apply there as it is: upstream main
lacks the harness and the session tests of positions 047, 324, 326,
327, and 329, whose declarations conflict.

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

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 reported for the documented OpenVMM pin and roadmap update.

No open issues 🎉

What changed in this PR

This PR pins OpenVMM’s fix for #1631, making FUSE write and copy counts above u32::MAX return EIO instead of aborting the VMM. NVX’s built-in file systems remain unaffected.

Changes:

  • Records OpenVMM revision 51e9af75d at chain position 330, 204 commits beyond the mapped tip.
  • Updates the roadmap’s chain counts and explains the fix, regression-test dependencies, and prerequisites for upstreaming.
File Description
doc/​openvmm-upstream-roadmap.md Updates the documented pin and maps the FUSE count-overflow fix and its dependencies.

Review effort: Balanced

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: fuse: write and copy_file_range byte counts exceeding u32::MAX panic

2 participants