openvmm: fuse: ReplySender::send_error panics on i32::MIN overflow in debug builds

Aperta
#1,625 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start at vm/devices/support/fs/fuse/src/reply.rs around line 42, in ReplySender::send_error, where make_header(unique, 0, -error) is built; read vm/devices/support/fs/fuse/src/session.rs around Session::dispatch to see how lx::Error::value() reaches it. Run cargo nextest run --profile agent -p fuse and use the named tests reply::tests::send_error_takes_any_code and session::tests::dispatch_replies_any_error_code as the finish line for an i32::MIN reply. The body references a fix.patch, so confirm whether that patch is already proposed before duplicating it.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: openvmm

Summary

fuse::ReplySender::send_error negates its error: i32 argument with -error when populating fuse_out_header.error. Because -i32::MIN cannot be represented as an i32, passing i32::MIN triggers a signed negation overflow panic in builds with overflow checks enabled. Found by formal verification.

Root Cause

In vm/devices/support/fs/fuse/src/reply.rs#L37-L45, ReplySender::send_error accepts any i32 error code and negates it directly with -error on reply.rs#L42:

    /// Send an error reply.
    fn send_error(&mut self, unique: u64, error: i32) -> io::Result<()> {
        if error != 0 {
            tracing::debug!(unique, error, "reply");
        }

        let header = make_header(unique, 0, -error);
        let header = header.as_bytes();
        self.send(&[io::IoSlice::new(header)])
    }

lx::Error wraps an arbitrary i32 via lx::Error::from_lx, and Session::dispatch forwards e.value() directly to sender.send_error(unique, e.value()) in vm/devices/support/fs/fuse/src/session.rs#L90-L98 without restricting the range of i32 values.

Consequence

If ReplySender::send_error is called with i32::MIN—either directly or through Session::dispatch when a Fuse implementation returns Err(lx::Error::from_lx(i32::MIN))—builds with integer overflow checks enabled (such as dev builds, where panic = 'abort' is configured) panic with attempt to negate with overflow and abort the process. Release builds without overflow checks already wrap -i32::MIN to i32::MIN. This path is not reachable in practice through VirtioFs, whose errors originate from positive lx errno constants and host OS error codes mapped by lxutil.

Reproduction

Call sender.send_error(1, i32::MIN) on any ReplySender, or initialize a fuse::Session around a Fuse implementation whose get_attr returns Err(lx::Error::from_lx(i32::MIN)) and dispatch a FUSE_GETATTR request.

The regression tests reply::tests::send_error_takes_any_code and session::tests::dispatch_replies_any_error_code in fix.patch exercise both paths via cargo nextest run --profile agent -p fuse. Before the fix, both tests fail with a panic (attempt to negate with overflow at vm/devices/support/fs/fuse/src/reply.rs:42:45); after the fix, both pass and emit an error reply header with error = i32::MIN (i32::MIN.wrapping_neg()).

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

Lingua principale
Rust
Stelle
848
Fork
63
Merge medio
13h 37m
PR unite (30g)
571

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/nvx

Tutte le issue di microsoft/nvx

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.