Skip to content

Commit 6507325

Browse files
dgreidrbradford
authored andcommitted
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>
1 parent 0b90180 commit 6507325

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

vmm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ impl RequestHandler for Vmm {
20612061

20622062
let mut memory_actual_size = config.memory.total_size();
20632063
if let Some(vm) = &self.vm {
2064-
memory_actual_size -= vm.balloon_size();
2064+
memory_actual_size = memory_actual_size.saturating_sub(vm.balloon_size());
20652065
}
20662066

20672067
let device_tree = self

0 commit comments

Comments
 (0)