openvmm: fuse: dispatch_init asserts on unoffered Fuse::init flags and trusts mutable SessionInfo capabilities
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 52/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 848
- Forks
- 63
- Merge medio
- 13 h 37 min
- PR fusionados (30 d)
- 571
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/nvx
-
area: ci
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
area: ci
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
openvmm: virtiofs: aggregate synthetic root st_nlink counts single-file shares as subdirectoriesAbiertoarea: openvmm
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/nvx#1632 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area: openvmm
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/nvx#1628 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area: openvmm
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
microsoft/nvx#1629 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/nvx
Issues similares
-
priority: low
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
storytold/vectorcraft#8387 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
area:desktop kind:test priority:p3 ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 91/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
obi1kenobi/cargo-semver-checks#1814 ·
Los mantenedores suelen responder en 1 día
-
COMPARE.md symlink is brokenAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
BurntSushi/jiff#715 ·
Los mantenedores suelen responder en 1 día