Skip to content

Validate guest address ranges for overlapping regions in map_region / map_file_cow #1289

@simongdavies

Description

@simongdavies

Summary

HyperlightVm::map_region does not check whether a new guest address range overlaps with an already-mapped region. The VirtualMachine::map_memory safety contract explicitly requires non-overlapping regions, but map_region does not enforce this precondition. On WHP, overlapping mappings return a cryptic HRESULT (confirmed — WHvMapGpaRange2 rejects the call and the error is wrapped as a generic WindowsError). On KVM and MSHV, the behaviour is kernel/hypervisor-version-dependent and may range from an explicit error to silent shadowing of the previous mapping, risking data corruption.

Current Behaviour

HyperlightVm::map_region (in src/hyperlight_host/src/hypervisor/hyperlight_vm.rs) validates page alignment of guest and host addresses, assigns a unique slot, and calls the platform-specific map_memory. It does not check the new guest_region against existing entries in self.mmap_regions.

The existing mapped regions are readily available via self.mmap_regions (a Vec<(u32, MemoryRegion)>), so adding the check is straightforward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/confirmedBug is verified or proposal seems reasonable

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions