openvmm: fuse: data reply exceeding requested size panics in Session::send_max_size

Abierto Apto para principiantes
#1,629 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
80/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
backend

Línea de trabajo

Empieza en vm/devices/support/fs/fuse/src/session.rs, especialmente en Session::send_max_size alrededor de la línea 567, y luego sigue sus llamadores Read, GetXAttr, ListXAttr, ReadDir y ReadDirPlus en dispatch_helper; compara la ruta de Ioctl que devuelve EINVAL. El trait público Fuse está en vm/devices/support/fs/fuse/src/lib.rs, y el issue nombra la prueba de regresión dispatch_read_reply_larger_than_size_fails (en fix.patch), ejecutable con el comando cargo nextest indicado. Hecho significa que una respuesta sobredimensionada produce una respuesta de error como -EIO en lugar de abortar el VMM.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area: openvmm

Summary

fuse::Session::send_max_size enforces with assert!(data.len() <= max_size as usize) that a filesystem's data reply does not exceed the guest-requested byte count. Because both dev and release profiles configure panic = 'abort', any fuse::Fuse implementation that returns more bytes than requested in read, read_dir, read_dir_plus, get_xattr, or list_xattr aborts the entire VMM process instead of failing the FUSE request with an error reply. Found by formal verification.

Root Cause

In vm/devices/support/fs/fuse/src/session.rs, Session::send_max_size uses an unconditional assert! to validate the length of the Vec<u8> returned by the Fuse trait implementation against the guest's max_size: u32:

    /// Send a reply, validating it doesn't exceed the requested size.
    ///
    /// If it exceeds the maximum size, this causes a panic because that's a bug in the file system.
    fn send_max_size(
        sender: &mut impl ReplySender,
        unique: u64,
        data: &[u8],
        max_size: u32,
    ) -> Result<(), OperationError> {
        assert!(data.len() <= max_size as usize);
        sender.send_data(unique, data)?;
        Ok(())
    }

Session::dispatch_helper calls Self::send_max_size for Read (L204-L207), GetXAttr (L245-L247), ListXAttr (L260-L262), ReadDir (L280-L283), and ReadDirPlus (L373-L376). Meanwhile, the corresponding public Fuse trait methods return lx::Result<Vec<u8>> without documenting or enforcing an upper bound in the return type, whereas FuseOperation::Ioctl in the same dispatcher (L334-L336) already rejects an oversized buffer gracefully with Err(lx::Error::EINVAL.into()).

Consequence

OpenVMM sets panic = 'abort' in both [profile.dev] and [profile.release] (Cargo.toml). If a custom or future fuse::Fuse backend passed to fuse::Session::new or virtiofs::VirtioFsDevice::new returns a payload even one byte larger than arg.size, the session dispatcher aborts the entire VMM process rather than failing the offending FUSE request. OpenVMM's built-in VirtioFs backend sizes its read, xattr, and directory buffers from the guest's size parameter and does not trigger this panic, making this a fuse::Session API hardening issue.

Reproduction

Implement fuse::Fuse with read returning Ok(vec![0; arg.size as usize + 1]), initialize a fuse::Session with FUSE_INIT, and dispatch a FUSE_READ request with size = 4096. On commit 9d64daad3cbe14fb0591081b73c6c9648e18d0fb, dispatching the request panics at vm/devices/support/fs/fuse/src/session.rs:576:9 with assertion failed: data.len() <= max_size as usize. Running cargo nextest run --profile agent -p fuse -E 'test(dispatch_read_reply_larger_than_size_fails)' with the regression test in fix.patch reproduces the panic prior to the fix and passes with a -EIO reply afterward.

Related: #1628, #1631, #1630, #1625.

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/nvx

Todos los issues de microsoft/nvx

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.