[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 60/81] hw/acpi/erst.c: Fix memory handling issues
|
From: |
Michael S. Tsirkin |
|
Subject: |
[PULL v3 60/81] hw/acpi/erst.c: Fix memory handling issues |
|
Date: |
Sat, 5 Nov 2022 13:18:20 -0400 |
From: "Christian A. Ehrhardt" <lk@c--e.de>
- Fix memset argument order: The second argument is
the value, the length goes last.
- Fix an integer overflow reported by Alexander Bulekov.
Both issues allow the guest to overrun the host buffer
allocated for the ERST memory device.
Cc: Eric DeVolder <eric.devolder@oracle.com
Cc: Alexander Bulekov <alxndr@bu.edu>
Cc: qemu-stable@nongnu.org
Fixes: f7e26ffa590 ("ACPI ERST: support for ACPI ERST feature")
Tested-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Christian A. Ehrhardt <lk@c--e.de>
Message-Id: <20221024154233.1043347-1-lk@c--e.de>
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1268
Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Eric DeVolder <eric.devolder@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/acpi/erst.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c
index df856b2669..aefcc03ad6 100644
--- a/hw/acpi/erst.c
+++ b/hw/acpi/erst.c
@@ -635,7 +635,7 @@ static unsigned read_erst_record(ERSTDeviceState *s)
if (record_length < UEFI_CPER_RECORD_MIN_SIZE) {
rc = STATUS_FAILED;
}
- if ((s->record_offset + record_length) > exchange_length) {
+ if (record_length > exchange_length - s->record_offset) {
rc = STATUS_FAILED;
}
/* If all is ok, copy the record to the exchange buffer */
@@ -684,7 +684,7 @@ static unsigned write_erst_record(ERSTDeviceState *s)
if (record_length < UEFI_CPER_RECORD_MIN_SIZE) {
return STATUS_FAILED;
}
- if ((s->record_offset + record_length) > exchange_length) {
+ if (record_length > exchange_length - s->record_offset) {
return STATUS_FAILED;
}
@@ -716,7 +716,7 @@ static unsigned write_erst_record(ERSTDeviceState *s)
if (nvram) {
/* Write the record into the slot */
memcpy(nvram, exchange, record_length);
- memset(nvram + record_length, exchange_length - record_length, 0xFF);
+ memset(nvram + record_length, 0xFF, exchange_length - record_length);
/* If a new record, increment the record_count */
if (!record_found) {
uint32_t record_count;
--
MST
- [PULL v3 59/81] tests: acpi: update expected blobs, (continued)
- [PULL v3 59/81] tests: acpi: update expected blobs, Michael S. Tsirkin, 2022/11/05
- [PULL v3 36/81] virtio-pci: support queue reset, Michael S. Tsirkin, 2022/11/05
- [PULL v3 43/81] virtio-net: support queue reset, Michael S. Tsirkin, 2022/11/05
- [PULL v3 47/81] virtio-rng-pci: Allow setting nvectors, so we can use MSI-X, Michael S. Tsirkin, 2022/11/05
- [PULL v3 48/81] vhost-user: Fix out of order vring host notification handling, Michael S. Tsirkin, 2022/11/05
- [PULL v3 68/81] tests: acpi: add and whitelist *.hmat-noinitiator expected blobs, Michael S. Tsirkin, 2022/11/05
- [PULL v3 44/81] virtio-net: support queue_enable, Michael S. Tsirkin, 2022/11/05
- [PULL v3 53/81] tests: acpi: whitelist DSDT before generating ICH9_SMB AML automatically, Michael S. Tsirkin, 2022/11/05
- [PULL v3 61/81] MAINTAINERS: Add qapi/virtio.json to section "virtio", Michael S. Tsirkin, 2022/11/05
- [PULL v3 64/81] hw/i386/acpi-build: Remove unused struct, Michael S. Tsirkin, 2022/11/05
- [PULL v3 60/81] hw/acpi/erst.c: Fix memory handling issues,
Michael S. Tsirkin <=
- [PULL v3 65/81] hw/i386/acpi-build: Resolve redundant attribute, Michael S. Tsirkin, 2022/11/05
- [PULL v3 39/81] vhost: expose vhost_virtqueue_stop(), Michael S. Tsirkin, 2022/11/05
- [PULL v3 35/81] virtio: core: vq reset feature negotation support, Michael S. Tsirkin, 2022/11/05
- [PULL v3 37/81] virtio-pci: support queue enable, Michael S. Tsirkin, 2022/11/05
- [PULL v3 40/81] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset(), Michael S. Tsirkin, 2022/11/05
- [PULL v3 46/81] virtio-net: enable vq reset feature, Michael S. Tsirkin, 2022/11/05
- [PULL v3 45/81] vhost: vhost-kernel: enable vq reset feature, Michael S. Tsirkin, 2022/11/05
- [PULL v3 54/81] acpi: add get_dev_aml_func() helper, Michael S. Tsirkin, 2022/11/05
- [PULL v3 52/81] tests: acpi: update expected DSDT after ISA bridge is moved directly under PCI host bridge, Michael S. Tsirkin, 2022/11/05
- [PULL v3 63/81] hw/i386/pc.c: CXL Fixed Memory Window should not reserve e820 in bios, Michael S. Tsirkin, 2022/11/05