Repository navigation
Description
Summary
A guest FUSE_SETATTR request that sets atime, mtime, or ctime with a nanosecond field of 1_000_000_000 or greater and secs = u64::MAX causes virtiofs to panic inside std::time::Duration::new with overflow in Duration::new. Found by formal verification.
Root Cause
In vm/devices/virtio/virtiofs/src/util.rs#L99-L142 (specifically #L121-L139), fuse_set_attr_to_lxutil passes the untrusted guest atime/atimensec, mtime/mtimensec, and ctime/ctimensec fields directly to std::time::Duration::new:
if arg.valid & FATTR_ATIME != 0 {
attr.atime = if arg.valid & FATTR_ATIME_NOW != 0 {
lxutil::SetTime::Now
} else {
lxutil::SetTime::Set(Duration::new(arg.atime, arg.atimensec))
};
}
if arg.valid & FATTR_MTIME != 0 {
attr.mtime = if arg.valid & FATTR_MTIME_NOW != 0 {
lxutil::SetTime::Now
} else {
lxutil::SetTime::Set(Duration::new(arg.mtime, arg.mtimensec))
};
}
if arg.valid & FATTR_CTIME != 0 {
attr.ctime = lxutil::SetTime::Set(Duration::new(arg.ctime, arg.ctimensec));
}Both VirtioFsFile::set_attr and VirtioFsInode::set_attr, dispatched from VirtioFs::set_attr, invoke fuse_set_attr_to_lxutil infallibly on the parsed fuse_setattr_in payload. Because Duration::new(secs, nanos) adds (nanos / 1_000_000_000) as u64 onto secs and panics on u64 overflow in both debug and release builds, any nanosecond value >= 1_000_000_000 paired with secs == u64::MAX panics immediately.
Consequence
Any guest with access to a writable virtio-fs share (in direct, aggregate, or microVM mode, using either node-based SETATTR or handle-based SETATTR with FATTR_FH) can send a crafted FUSE_SETATTR message that panics the virtio-fs worker and crashes the VMM process. Even when secs is below u64::MAX, out-of-range nanosecond fields (>= 1_000_000_000) silently carry into seconds instead of failing with EINVAL as POSIX utimensat(2) specifies.
Reproduction
- Attach a writable
VirtioFsshare containing a regular file, look up the file's node ID, and optionally open a writable file handle. - Issue a
FUSE_SETATTR(fuse_setattr_in) request on that node (with or withoutFATTR_FH) settingvalid = FATTR_ATIME(andFATTR_ATIME_NOWunset),atime = u64::MAX, andatimensec = 1_000_000_000(or analogously forFATTR_MTIMEorFATTR_CTIME). - Observe that
VirtioFs::set_attrpanics withoverflow in Duration::newinstead of returningErr(lx::Error::EINVAL).
Activity
tangruize commentedon Nov 15, 2026
Suggested Fix
Validate guest-supplied nanosecond fields in
util::fuse_set_attr_to_lxutilvia a small helper (for exampleguest_time(secs: u64, nanos: u32) -> lx::Result<Duration>) that returnsErr(lx::Error::EINVAL)whenevernanos >= 1_000_000_000before callingDuration::new(secs, nanos). Changefuse_set_attr_to_lxutilto returnlx::Result<lxutil::SetAttributes>and propagate the error with?in bothVirtioFsInode::set_attrandVirtioFsFile::set_attr. Rejectingnanos >= 1_000_000_000matches POSIXutimensat(2)and does not affect standard Linux FUSE clients, which always send normalized sub-second nanosecond fields (if preserving carry behavior for non-overflowing timestamps were desired,guest_timecould instead usechecked_addon the carried seconds, though rejecting out-of-range nanoseconds up front is cleaner and standard).Patch against OpenVMM
9d64daad3cbe14fb0591081b73c6c9648e18d0fb. Save the contents below asfix.patchand rungit apply fix.patch.fix.patch