Skip to content

fix: Validate guest address ranges for overlapping regions in map_region#1369

Draft
Richard-Durkee wants to merge 1 commit intohyperlight-dev:mainfrom
Richard-Durkee:fix/validate-map-region-overlap
Draft

fix: Validate guest address ranges for overlapping regions in map_region#1369
Richard-Durkee wants to merge 1 commit intohyperlight-dev:mainfrom
Richard-Durkee:fix/validate-map-region-overlap

Conversation

@Richard-Durkee
Copy link
Copy Markdown

Add overlap validation to HyperlightVm::map_region to enforce the safety contract documented on VirtualMachine::map_memory, which requires that memory regions must not overlap.

The check validates the new region against:

  • Existing dynamically mapped regions (mmap_regions)
  • The snapshot region (starting at BASE_ADDRESS)
  • The scratch region (at the top of the GPA space)

Add Overlapping variant to MapRegionError with a descriptive message showing both the new and conflicting ranges.

Add four tests covering:

  • Exact duplicate mapping rejection
  • Partial overlap rejection
  • Adjacent non-overlapping regions (should succeed)
  • Overlap with the snapshot region

Add overlap validation to HyperlightVm::map_region to enforce the
safety contract documented on VirtualMachine::map_memory, which
requires that memory regions must not overlap.

The check validates the new region against:
- Existing dynamically mapped regions (mmap_regions)
- The snapshot region (starting at BASE_ADDRESS)
- The scratch region (at the top of the GPA space)

Add Overlapping variant to MapRegionError with a descriptive message
showing both the new and conflicting ranges.

Add four tests covering:
- Exact duplicate mapping rejection
- Partial overlap rejection
- Adjacent non-overlapping regions (should succeed)
- Overlap with the snapshot region

Signed-off-by: Richard Durkee <Richard-Durkee@users.noreply.github.com>
@ludfjig ludfjig added the kind/bugfix For PRs that fix bugs label Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bugfix For PRs that fix bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants