Skip to contentSkip to conversation

hw/smbios: Fix option validation

PATCH Superseded Akihiko Odaki 2 participants 5 messages Jan 28, 2024 – Jan 29, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover hw/smbios: Fix option validation

This fixes qemu_smbios_type8_opts and qemu_smbios_type11_opts to have list terminators and elements for the type option.

---
Akihiko Odaki (2):
hw/smbios: Fix OEM strings table option validation hw/smbios: Fix port connector option validation

 hw/smbios/smbios.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

---
base-commit: f614acb7450282a119d85d759f27eae190476058
change-id: 20240128-smbios-be5c321d7158

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>
#1 lore raw

PATCH 1/2 hw/smbios: Fix OEM strings table option validation

qemu_smbios_type11_opts did not the list terminator and that resulted in out-of-bound memory access. qemu_smbios_type11_opts also needs to have an element for the type option.

Fixes 2d6dcbf93fb0 ("smbios: support setting OEM strings table")
---
 hw/smbios/smbios.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/smbios/smbios.c +6 -0
index 2a90601ac5d9..522ed1ed9fe3 100644
@@ -369,6 +369,11 @@ static const QemuOptDesc qemu_smbios_type8_opts[] = {
 };
 
 static const QemuOptDesc qemu_smbios_type11_opts[] = {
+    {
+        .name = "type",
+        .type = QEMU_OPT_NUMBER,
+        .help = "SMBIOS element type",
+    },
     {
         .name = "value",
         .type = QEMU_OPT_STRING,
@@ -379,6 +384,7 @@ static const QemuOptDesc qemu_smbios_type11_opts[] = {
         .type = QEMU_OPT_STRING,
         .help = "OEM string data from file",
     },
+    { /* end of list */ }
 };
 
 static const QemuOptDesc qemu_smbios_type17_opts[] = {
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] hw/smbios: Fix OEM strings table option validation

28.01.2024 10:15, Akihiko Odaki:

Quoted 1 line

qemu_smbios_type11_opts did not the list terminator and that resulted in

..did not *have* the list terminator.., here and in 2/2.

Quoted 4 lines

out-of-bound memory access. qemu_smbios_type11_opts also needs to have an element for the type option.

Fixes 2d6dcbf93fb0 ("smbios: support setting OEM strings table")

Wow. That's long ago..

This is a -stable material.
And since it's exactly the same 2 problems in 2 nearby places, it can be combined into a single patch, but it definitely works this way too, just a question of taste.

Quoted 30 lines
---
  hw/smbios/smbios.c | 6 ++++++
  1 file changed, 6 insertions(+)
hw/smbios/smbios.c +6 -0
index 2a90601ac5d9..522ed1ed9fe3 100644
@@ -369,6 +369,11 @@ static const QemuOptDesc qemu_smbios_type8_opts[] = {
  };
 
  static const QemuOptDesc qemu_smbios_type11_opts[] = {
+    {
+        .name = "type",
+        .type = QEMU_OPT_NUMBER,
+        .help = "SMBIOS element type",
+    },
      {
          .name = "value",
          .type = QEMU_OPT_STRING,
@@ -379,6 +384,7 @@ static const QemuOptDesc qemu_smbios_type11_opts[] = {
          .type = QEMU_OPT_STRING,
          .help = "OEM string data from file",
      },
+    { /* end of list */ }
  };
 
  static const QemuOptDesc qemu_smbios_type17_opts[] = {
#3 lore raw

PATCH 2/2 hw/smbios: Fix port connector option validation

In reply to Akihiko Odaki

qemu_smbios_type8_opts did not the list terminator and that resulted in out-of-bound memory access. qemu_smbios_type8_opts also needs to have an element for the type option.

Fixes fd8caa253c56 ("hw/smbios: support for type 8 (port connector)")
---
 hw/smbios/smbios.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/smbios/smbios.c +6 -0
index 522ed1ed9fe3..8a44d3f271de 100644
@@ -346,6 +346,11 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
 };
 
 static const QemuOptDesc qemu_smbios_type8_opts[] = {
+    {
+        .name = "type",
+        .type = QEMU_OPT_NUMBER,
+        .help = "SMBIOS element type",
+    },
     {
         .name = "internal_reference",
         .type = QEMU_OPT_STRING,
@@ -366,6 +371,7 @@ static const QemuOptDesc qemu_smbios_type8_opts[] = {
         .type = QEMU_OPT_NUMBER,
         .help = "port type",
     },
+    { /* end of list */ }
 };
 
 static const QemuOptDesc qemu_smbios_type11_opts[] = {
Signature · 1 line
2.43.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] hw/smbios: Fix port connector option validation

28.01.2024 10:15, Akihiko Odaki:

Quoted 3 lines

qemu_smbios_type8_opts did not the list terminator and that resulted in out-of-bound memory access. qemu_smbios_type8_opts also needs to have an element for the type option.

With the same description fix as in 1/1,

/mjt