Skip to contentSkip to conversation

hw/uefi: fix heap overflow (CVE-2026-5744)

PATCH In review Gerd Hoffmann 3 participants 3 messages Apr 8 – Apr 9

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/uefi: fix heap overflow (CVE-2026-5744)

When copying the request response into the pio transfer buffer the code skips the 'struct mm_header' but does not consider that when calculating transfer size, so it will copy 24 (== sizeof(struct mm_header)) extra bytes, which can overflow uv->pio_xfer_buffer.

Fix that by copying the complete buffer, including the header, which also makes the pio code path consistent with the (unaffected) dma code path.

Fixes CVE-2026-5744
Fixes 90ca4e03c27d ("hw/uefi: add var-service-core.c")
---
 hw/uefi/var-service-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
hw/uefi/var-service-core.c +2 -3
index ce0628fa5248..68d7594c0dd6 100644
@@ -137,9 +137,8 @@ static uint32_t uefi_vars_cmd_mm(uefi_vars_state *uv, bool dma_mode)
                          uv->buffer, sizeof(*mhdr) + mhdr->length,
                          MEMTXATTRS_UNSPECIFIED);
     } else {
-        memcpy(uv->pio_xfer_buffer + sizeof(*mhdr),
-               uv->buffer + sizeof(*mhdr),
-               sizeof(*mhdr) + mhdr->length);
+        memcpy(uv->pio_xfer_buffer,
+               uv->buffer, sizeof(*mhdr) + mhdr->length);
     }
 
     return retval;
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Gerd Hoffmann

When copying the request response into the pio transfer buffer the code skips the 'struct mm_header' but does not consider that when calculating transfer size, so it will copy 24 (== sizeof(struct mm_header)) extra bytes, which can overflow uv->pio_xfer_buffer.

Fix that by copying the complete buffer, including the header, which also makes the pio code path consistent with the (unaffected) dma code path.

Quoted 7 lines
Fixes CVE-2026-5744
Fixes 90ca4e03c27d ("hw/uefi: add var-service-core.c")
---
 hw/uefi/var-service-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
#2 lore raw
Quoted 19 lines · Daniel P. Berrangé
Quoted 9 lines · Gerd Hoffmann

When copying the request response into the pio transfer buffer the code skips the 'struct mm_header' but does not consider that when calculating transfer size, so it will copy 24 (== sizeof(struct mm_header)) extra bytes, which can overflow uv->pio_xfer_buffer.

Fix that by copying the complete buffer, including the header, which also makes the pio code path consistent with the (unaffected) dma code path.

Quoted 7 lines
Fixes CVE-2026-5744
Fixes 90ca4e03c27d ("hw/uefi: add var-service-core.c")
---
 hw/uefi/var-service-core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 1 line

Thanks; I'm applying this one directly to git so we can get it into today's RC.

-- PMM