Repository navigation
[DO NOT REVIEW] fuse: reply EIO when a write or copy count overflows u32 - #5198
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 21, 2026
Conversation
A FUSE_WRITE or FUSE_COPY_FILE_RANGE whose file system reported more than u32::MAX bytes aborted the VMM process. Session::dispatch converted the usize that Fuse::write and Fuse::copy_file_range return into the u32 size of their fuse_write_out reply with try_into().unwrap(), so such a count panicked, and OpenVMM builds with panic = 'abort'. The count comes from the file system, but a guest can drive it past u32::MAX: fuse_copy_file_range_in carries a 64-bit length, which Linux passed on unclamped from 4.20 until 6.17 (1e08938c3694, "fuse: prevent overflow in copy_file_range return value"), so a file system that copies all that the guest asks for counts more than the reply holds. VirtioFs is not affected today: it caps a write at 1 MiB and does not implement copy_file_range. Build both replies with Session::write_out, which fails the request with EIO and a rate-limited error when the count does not fit, as Linux's FUSE driver fails a write whose reply counts more bytes than the write carried. The documentation of Fuse::write and Fuse::copy_file_range states the bound, and that a copy should copy at most u32::MAX bytes, a short copy, even when arg.len is larger. The new tests in session::tests::write_out send each request through the session's test harness to a file system that reports a given count, and expect exactly one reply. A count beyond u32::MAX now fails the request with EIO, and the session answers the next copy; counts up to u32::MAX are replied unchanged. At feature/microvm/dev 3eb7500, the two overflow tests panic at session.rs:213 for a write and at session.rs:396 for a copy, and with this change, all 46 tests of fuse pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
requested a review
from a team
as a code owner
November 21, 2026 03:59
5 tasks done
Pedro Henrique Penna (ppenna)
merged commit Nov 21, 2026
51e9af7
into
feature/microvm/dev
104 of 105 checks passed
syeedali
pushed a commit
to syeedali/nvx
that referenced
this pull request
Nov 22, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs microsoft/nvx#1631.
NVX pins the head of this branch, so this is a prerequisite of the NVX change that pins it, and it lands by fast-forwarding
feature/microvm/devto that exact commit, not with the merge button, which squashes.What and why
fuse::Session::dispatchinvm/devices/support/fs/fuse/src/session.rsreplies toFUSE_WRITEandFUSE_COPY_FILE_RANGEwith afuse_write_out, whosesizeis au32, and it converted theusizethatFuse::writeandFuse::copy_file_rangereturn into that field withtry_into().unwrap(). A file system that reported more thanu32::MAXbytes therefore panicked the dispatcher and, withpanic = 'abort'in thedevandreleaseprofiles, aborted the VMM instead of failing the one request.The count comes from the file system, but a guest can drive it past
u32::MAX:fuse_copy_file_range_in.lenis 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 the guest asks for counts more than the reply can hold. The file systems ofvirtiofscannot trigger it:VirtioFsrefuses a write of more than 1 MiB and implements nocopy_file_range, andSectionFsand the dormant microVM file system implement neither request. Any other implementation ofFusecan.Both replies are now built by
Session::write_out, which, when the count does not fit, fails the request withEIO, whichSession::dispatchsends as the request's error reply, and logs it withtracelimit::error_ratelimited!(unique,opcode,count), since a guest can repeat the request.EIOis 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.Fuse::writeandFuse::copy_file_rangenow document the bound, and that a copy should copy at mostu32::MAXbytes, a short copy, whichcopy_file_rangeallows, even whenarg.lenis larger. A count within the bound is replied as before.The issue's patch makes the same change, with a helper that returns the
u32. Its test reads replies throughCapturingSender, 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 here use the session's test harness, which requires exactly one reply to each request, and also check that counts up tou32::MAX, the bound itself included, are replied unchanged. Rejected: saturating the count atu32::MAX, which would tell the guest that fewer bytes were written than were, and clampingarg.lenbefore calling the file system, which changes what the file system is asked to do and is not needed to stop the abort.The defect is upstream's: upstream main
bf353460fhas the sametry_into().unwrap()in both replies. This commit does not apply to upstream main as it is only because its tests use the session's test harness, which exists only on this branch.No saved state, protocol, ABI, or format, and no version of any of them, changes.
Tests
In
session::tests::write_out, each request goes through the session's test harness, which requires exactly one reply, whose header counts its whole length:write_count_beyond_u32_fails_with_eio: a file system that reportsu32::MAX + 1bytes for a 5-byte write gets an-EIOreply with no data.copy_count_beyond_u32_fails_with_eio: a file system that copies all of au32::MAX + 1-byte copy gets an-EIOreply with no data, and the same session then answers a 4096-byte copy with its count.write_replies_with_the_count_written: a write that the file system reports whole is replied with its count.copy_replies_with_counts_up_to_u32_max: copies of 4096 andu32::MAXbytes are replied with those counts, so the check does not refuse the bound itself.Validation
With
cargo nextest run --profile agent -p fuse, with the fix reverted (session.rsandlib.rsof3eb7500fd, with the new test module declared) and with it:write_count_beyond_u32_fails_with_eioandcopy_count_beyond_u32_fails_with_eiopanic withcalled Result::unwrap() on an Err value: TryFromIntError(PosOverflow), atsession.rs:213:46andsession.rs:396:46; the other two passnvx-mshv-test, an Azure Linux 3.0 virtual machinefuse_hello, which needs root)On both hosts, at this head,
cargo check,cargo clippy --all-targets, andcargo doc --no-depsforfuseare clean, but for theLNK4199linker message that every linked artifact gets on the Windows machine; on Windows,cargo xtask fmt --fixchanges nothing. Before the rebase onto3eb7500fd, the same fix behaved the same on85c3698f9, on Windows and onnvx-mshv-test.NVX's eight virtio-fs microVM scenarios, among them
platform-filesystem,filesystem-snapshot, andplatform-aggregate-export, pass onnvx-mshv-test, on MSHV, with the Alpine guest and OpenVMM built from this head, in microsoft/nvx#1864, which pins it. Their guest writes reachVirtioFsthroughFUSE_WRITE, whose replieswrite_outnow builds. In this pull request's CI, run 44863866339, every job that NVX requires passed, and so did every unit-test job, on x64 and aarch64, Linux, musl, and Windows;run vmm-tests [x64-windows-amd-snp]failed in three Hyper-V SEV-SNP OpenHCL tests,snp_vmgstool_copy_igvmfile,snp_ak_refresh, andsnp_ak_cert_cache, none of them a virtio-fs test.