From d36552471fc1d7cc1528176877b95df260c0bbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20Yi=C4=9Fit=20=C5=9Eahin?= Date: Mon, 1 Sep 2025 17:23:38 +0200 Subject: [PATCH] fix(virtio): don't include optional fields in minimum size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martin Kröning --- src/drivers/virtio/transport/pci.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/drivers/virtio/transport/pci.rs b/src/drivers/virtio/transport/pci.rs index 53d3a3728d..1e8f0bea30 100644 --- a/src/drivers/virtio/transport/pci.rs +++ b/src/drivers/virtio/transport/pci.rs @@ -123,8 +123,9 @@ impl PciCap { return None; } - // Drivers MAY do this check. See Virtio specification v1.1. - 4.1.4.1 - if self.len() < u64::try_from(mem::size_of::()).unwrap() { + // `CommonCfg::queue_notify_data` and `CommonCfg::queue_reset` are optional. + const MIN_SIZE: usize = mem::size_of::() - mem::size_of::<[le16; 2]>(); + if self.len() < u64::try_from(MIN_SIZE).unwrap() { error!( "Common config of with id {}, does not represent actual structure specified by the standard!", self.cap.id