Skip to content

Fix bad state on unmap failure#1675

Merged
ludfjig merged 1 commit into
hyperlight-dev:mainfrom
ludfjig:snapshot-restore-unmap-ownership
Jul 22, 2026
Merged

Fix bad state on unmap failure#1675
ludfjig merged 1 commit into
hyperlight-dev:mainfrom
ludfjig:snapshot-restore-unmap-ownership

Conversation

@ludfjig

@ludfjig ludfjig commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fixes a potential issue where state gets messed up if the hv unmap fails, but we still mark it as removed. Fixed by unmapping first, and only then mark removed

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 21:36
@ludfjig ludfjig added the kind/bugfix For PRs that fix bugs label Jul 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an error-path state consistency issue in HyperlightVm::unmap_region: if the hypervisor unmap operation fails, the VM should not forget the region or free the slot. The change keeps mmap_regions and freed_slots consistent with the actual hypervisor mapping state.

Changes:

  • Unmap the memory region in the hypervisor before removing it from mmap_regions.
  • Only return the slot to freed_slots after a successful unmap.

@ludfjig ludfjig changed the title Fix dynamic mapping ownership on unmap failure Fix bad state on unmap failure Jul 21, 2026
@ludfjig ludfjig added the ready-for-review PR is ready for (re-)review label Jul 21, 2026
Comment thread src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs
@ludfjig
ludfjig merged commit aa9d2e5 into hyperlight-dev:main Jul 22, 2026
46 of 47 checks passed
@github-actions github-actions Bot removed the ready-for-review PR is ready for (re-)review label Jul 22, 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.

3 participants