Skip to content

Commit

Permalink
Fix leaky stack discovered by fuzzing host functions
Browse files Browse the repository at this point in the history
Signed-off-by: Ludvig Liljenberg <lliljenberg@microsoft.com>
  • Loading branch information
ludfjig committed Mar 5, 2025
1 parent e6baad3 commit 85a3e60
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/hyperlight_host/src/hypervisor/kvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,10 @@ impl Hypervisor for KVMDriver {
hv_handler: Option<HypervisorHandler>,
#[cfg(gdb)] dbg_mem_access_fn: DbgMemAccessHandlerWrapper,
) -> Result<()> {
// Reset general purpose registers except RSP, then set RIP
let rsp_before = self.vcpu_fd.get_regs()?.rsp;
// Reset general purpose registers, then set RIP and RSP
let regs = kvm_regs {
rip: dispatch_func_addr.into(),
rsp: rsp_before,
rsp: self.orig_rsp.absolute()?,
..Default::default()
};
self.vcpu_fd.set_regs(&regs)?;
Expand All @@ -774,11 +773,6 @@ impl Hypervisor for KVMDriver {
dbg_mem_access_fn,
)?;

// reset RSP to what it was before function call
self.vcpu_fd.set_regs(&kvm_regs {
rsp: rsp_before,
..Default::default()
})?;
Ok(())
}

Expand Down

0 comments on commit 85a3e60

Please sign in to comment.