All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/3] Firmware 20260617 patches
@ 2026-06-17 10:09 Gerd Hoffmann
  2026-06-17 10:09 ` [PULL 1/3] hw/uefi: fix parse_hexstr Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-06-17 10:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefano Garzarella, Ani Sinha, Gerd Hoffmann

The following changes since commit b0df6e2f2c6c45df8d4d286933799c623e124d98:

  Merge tag 'pull-riscv-to-apply-20260616' of https://github.com/alistair23/qemu into staging (2026-06-16 10:41:47 -0400)

are available in the Git repository at:

  https://gitlab.com/kraxel/qemu.git tags/firmware-20260617-pull-request

for you to fetch changes up to 3f24c8a74ce89686143be2517b4c1e98651bb913:

  igvm: fix handling of optional variable header types (2026-06-17 09:42:57 +0200)

----------------------------------------------------------------
bugfixes and cleanups for igvm and uefi-vars

----------------------------------------------------------------

Gerd Hoffmann (1):
  hw/uefi: fix parse_hexstr

Luigi Leonardi (2):
  igvm: replace raw uint32_t with igvm library types
  igvm: fix handling of optional variable header types

 backends/igvm.c            | 41 ++++++++++++++++++++++++++++++++------
 hw/uefi/var-service-json.c |  2 +-
 2 files changed, 36 insertions(+), 7 deletions(-)

-- 
2.54.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PULL 1/3] hw/uefi: fix parse_hexstr
  2026-06-17 10:09 [PULL 0/3] Firmware 20260617 patches Gerd Hoffmann
@ 2026-06-17 10:09 ` Gerd Hoffmann
  2026-06-17 10:09 ` [PULL 2/3] igvm: replace raw uint32_t with igvm library types Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-06-17 10:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stefano Garzarella, Ani Sinha, Gerd Hoffmann, Feifan Qian,
	Philippe Mathieu-Daudé

Make sure we actually have two input characters available before going
to parse two hex digits.  Fixes one byte buffer overflow of the output
buffer in case the input string has an odd number of characters.

Fixes: CVE-2026-48915
Fixes: 12058948abdf ("hw/uefi: add var-service-json.c + qapi for NV vars.")
Reported-by: Feifan Qian <bea1e@proton.me>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20260526135948.599148-1-kraxel@redhat.com>
---
 hw/uefi/var-service-json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/uefi/var-service-json.c b/hw/uefi/var-service-json.c
index f5f155683334..8621b86c5c5f 100644
--- a/hw/uefi/var-service-json.c
+++ b/hw/uefi/var-service-json.c
@@ -98,7 +98,7 @@ static void parse_hexstr(void *dest, char *src, int len)
     uint8_t *data = dest;
     size_t i;
 
-    for (i = 0; i < len; i += 2) {
+    for (i = 0; i + 1 < len; i += 2) {
         *(data++) =
             parse_hexchar(src[i]) << 4 |
             parse_hexchar(src[i + 1]);
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 2/3] igvm: replace raw uint32_t with igvm library types
  2026-06-17 10:09 [PULL 0/3] Firmware 20260617 patches Gerd Hoffmann
  2026-06-17 10:09 ` [PULL 1/3] hw/uefi: fix parse_hexstr Gerd Hoffmann
@ 2026-06-17 10:09 ` Gerd Hoffmann
  2026-06-17 10:09 ` [PULL 3/3] igvm: fix handling of optional variable header types Gerd Hoffmann
  2026-06-17 19:30 ` [PULL 0/3] Firmware 20260617 patches Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-06-17 10:09 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stefano Garzarella, Ani Sinha, Gerd Hoffmann, Luigi Leonardi,
	Philippe Mathieu-Daudé

From: Luigi Leonardi <leonardi@redhat.com>

Use IgvmVariableHeaderType and IgvmHeaderSection in QIGVMHandler and
qigvm_handler() instead of plain uint32_t, so that each field's purpose
is clear from its type.

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260609-igvm_optional-v2-1-b1f1f08dc40e@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 backends/igvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/backends/igvm.c b/backends/igvm.c
index 9b889f04287e..3ccbafe9b90c 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -102,8 +102,8 @@ static int qigvm_initialization_guest_policy(QIgvm *ctx,
                                        Error **errp);
 
 struct QIGVMHandler {
-    uint32_t type;
-    uint32_t section;
+    IgvmVariableHeaderType type;
+    IgvmHeaderSection section;
     int (*handler)(QIgvm *ctx, const uint8_t *header_data, Error **errp);
 };
 
@@ -132,7 +132,7 @@ static struct QIGVMHandler handlers[] = {
       qigvm_directive_madt },
 };
 
-static int qigvm_handler(QIgvm *ctx, uint32_t type, Error **errp)
+static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType type, Error **errp)
 {
     size_t handler;
     IgvmHandle header_handle;
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 3/3] igvm: fix handling of optional variable header types
  2026-06-17 10:09 [PULL 0/3] Firmware 20260617 patches Gerd Hoffmann
  2026-06-17 10:09 ` [PULL 1/3] hw/uefi: fix parse_hexstr Gerd Hoffmann
  2026-06-17 10:09 ` [PULL 2/3] igvm: replace raw uint32_t with igvm library types Gerd Hoffmann
@ 2026-06-17 10:09 ` Gerd Hoffmann
  2026-06-17 19:30 ` [PULL 0/3] Firmware 20260617 patches Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2026-06-17 10:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefano Garzarella, Ani Sinha, Gerd Hoffmann, Luigi Leonardi

From: Luigi Leonardi <leonardi@redhat.com>

The IGVM spec defines bit 31 of the variable header type as an
optional flag: if set, a loader that does not recognize the header
type may safely skip it. If clear, the loader must reject the file.

Currently, the optional bit is not stripped before comparing header
types, so headers with the bit set fail to match any known type
and are rejected.

Mask bit 31 before comparing header types throughout the IGVM
loader, and skip with a warning any unrecognized header that has
the optional bit set.

Fixes: c1d466d267cf ("backends/igvm: Add IGVM loader and configuration")
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Message-ID: <20260609-igvm_optional-v2-2-b1f1f08dc40e@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 backends/igvm.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/backends/igvm.c b/backends/igvm.c
index 3ccbafe9b90c..3f4b97a5d417 100644
--- a/backends/igvm.c
+++ b/backends/igvm.c
@@ -26,6 +26,25 @@
 #include <igvm/igvm.h>
 #include <igvm/igvm_defs.h>
 
+#ifndef IGVM_VHT_OPTIONAL_BIT
+#define IGVM_VHT_OPTIONAL_BIT (1U << 31)
+#endif
+
+/*
+ * Bit 31 of the variable header type indicates that the header is
+ * optional and can be safely ignored by a loader that does not
+ * support it. If the bit is clear, the file cannot be loaded.
+ * https://docs.rs/igvm_defs/0.4.0/igvm_defs/struct.IgvmVariableHeaderType.html
+ */
+static IgvmVariableHeaderType igvm_vht_type(IgvmVariableHeaderType type)
+{
+    return type & ~IGVM_VHT_OPTIONAL_BIT;
+}
+
+static bool igvm_vht_optional(IgvmVariableHeaderType type)
+{
+    return !!(type & IGVM_VHT_OPTIONAL_BIT);
+}
 
 /*
  * Some directives are specific to particular confidential computing platforms.
@@ -132,12 +151,14 @@ static struct QIGVMHandler handlers[] = {
       qigvm_directive_madt },
 };
 
-static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType type, Error **errp)
+static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType raw_type,
+                         Error **errp)
 {
     size_t handler;
     IgvmHandle header_handle;
     const uint8_t *header_data;
     int result;
+    IgvmVariableHeaderType type = igvm_vht_type(raw_type);
 
     for (handler = 0; handler < G_N_ELEMENTS(handlers); handler++) {
         if (handlers[handler].type != type) {
@@ -166,6 +187,13 @@ static int qigvm_handler(QIgvm *ctx, IgvmVariableHeaderType type, Error **errp)
         igvm_free_buffer(ctx->file, header_handle);
         return result;
     }
+
+    if (igvm_vht_optional(raw_type)) {
+        warn_report("IGVM: Skipping unsupported optional header type 0x%"
+                    PRIX32, type);
+        return 0;
+    }
+
     error_setg(errp,
                "IGVM: Unknown header type encountered when processing file: "
                "(type 0x%X)",
@@ -787,6 +815,7 @@ static int qigvm_supported_platform_compat_mask(QIgvm *ctx, Error **errp)
          header_index++) {
         IgvmVariableHeaderType typ = igvm_get_header_type(
             ctx->file, IGVM_HEADER_SECTION_PLATFORM, header_index);
+        typ = igvm_vht_type(typ);
         if (typ == IGVM_VHT_SUPPORTED_PLATFORM) {
             header_handle = igvm_get_header(
                 ctx->file, IGVM_HEADER_SECTION_PLATFORM, header_index);
@@ -945,10 +974,10 @@ int qigvm_process_file(IgvmCfg *cfg, MachineState *machine_state,
     for (ctx.current_header_index = 0;
          ctx.current_header_index < (unsigned)header_count;
          ctx.current_header_index++) {
-        IgvmVariableHeaderType type = igvm_get_header_type(
+        IgvmVariableHeaderType raw_type = igvm_get_header_type(
             ctx.file, IGVM_HEADER_SECTION_DIRECTIVE, ctx.current_header_index);
-        if (!onlyVpContext || (type == IGVM_VHT_VP_CONTEXT)) {
-            if (qigvm_handler(&ctx, type, errp) < 0) {
+        if (!onlyVpContext || igvm_vht_type(raw_type) == IGVM_VHT_VP_CONTEXT) {
+            if (qigvm_handler(&ctx, raw_type, errp) < 0) {
                 goto cleanup_parameters;
             }
         }
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PULL 0/3] Firmware 20260617 patches
  2026-06-17 10:09 [PULL 0/3] Firmware 20260617 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2026-06-17 10:09 ` [PULL 3/3] igvm: fix handling of optional variable header types Gerd Hoffmann
@ 2026-06-17 19:30 ` Stefan Hajnoczi
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2026-06-17 19:30 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Stefano Garzarella, Ani Sinha, Gerd Hoffmann

[-- Attachment #1: Type: text/plain, Size: 116 bytes --]

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-17 19:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-17 10:09 [PULL 0/3] Firmware 20260617 patches Gerd Hoffmann
2026-06-17 10:09 ` [PULL 1/3] hw/uefi: fix parse_hexstr Gerd Hoffmann
2026-06-17 10:09 ` [PULL 2/3] igvm: replace raw uint32_t with igvm library types Gerd Hoffmann
2026-06-17 10:09 ` [PULL 3/3] igvm: fix handling of optional variable header types Gerd Hoffmann
2026-06-17 19:30 ` [PULL 0/3] Firmware 20260617 patches Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.