Repository navigation
Description
Summary
fuse::Session::dispatch_init checks negotiated feature flags after calling Fuse::init(&mut SessionInfo) using assert!(info.want & !info.capable == 0) and assert!(info.want2 & !info.capable2 == 0), and reads info.capable / info.capable2 back out of the mutable SessionInfo reference even though SessionInfo implements From<SessionInfoState>. A Fuse::init implementation that requests flags the guest did not offer panics and aborts the VMM process instead of failing FUSE_INIT with -EIO, while one that replaces *info via SessionInfoState can forge capable / capable2 and bypass the check altogether. Found by formal verification.
Root Cause
In vm/devices/support/fs/fuse/src/session.rs, dispatch_init passes &mut SessionInfo to self.fs.init(&mut info) and then asserts against info.capable and info.capable2:
info.max_write = DEFAULT_MAX_PAGES * PAGE_SIZE;
self.fs.init(&mut info);
assert!(info.want & !info.capable == 0);
// If the filesystem cleared FUSE_INIT_EXT from want, force want2 to
// zero so we never reply with flags2 the kernel won't expect.
if info.want & FUSE_INIT_EXT == 0 {
info.want2 = 0;
}
assert!(info.want2 & !info.capable2 == 0);Fuse::init exposes info.want and info.want2 as pub u32 fields without documenting that setting bits outside info.capable() / info.capable2() will panic, and dispatch_init aborts rather than rejecting the negotiation with lx::Error::EIO. In addition, although SessionInfo's major, minor, capable, and capable2 fields are private, SessionInfoState is publicly re-exported at vm/devices/support/fs/fuse/src/lib.rs with pub fields and impl From<SessionInfoState> for SessionInfo:
impl From<SessionInfoState> for SessionInfo {
fn from(state: SessionInfoState) -> Self {
Self {
major: state.major,
minor: state.minor,
max_readahead: state.max_readahead,
capable: state.capable,
capable2: state.capable2,
want: state.want,
want2: state.want2,
max_background: state.max_background,
congestion_threshold: state.congestion_threshold,
max_write: state.max_write,
time_gran: state.time_gran,
}
}
}Because dispatch_init compares info.want and info.want2 against info.capable and info.capable2 after self.fs.init(&mut info) returns, an external Fuse::init implementation can assign *info = SessionInfo::from(SessionInfoState { capable: !0, capable2: !0, .. }) to bypass capability validation and alter the saved protocol state.
Consequence
With panic = 'abort' enabled in both [profile.dev] and [profile.release] (Cargo.toml), any Fuse implementation that sets an unadvertised want or want2 bit during FUSE_INIT crashes the VMM process instead of returning -EIO and keeping the session uninitialized. Conversely, replacing *info through SessionInfo::from(SessionInfoState { .. }) allows init to emit unoffered fuse_init_out flags to the guest and corrupt Session::save_state(). OpenVMM's built-in VirtioFs::init masks want against info.capable() and does not construct SessionInfoState, so this is not triggered through VirtioFs today.
Reproduction
Dispatch FUSE_INIT on a fuse::Session whose Fuse::init sets info.want |= 1 << 30 when the request flags omit bit 30; on commit 9d64daad3cbe14fb0591081b73c6c9648e18d0fb, this panics at vm/devices/support/fs/fuse/src/session.rs:502:9 (assertion failed: info.want & !info.capable == 0). Dispatching FUSE_INIT against a Fuse::init that assigns *info = SessionInfo::from(SessionInfoState { capable: !0, capable2: !0, want: 1 << 30, .. }) succeeds with error == 0 instead of -EIO. Running cargo nextest run --profile agent -p fuse -E 'test(dispatch_init_unoffered_flags_fails) | test(dispatch_init_forged_capable_via_session_info_state_fails)' reproduces both failures before fix.patch and passes afterward.
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Save
(major, minor, capable, capable2)frominfointo local bindings before callingself.fs.init(&mut info), validateinfo.want & !capable == 0and (after zeroinginfo.want2wheninfo.want & FUSE_INIT_EXT == 0)info.want2 & !capable2 == 0against the saved capability bitmasks, and on failure log a rate-limited error viatracelimit::error_ratelimited!, reset*info = SessionInfo::default()soSession::save_state()remains valid for an uninitialized session, and returnErr(lx::Error::EIO.into()). On success, restoreinfo.major,info.minor,info.capable, andinfo.capable2from the saved pre-initbindings before buildingfuse_init_out.Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch