[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 31/47] hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELE
From: |
Michael Roth |
Subject: |
[PATCH 31/47] hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands |
Date: |
Tue, 14 Dec 2021 18:01:09 -0600 |
From: Mauro Matteo Cascella <mcascell@redhat.com>
This avoids an off-by-one read of 'mode_sense_valid' buffer in
hw/scsi/scsi-disk.c:mode_sense_page().
Fixes: CVE-2021-3930
Cc: qemu-stable@nongnu.org
Reported-by: Alexander Bulekov <alxndr@bu.edu>
Fixes: a8f4bbe2900 ("scsi-disk: store valid mode pages in a table")
Fixes: #546
Reported-by: Qiuhao Li <Qiuhao.Li@outlook.com>
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit b3af7fdf9cc537f8f0dd3e2423d83f5c99a457e8)
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
hw/scsi/scsi-disk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index e8a547dbb7..d4914178ea 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -1087,6 +1087,7 @@ static int mode_sense_page(SCSIDiskState *s, int page,
uint8_t **p_outbuf,
uint8_t *p = *p_outbuf + 2;
int length;
+ assert(page < ARRAY_SIZE(mode_sense_valid));
if ((mode_sense_valid[page] & (1 << s->qdev.type)) == 0) {
return -1;
}
@@ -1428,6 +1429,11 @@ static int scsi_disk_check_mode_select(SCSIDiskState *s,
int page,
return -1;
}
+ /* MODE_PAGE_ALLS is only valid for MODE SENSE commands */
+ if (page == MODE_PAGE_ALLS) {
+ return -1;
+ }
+
p = mode_current;
memset(mode_current, 0, inlen + 2);
len = mode_sense_page(s, page, &p, 0);
--
2.25.1
- [PATCH 22/47] block: introduce max_hw_iov for use in scsi-generic, (continued)
- [PATCH 22/47] block: introduce max_hw_iov for use in scsi-generic, Michael Roth, 2021/12/14
- [PATCH 23/47] pci: fix PCI resource reserve capability on BE, Michael Roth, 2021/12/14
- [PATCH 24/47] tests/acpi/bios-tables-test: add and allow changes to a new q35 DSDT table blob, Michael Roth, 2021/12/14
- [PATCH 25/47] tests/acpi/pcihp: add unit tests for hotplug on multifunction bridges for q35, Michael Roth, 2021/12/14
- [PATCH 26/47] tests/acpi/bios-tables-test: update DSDT blob for multifunction bridge test, Michael Roth, 2021/12/14
- [PATCH 27/47] block/file-posix: Fix return value translation for AIO discards, Michael Roth, 2021/12/14
- [PATCH 28/47] Partially revert "build: -no-pie is no functional linker flag", Michael Roth, 2021/12/14
- [PATCH 29/47] target-i386: mmu: use pg_mode instead of HF_LMA_MASK, Michael Roth, 2021/12/14
- [PATCH 30/47] target-i386: mmu: fix handling of noncanonical virtual addresses, Michael Roth, 2021/12/14
- [PATCH 02/47] target/arm: Don't skip M-profile reset entirely in user mode, Michael Roth, 2021/12/14
- [PATCH 31/47] hw/scsi/scsi-disk: MODE_PAGE_ALLS not allowed in MODE SELECT commands,
Michael Roth <=
- [PATCH 32/47] hw: m68k: virt: Add compat machine for 6.1, Michael Roth, 2021/12/14
- [PATCH 33/47] rcu: Introduce force_rcu notifier, Michael Roth, 2021/12/14
- [PATCH 34/47] accel/tcg: Register a force_rcu notifier, Michael Roth, 2021/12/14
- [PATCH 35/47] pcie: rename 'native-hotplug' to 'x-native-hotplug', Michael Roth, 2021/12/14
- [PATCH 36/47] virtio: use virtio accessor to access packed descriptor flags, Michael Roth, 2021/12/14
- [PATCH 37/47] virtio: use virtio accessor to access packed event, Michael Roth, 2021/12/14
- [PATCH 38/47] vfio: Fix memory leak of hostwin, Michael Roth, 2021/12/14
- [PATCH 39/47] nbd/server: Don't complain on certain client disconnects, Michael Roth, 2021/12/14
- [PATCH 40/47] hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947), Michael Roth, 2021/12/14
- [PATCH 03/47] virtio-net: fix use after unmap/free for sg, Michael Roth, 2021/12/14