mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: checked_descriptor: Add unit test for out of range descriptor
Add rejects_out_of_range_descriptor which submits a descriptor whose length overshoots guest memory and verifies CheckedDescriptorIter yields no descriptor and sets the failed flag. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
d24e2fd140
commit
782ce21c1a
@@ -228,4 +228,14 @@ mod unit_tests {
|
||||
assert!(desc.is_write_only());
|
||||
assert!(it.next().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_out_of_range_descriptor() {
|
||||
let (_mem, mem_atomic, mut queue) = setup_vq(128 * 1024, 0x4000, 1 << 30, 0);
|
||||
let mem_guard = mem_atomic.memory();
|
||||
let mut chain = queue.pop_descriptor_chain(mem_guard).unwrap();
|
||||
let mut it = chain.checked_iter(None);
|
||||
let result = it.next().expect("iterator must yield an item");
|
||||
result.unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user