[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 26/47] hw/smbios: fix field corruption in type 4 table
From: |
Michael Tokarev |
Subject: |
[PATCH 26/47] hw/smbios: fix field corruption in type 4 table |
Date: |
Wed, 8 Mar 2023 19:57:29 +0300 |
From: Julia Suvorova <jusual@redhat.com>
Since table type 4 of SMBIOS version 2.6 is shorter than 3.0, the
strings which follow immediately after the struct fields have been
overwritten by unconditional filling of later fields such as core_count2.
Make these fields dependent on the SMBIOS version.
Fixes: 05e27d74c7 ("hw/smbios: add core_count2 to smbios table type 4")
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2169904
Signed-off-by: Julia Suvorova <jusual@redhat.com>
Message-Id: <20230223125747.254914-1-jusual@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 60d09b8dc7dd4256d664ad680795cb1327805b2b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/smbios/smbios.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index b4243de735..66a020999b 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -749,14 +749,16 @@ static void smbios_build_type_4_table(MachineState *ms,
unsigned instance)
t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores;
t->core_enabled = t->core_count;
- t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
-
t->thread_count = (ms->smp.threads > 255) ? 0xFF : ms->smp.threads;
- t->thread_count2 = cpu_to_le16(ms->smp.threads);
t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
t->processor_family2 = cpu_to_le16(0x01); /* Other */
+ if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
+ t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
+ t->thread_count2 = cpu_to_le16(ms->smp.threads);
+ }
+
SMBIOS_BUILD_TABLE_POST;
smbios_type4_count++;
}
--
2.30.2
- [PATCH 18/47] qcow2: Fix theoretical corruption in store_bitmap() error path, (continued)
- [PATCH 18/47] qcow2: Fix theoretical corruption in store_bitmap() error path, Michael Tokarev, 2023/03/08
- [PATCH 16/47] migration/ram: Fix error handling in ram_write_tracking_start(), Michael Tokarev, 2023/03/08
- [PATCH 22/47] target/i386: Fix C flag for BLSI, BLSMSK, BLSR, Michael Tokarev, 2023/03/08
- [PATCH 17/47] migration/ram: Fix populate_read_range(), Michael Tokarev, 2023/03/08
- [PATCH 15/47] target/arm: Fix physical address resolution for Stage2, Michael Tokarev, 2023/03/08
- [PATCH 20/47] tests/tcg/i386: Introduce and use reg_t consistently, Michael Tokarev, 2023/03/08
- [PATCH 19/47] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF, Michael Tokarev, 2023/03/08
- [PATCH 24/47] target/i386: Fix BZHI instruction, Michael Tokarev, 2023/03/08
- [PATCH 21/47] target/i386: Fix BEXTR instruction, Michael Tokarev, 2023/03/08
- [PATCH 23/47] target/i386: fix ADOX followed by ADCX, Michael Tokarev, 2023/03/08
- [PATCH 26/47] hw/smbios: fix field corruption in type 4 table,
Michael Tokarev <=
- [PATCH 25/47] block/iscsi: fix double-free on BUSY or similar statuses, Michael Tokarev, 2023/03/08
- [PATCH 27/47] Revert "x86: do not re-randomize RNG seed on snapshot load", Michael Tokarev, 2023/03/08
- [PATCH 32/47] Revert "hw/i386: pass RNG seed via setup_data entry", Michael Tokarev, 2023/03/08
- [PATCH 28/47] Revert "x86: re-initialize RNG seed when selecting kernel", Michael Tokarev, 2023/03/08
- [PATCH 29/47] Revert "x86: reinitialize RNG seed on system reboot", Michael Tokarev, 2023/03/08
- [PATCH 33/47] vhost-user-gpio: Configure vhost_dev when connecting, Michael Tokarev, 2023/03/08
- [PATCH 31/47] Revert "x86: return modified setup_data only if read as memory, not as file", Michael Tokarev, 2023/03/08
- [PATCH 30/47] Revert "x86: use typedef for SetupData struct", Michael Tokarev, 2023/03/08
- [PATCH 34/47] vhost-user-i2c: Back up vqs before cleaning up vhost_dev, Michael Tokarev, 2023/03/08
- [PATCH 41/47] libvhost-user: check for NULL when allocating a virtqueue element, Michael Tokarev, 2023/03/08