openvmm: fuse: dispatch_init asserts on unoffered Fuse::init flags and trusts mutable SessionInfo capabilities
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
Research direction
Start by reading dispatch_init in vm/devices/support/fs/fuse/src/session.rs and Fuse::init in src/lib.rs, then compare SessionInfo with SessionInfoState in src/session/saved_state.rs. Run the two named cargo nextest filters in -p fuse to observe the panic and the forged-capability success. Done means unoffered or forged FUSE_INIT flags fail with -EIO instead of panicking, and both regression tests pass.
Written by the indexing model from the issue text.
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.
Related: #1629, #1628, #1631.
- Dominant language
- Rust
- Stars
- 848
- Forks
- 63
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 571
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/nvx
-
area: ci
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area: ci
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
openvmm: virtiofs: aggregate synthetic root st_nlink counts single-file shares as subdirectoriesOpenarea: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/nvx#1632 · 1 comment ·
Maintainers usually reply within 1 day
-
area: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/nvx#1628 · 1 comment ·
Maintainers usually reply within 1 day
-
area: openvmm
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
microsoft/nvx#1629 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
community differential help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
hffgzktbcc-blip/ounce-core#489 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
pact-foundation/pact-plugins#125 ·
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jolars/panache#627 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
facebookexperimental/hermit#347 ·
Maintainers usually reply within 1 day