Skip to contentSkip to conversation

hw/uefi: clear uefi-vars buffer in uefi_vars_write callback

PATCH New Mauro Matteo Cascella 1 participant 1 message Aug 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/uefi: clear uefi-vars buffer in uefi_vars_write callback

When the guest writes to register UEFI_VARS_REG_BUFFER_SIZE, the .write callback uefi_vars_write is invoked. The function allocates a heap buffer without zeroing the memory, leaving the buffer filled with residual data from prior allocations. When the guest later reads from register UEFI_VARS_REG_PIO_BUFFER_TRANSFER, the .read callback uefi_vars_read returns leftover metadata or other sensitive process memory from the previously allocated buffer, leading to an information disclosure vulnerability.

Fixes CVE-2025-8860
Fixes 90ca4e03c27d ("hw/uefi: add var-service-core.c")
---
 hw/uefi/var-service-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/uefi/var-service-core.c +2 -2
index feec5a5958..6ab8df091a 100644
@@ -259,8 +259,8 @@ static void uefi_vars_write(void *opaque, hwaddr addr, uint64_t val, unsigned si
         uv->buf_size = val;
         g_free(uv->buffer);
         g_free(uv->pio_xfer_buffer);
-        uv->buffer = g_malloc(uv->buf_size);
-        uv->pio_xfer_buffer = g_malloc(uv->buf_size);
+        uv->buffer = g_malloc0(uv->buf_size);
+        uv->pio_xfer_buffer = g_malloc0(uv->buf_size);
         break;
     case UEFI_VARS_REG_DMA_BUFFER_ADDR_LO:
         uv->buf_addr_lo = val;
Signature · 1 line
2.50.1