mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: handle malformed balloon actual from guest
The actual size of the balloon is taken directly from the guest. A misbehaving guest can set it to an arbitrary value and cause underflow on the next vm.info call. Use a saturation_sub instead to avoid a panic in a debug build or a crazy number in a release build. Signed-off-by: Dylan Reid <dgreid@dylanreid.com>
This commit is contained in:
@@ -2061,7 +2061,7 @@ impl RequestHandler for Vmm {
|
||||
|
||||
let mut memory_actual_size = config.memory.total_size();
|
||||
if let Some(vm) = &self.vm {
|
||||
memory_actual_size -= vm.balloon_size();
|
||||
memory_actual_size = memory_actual_size.saturating_sub(vm.balloon_size());
|
||||
}
|
||||
|
||||
let device_tree = self
|
||||
|
||||
Reference in New Issue
Block a user