Skip to content

[DO NOT REVIEW] fuse: fail FUSE_INIT when init wants flags the client did not offer - #5200

Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
feature/microvm/devfrom
copilot/nvx-issue-1630-init-flags
Nov 21, 2026
Merged

Pedro Henrique Penna (ppenna) merged 1 commit into
feature/microvm/devfrom
copilot/nvx-issue-1630-init-flags

Conversation

@ppenna

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

Copy link
Copy Markdown
Contributor

Refs microsoft/nvx#1630.

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/dev to that exact commit, not with the merge button, which squashes.

What and why

fuse::Session::dispatch_init in vm/devices/support/fs/fuse/src/session.rs fills a SessionInfo from the guest's FUSE_INIT, lets the file system negotiate in Fuse::init(&mut SessionInfo), and then asserted that what init wants is among what the guest offered: assert!(info.want & !info.capable == 0) and, unless init dropped FUSE_INIT_EXT, assert!(info.want2 & !info.capable2 == 0). The guest decides the offer, through fuse_init_in.flags and flags2, so a file system that wants a flag without checking info.capable() panicked the dispatcher whenever the guest left that flag out, and, with panic = 'abort' in the dev and release profiles, aborted the VMM instead of failing FUSE_INIT.

The assertions also read the guest's capabilities back from the SessionInfo that init may change. Its major, minor, capable, and capable2 are private, but on this branch SessionInfo converts from SessionInfoState, whose fields are public, so init can replace info with one whose version and capabilities it chose. One that claimed every capability passed both assertions, replied flags that the guest never offered, and left in Session::save_state() a version and capabilities that the guest never sent.

dispatch_init now takes the version and the guest's capabilities before it calls init and puts them back after it, whatever init did to info. When init wants a flag that the guest did not offer, or, while it keeps FUSE_INIT_EXT, an extended flag that the guest did not offer, dispatch_init logs the unoffered flags with tracelimit::error_ratelimited!, since a guest can repeat FUSE_INIT; resets info to its default, so that the session stays uninitialized and save_state() saves no negotiation, as SessionState::validate() requires of an uninitialized session; and fails the request with EIO, which Session::dispatch sends as its error reply, as for the other FUSE_INIT failures of dispatch_init. Fuse::init now documents both. A negotiation within the offer is replied and saved as before. VirtioFs::init wants only flags that info.capable() and info.capable2() hold, and SectionFs and the dormant microVM file system keep the default init, so none of them changes its negotiation.

libfuse refuses the same negotiation with EPROTO (want_flags_valid() in do_init()); the Linux FUSE driver treats any error reply to FUSE_INIT alike, as a connection error (process_init_reply()), so EIO, which dispatch_init already uses for an unsupported version, serves as well. Rejected: masking want and want2 to the offer, which would silently drop flags that the file system relies on.

The issue's patch makes the same change. Its tests read replies through CapturingSender, which keeps only the last one; the tests here use the session's test harness, which requires exactly one reply to each request, whose header counts its whole length.

Upstream main bf353460f has the same two assertions, but its SessionInfo converts from no SessionInfoState, which only this branch has, so only the abort is upstream's. This commit does not apply to upstream main as it is: replaying it there conflicts only in the module declarations of the session's test module, and its tests use the session's test harness and SessionInfoState. Without its tests, its change applies there, and cargo check -p fuse passes.

No saved state, protocol, ABI, or format, and no version of any of them, changes.

Tests

In session::tests::init, each request goes through the session's test harness:

  • init_rejects_flags_the_client_did_not_offer: a file system that wants FUSE_DO_READDIRPLUS, which the guest's flags did not offer, or, with FUSE_INIT_EXT offered and kept, FUSE_DIRECT_IO_ALLOW_MMAP_FLAG2, which its flags2 did not offer, gets an -EIO reply with no data, and its session stays uninitialized and saves the default state.
  • init_keeps_the_client_version_and_capabilities: a file system whose init replaces info with one that claims version 8.0 and every capability gets an -EIO reply when it also wants a flag beyond the offer; when it wants nothing more, it gets the offered flags, and the session saves the guest's version 7.31 and capabilities, which SessionState::validate() accepts.

Validation

With cargo nextest run --profile agent -p fuse, with the fix reverted (session.rs and lib.rs of 51e9af75d, with the new test module declared) and with it:

Host Without the fix With it
Windows 11, local init_rejects_flags_the_client_did_not_offer panics with assertion failed: info.want & !info.capable == 0 at session.rs:490, and, with only its flags2 case, with assertion failed: info.want2 & !info.capable2 == 0 at session.rs:496; init_keeps_the_client_version_and_capabilities gets no error reply (0, not -5) and, with only its second case, saves (8, 0, 0xffffffff, 0xffffffff) instead of (7, 31, 1, 0) all 48 pass
nvx-kvm-test, an Azure Linux 3.0 virtual machine the same two tests fail the same way, at the same lines 48 pass, 1 skipped (fuse_hello, which needs root)

On both hosts, at this head, cargo check, cargo clippy --all-targets, and cargo doc --no-deps for fuse are clean, but for the LNK4199 linker message that every linked artifact gets on the Windows machine; on Windows, cargo xtask fmt --fix changes nothing. On nvx-kvm-test, cargo nextest run --profile agent -p virtiofs passes at this head too (171 pass, 1 skipped), since VirtioFs is the in-tree file system that negotiates in init. Before the rebase onto 51e9af75d, the same fix behaved the same on 85c3698f9, on Windows and on nvx-kvm-test.

NVX's eight virtio-fs microVM scenarios, among them platform-filesystem, filesystem-snapshot, and platform-aggregate-export, pass on nvx-kvm-test, on KVM, with the Alpine guest and OpenVMM built from this head, in microsoft/nvx#1870, which pins it. Each guest mount negotiates FUSE_INIT through the changed dispatch_init, and filesystem-snapshot restores the negotiation that it saves. In this pull request's CI, run 44875530937, 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 two Hyper-V SEV-SNP OpenHCL tests, snp_vmgstool_copy_igvmfile and snp_seal_signer, neither of them a virtio-fs test.

Session::dispatch_init asserted that the flags which Fuse::init wants
are among those that the client offered (microsoft/nvx#1630). A file
system whose init wants a flag that the guest did not offer thus
panicked, which aborts the VMM process, since its profiles abort on
panic, instead of failing FUSE_INIT. And dispatch_init read the
client's capabilities back from the SessionInfo that init may replace,
as with the public SessionInfo::from(SessionInfoState): an init that
claimed every capability passed the check, sent the guest flags that
it never offered, and left in save_state a version and capabilities
that the client never sent.

dispatch_init now keeps the version and the client's capabilities that
it sets before init, and restores them after it, whatever init did to
the SessionInfo. When init wants a flag that the client did not offer,
or an extended flag that it did not offer while init keeps
FUSE_INIT_EXT, without which dispatch_init discards the extended
flags, dispatch_init logs a rate-limited error, resets the
SessionInfo, so that the session stays uninitialized and saves no
negotiation, and replies with EIO, as for its other FUSE_INIT
failures. Fuse::init documents both. VirtioFs::init wants only flags
that the client offers, so its negotiation does not change.

Tests, in fuse's session tests of init:

- init_rejects_flags_the_client_did_not_offer, with a file system that
  wants a flag or an extended flag that the client did not offer,
  panics at feature/microvm/dev 51e9af7 on the assertion of each.
- init_keeps_the_client_version_and_capabilities, with one whose init
  claims version 8.0 and every capability, there replies without an
  error to a want beyond the offer, and saves that version and those
  capabilities.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the release-nvx Targets a branch under feature/microvm/. label Nov 21, 2026
@ppenna
Pedro Henrique Penna (ppenna) merged commit 32c0c2b into feature/microvm/dev Nov 21, 2026
104 of 105 checks passed
github-merge-queue Bot pushed a commit to microsoft/nvx that referenced this pull request Nov 21, 2026
Map position 331, the commit of microsoft/openvmm#5200, which NVX now
pins at 32c0c2bbc, 205 commits past the mapped tip:

- 331, fuse: fail FUSE_INIT when init wants flags the client did not
  offer. Session::dispatch_init fails FUSE_INIT with EIO and a
  rate-limited error, and leaves the session uninitialized with no
  negotiation to save, when the file system's init wants a flag, or,
  while it keeps FUSE_INIT_EXT, an extended flag, that the guest did
  not offer, and it keeps the version and the guest's capabilities
  across init. It asserted the bound, so such a file system panicked,
  which aborts the VMM, and read the capabilities back from the
  SessionInfo that init may replace with one converted from a
  SessionInfoState.

It is not a fixup of a mapped PR: it changes nothing that one adds.
Position 331 changes dispatch_init in session.rs, whose lines that it
changes upstream main has and no earlier chain commit changes,
documents Fuse::init in lib.rs, which positions 047, 324, 326, 329,
and 330 also change, and adds its tests, which use the harness and
PR13's session state, in a new file that it declares in the session's
test module. The replacement that it stops needs PR13's position 047,
which made SessionInfo convertible from SessionInfoState, so the
roadmap asks that PR13 go upstream with it. Upstream main, bf353460f,
has the two assertions; replaying the commit there conflicts only in
the test module's declarations, and without its tests its change
applies there and fuse type-checks, but its tests need what upstream
main lacks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-nvx Targets a branch under feature/microvm/.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant