mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: iommu: Drop unrecognised requests without writing reply
The virtio spec requires the device to leave the reply buffer untouched and report a used length of zero for an unrecognised request type, so the driver can tell the request was not handled. Signed-off-by: Rob Bradford <rbradford@meta.com> Assisted-by: Claude:claude-opus-4-7
This commit is contained in:
@@ -388,6 +388,7 @@ impl Request {
|
||||
let mut reply: Vec<u8> = Vec::new();
|
||||
let mut status = VIRTIO_IOMMU_S_OK;
|
||||
let mut hdr_len = 0;
|
||||
let mut unrecognised_type = false;
|
||||
|
||||
let result = (|| {
|
||||
match req_head.type_ {
|
||||
@@ -679,13 +680,19 @@ impl Request {
|
||||
hdr_len = PROBE_PROP_SIZE;
|
||||
}
|
||||
_ => {
|
||||
status = VIRTIO_IOMMU_S_INVAL;
|
||||
unrecognised_type = true;
|
||||
return Err(Error::InvalidRequest);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})();
|
||||
|
||||
// virtio spec: unrecognised request types must not have the reply
|
||||
// buffer written and must report a used length of zero.
|
||||
if unrecognised_type {
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
let status_desc = desc_chain.next().ok_or(Error::DescriptorChainTooShort)?;
|
||||
|
||||
// The status MUST always be writable
|
||||
|
||||
Reference in New Issue
Block a user