From 7fbc5a13540b560152425f5299e1b9d061058416 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 4 May 2026 11:43:36 +0200 Subject: [PATCH] pci: msix: Replace panic with graceful error on invalid table write A malicious or buggy guest can issue an MSI-X table write with an unexpected size (not 4 or 8 bytes), triggering an assert!() that crashes the VMM process. Replace the assertion with an error log and early return to maintain VMM stability under adversarial guest behavior. Signed-off-by: Anatol Belski --- pci/src/msix.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pci/src/msix.rs b/pci/src/msix.rs index 49b379b02..05a1d8ce5 100644 --- a/pci/src/msix.rs +++ b/pci/src/msix.rs @@ -321,7 +321,13 @@ impl MsixConfig { } pub fn write_table(&mut self, offset: u64, data: &[u8]) { - assert!(data.len() == 4 || data.len() == 8); + if data.len() != 4 && data.len() != 8 { + error!( + "invalid MSI-X table write size: {} (allowed: 4 or 8)", + data.len() + ); + return; + } let index: usize = (offset / MSIX_TABLE_ENTRIES_MODULO) as usize; let modulo_offset = offset % MSIX_TABLE_ENTRIES_MODULO;