Repository navigation
Description
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()).
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Replace
-errorwitherror.wrapping_neg()inReplySender::send_errorso that everyi32value is handled without panicking when overflow checks are enabled, matching existing release-build behavior. Add unit tests coveringReplySender::send_errorandSession::dispatchacross boundaryi32values includingi32::MIN.Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch