You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
openvmm: memory-expansion range math overflows near the top of the GPA space #1364
canonical_memory_expansion_ranges adds before it subtracts, so when the RAM size is at least 2^64 - 4 GiB (and below the capacity), a debug build panics with "attempt to add with overflow" although the GPA it computes fits. A release build wraps and computes the correct value, so only debug builds are affected. No real VM has such a size, but a crafted snapshot manifest can declare one: opening it reaches the helper through the shape check validate_machine_contract_shape. Building a microVM's memory-expansion contract calls the helper too.
Reproduction
canonical_memory_expansion_ranges(2^64 - 2^32, 2^64 - 2^31) should return one range at GPA 2^64 - 3 GiB; in a debug build it panics at the gpa_start computation. The test memory_expansion_near_gpa_limit_does_not_overflow that fix.patch adds fails at the pin and passes with the fix.
Cause
For the high-RAM capacity range (gpa_start 4 GiB, file_offset 3 GiB), gpa_start + logical_start overflows before the subtraction brings the value back into range:
fix.patch computes gpa_start + (logical_start - file_offset). The subtraction cannot underflow, because logical_start is at least file_offset. The sum is at most the range's GPA end, which canonical_microvm_memory_ranges has already checked fits in a u64. The test checks the resulting range, and that validate_machine_contract_shape accepts the manifest built from it.
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_helpers: compute memory-expansion ranges without overflow
openvmm: pin overflow-free memory-expansion ranges
openvmm_helpers: compute memory-expansion ranges without overflow