diff --git a/virtio-devices/src/iommu.rs b/virtio-devices/src/iommu.rs index fcf837383..de03bbc46 100644 --- a/virtio-devices/src/iommu.rs +++ b/virtio-devices/src/iommu.rs @@ -388,6 +388,7 @@ impl Request { let mut reply: Vec = 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