Repository navigation
Description
A VM worker restoring a microVM snapshot panics at load with "assertion failed: range.end & (PAGE_SIZE - 1) == 0" when its launch message carries a snapshot or restore RAM range that is not 4-KiB-aligned, or ends before it starts, and that range merges with its neighbour into another invalid range. The assertion fires in release builds too, and panic = 'abort' ends the worker's process. Malformed ranges that merge into a valid range are not caught at all, and reach the RAM backing as they are. Only a launch message that OpenVMM's controller did not build carries such a range: the controller builds every snapshot and restore range with MemoryRange::new, and only MemoryRange's Protobuf decoding skips that constructor's checks.
Reproduction
Decode a MemoryRange with start 0x1000 and end 0x1800 (Protobuf fields 1 and 2), and put it after MemoryRange::new(0..0x1000) in snapshot_memory_ranges of an otherwise valid microVM configuration that has a RAM capacity. validate_machine_config should refuse the configuration; it accepts it. Load then merges the two into MemoryRange::new(0..0x1800), which panics on the unaligned end.
Cause
validate_machine_config looks at the snapshot ranges only to require a RAM capacity for them, never at their bounds:
// openvmm/openvmm_defs/src/microvm.rs
if let Some(memory_capacity) = config.microvm.memory_capacity {
// ...
} else {
anyhow::ensure!(
config.microvm.snapshot_memory_ranges.is_empty()
&& config.microvm.restore_memory_ranges.is_empty(),
"microVM snapshot RAM ranges require a RAM capacity"
);
}At load, add_snapshot_restore_backing merges adjacent ranges in coalesce_adjacent_ranges with MemoryRange::new, which asserts alignment and ordering:
// openvmm/openvmm_core/src/worker/dispatch/microvm.rs
if range.start() == previous.end() {
*previous = MemoryRange::new(previous.start()..range.end());Fix
fix.patch adds validate_snapshot_memory_ranges, which validate_machine_config calls after the RAM-capacity check. It requires MemoryRange::try_new(start..end) to succeed for every snapshot range and every restore range, and otherwise fails with "microVM snapshot RAM ranges must be page-aligned ranges", so the worker fails to start instead of aborting at load. Checking only in coalesce_adjacent_ranges would still let malformed ranges that merge into a valid range reach the RAM backing. Every range built with MemoryRange::new validates as before. The test decoded_snapshot_memory_ranges_are_validated decodes an unaligned end, an unaligned start and a reversed range into both lists and expects each to be refused, and checks that valid ranges pass. It adds test_with_tracing as a dev-dependency of openvmm_defs.
Related: #1372.
Activity
tangruize commentedon Nov 8, 2026
Proposed patch
Patch against OpenVMM 3cf58a5234ed824435825c9f87187f5129219724. Save the contents below as
fix.patchand rungit apply fix.patch.fix.patchopenvmm: pin the refusal of malformed decoded snapshot RAM ranges
microVM: refuse an unaligned or reversed decoded snapshot RAM range