From: Jan Beulich Date: Mon, 17 Feb 2025 12:28:13 +0000 (+0100) Subject: x86/HVM: correct MMIO emulation cache bounds check X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0d2799a557b4e08ab4eb2dada46afeb6e6f56c1f;p=xen.git x86/HVM: correct MMIO emulation cache bounds check To avoid overrunning the internal buffer we need to take the offset into the buffer into account. Fixes: d95da91fb497 ("x86/HVM: grow MMIO cache data size to 64 bytes") Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné master commit: e5339bb689dfa79a914c6c96e1d82d61e1ae3161 master date: 2025-01-23 11:14:48 +0100 --- diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 5742383139..cebd4a5161 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -937,7 +937,7 @@ static int hvmemul_phys_mmio_access( } /* Accesses must not overflow the cache's buffer. */ - if ( size > sizeof(cache->buffer) ) + if ( offset + size > sizeof(cache->buffer) ) { ASSERT_UNREACHABLE(); return X86EMUL_UNHANDLEABLE;