mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
release_memory_range took (range_base, range_len) verbatim from a guest-controlled descriptor (free-page-reporting and inflate paths) and called fallocate(PUNCH_HOLE | KEEP_SIZE) on the backing file before any length check ran. find_region only validates that range_base lands inside *some* region; range_len can extend past the region's end. When the operator uses --memory-zone file=PATH against a host file larger than the zone, the punch zeroes host file content past the guest's memory extent. Free-page reporting is advisory, so the VMM is allowed to act on a subset of a free range. Clamp range_len to the bytes that actually fit within the region returned by find_region. Going past the end of a region is most likely a guest bug so log it. Signed-off-by: Dylan Reid <dgreid@fb.com>