From 8fb4aa61c74dbe351609b83ca0396d85e7bc7be1 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Sun, 26 Apr 2026 22:11:40 +0100 Subject: [PATCH] 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 Assisted-by: Claude:claude-opus-4-7 --- virtio-devices/src/iommu.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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