]> xenbits.xensource.com Git - xen.git/commitdiff
x86/HVM: correct MMIO emulation cache bounds check
authorJan Beulich <jbeulich@suse.com>
Mon, 17 Feb 2025 12:28:13 +0000 (13:28 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 17 Feb 2025 12:28:13 +0000 (13:28 +0100)
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 <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: e5339bb689dfa79a914c6c96e1d82d61e1ae3161
master date: 2025-01-23 11:14:48 +0100

xen/arch/x86/hvm/emulate.c

index 5742383139b86605e01897749827f8b7ced996f4..cebd4a51610e64b334803f265daf2a9c14cf405d 100644 (file)
@@ -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;