Skip to contentSkip to conversation

hw/uefi: fix size negotiation

PATCH In review Gerd Hoffmann 2 participants 2 messages Jan 14 – Feb 4

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/uefi: fix size negotiation

Payload size is the variable request size, not the total buffer size. Take that into account and subtract header sizes.

Fixes db1ecfb473ac ("hw/uefi: add var-service-vars.c")
---
 hw/uefi/var-service-vars.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/uefi/var-service-vars.c +1 -1
index 8533533ea5c8..5607763525b3 100644
@@ -592,7 +592,7 @@ uefi_vars_mm_get_payload_size(uefi_vars_state *uv, mm_header *mhdr,
         return uefi_vars_mm_error(mhdr, mvar, EFI_BAD_BUFFER_SIZE);
     }
 
-    ps->payload_size = uv->buf_size;
+    ps->payload_size = uv->buf_size - sizeof(*mhdr) - sizeof(*mvar);
     mvar->status = EFI_SUCCESS;
     return length;
 }
Signature · 1 line
2.52.0
#1 lore raw
Quoted 4 lines · Gerd Hoffmann

Payload size is the variable request size, not the total buffer size. Take that into account and subtract header sizes.

Fixes db1ecfb473ac ("hw/uefi: add var-service-vars.c")

This feels like a qemu-stable material.
Please let me know if it isn't.

Thanks,

/mjt

Quoted 11 lines
hw/uefi/var-service-vars.c +1 -1
@@ -592,7 +592,7 @@ uefi_vars_mm_get_payload_size(uefi_vars_state *uv, mm_header *mhdr,
          return uefi_vars_mm_error(mhdr, mvar, EFI_BAD_BUFFER_SIZE);
      }
 
-    ps->payload_size = uv->buf_size;
+    ps->payload_size = uv->buf_size - sizeof(*mhdr) - sizeof(*mvar);
      mvar->status = EFI_SUCCESS;
      return length;
  }