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 <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-05-04 11:43:36 +02:00
committed by Rob Bradford
parent c5951252a5
commit 7fbc5a1354

View File

@@ -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;