[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 019/108] ssd0323: fix buffer overun on invalid stat
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 019/108] ssd0323: fix buffer overun on invalid state load |
Date: |
Wed, 6 Aug 2014 15:38:29 -0500 |
From: "Michael S. Tsirkin" <address@hidden>
CVE-2013-4538
s->cmd_len used as index in ssd0323_transfer() to store 32-bit field.
Possible this field might then be supplied by guest to overwrite a
return addr somewhere. Same for row/col fields, which are indicies into
framebuffer array.
To fix validate after load.
Additionally, validate that the row/col_start/end are within bounds;
otherwise the guest can provoke an overrun by either setting the _end
field so large that the row++ increments just walk off the end of the
array, or by setting the _start value to something bogus and then
letting the "we hit end of row" logic reset row to row_start.
For completeness, validate mode as well.
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
(cherry picked from commit ead7a57df37d2187813a121308213f41591bd811)
Signed-off-by: Michael Roth <address@hidden>
---
hw/display/ssd0323.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/hw/display/ssd0323.c b/hw/display/ssd0323.c
index 971152e..9727007 100644
--- a/hw/display/ssd0323.c
+++ b/hw/display/ssd0323.c
@@ -312,18 +312,42 @@ static int ssd0323_load(QEMUFile *f, void *opaque, int
version_id)
return -EINVAL;
s->cmd_len = qemu_get_be32(f);
+ if (s->cmd_len < 0 || s->cmd_len > ARRAY_SIZE(s->cmd_data)) {
+ return -EINVAL;
+ }
s->cmd = qemu_get_be32(f);
for (i = 0; i < 8; i++)
s->cmd_data[i] = qemu_get_be32(f);
s->row = qemu_get_be32(f);
+ if (s->row < 0 || s->row >= 80) {
+ return -EINVAL;
+ }
s->row_start = qemu_get_be32(f);
+ if (s->row_start < 0 || s->row_start >= 80) {
+ return -EINVAL;
+ }
s->row_end = qemu_get_be32(f);
+ if (s->row_end < 0 || s->row_end >= 80) {
+ return -EINVAL;
+ }
s->col = qemu_get_be32(f);
+ if (s->col < 0 || s->col >= 64) {
+ return -EINVAL;
+ }
s->col_start = qemu_get_be32(f);
+ if (s->col_start < 0 || s->col_start >= 64) {
+ return -EINVAL;
+ }
s->col_end = qemu_get_be32(f);
+ if (s->col_end < 0 || s->col_end >= 64) {
+ return -EINVAL;
+ }
s->redraw = qemu_get_be32(f);
s->remap = qemu_get_be32(f);
s->mode = qemu_get_be32(f);
+ if (s->mode != SSD0323_CMD && s->mode != SSD0323_DATA) {
+ return -EINVAL;
+ }
qemu_get_buffer(f, s->framebuffer, sizeof(s->framebuffer));
ss->cs = qemu_get_be32(f);
--
1.9.1
- [Qemu-stable] [PATCH 007/108] virtio-net: out-of-bounds buffer write on invalid state load, (continued)
- [Qemu-stable] [PATCH 007/108] virtio-net: out-of-bounds buffer write on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 005/108] vmstate: add VMSTATE_VALIDATE, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 011/108] hw/pci/pcie_aer.c: fix buffer overruns on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 010/108] hpet: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 008/108] virtio-net: out-of-bounds buffer write on load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 013/108] vmstate: fix buffer overflow in target-arm/machine.c, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 012/108] pl022: fix buffer overun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 015/108] virtio: validate num_sg when mapping, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 017/108] pxa2xx: avoid buffer overrun on incoming migration, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 020/108] tsc210x: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 019/108] ssd0323: fix buffer overun on invalid state load,
Michael Roth <=
- [Qemu-stable] [PATCH 021/108] zaurus: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 024/108] target-arm: A64: fix unallocated test of scalar SQXTUN, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 018/108] ssi-sd: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 025/108] megasas: Implement LD_LIST_QUERY, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 022/108] usb: sanity check setup_index+setup_len in post_load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 023/108] virtio-scsi: fix buffer overrun on invalid state load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 014/108] virtio: avoid buffer overrun on incoming migration, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 029/108] po/Makefile: fix $SRC_PATH reference, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 027/108] block: Prevent coroutine stack overflow when recursing in bdrv_open_backing_file., Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 028/108] s390x: empty function stubs in preparation for __KVM_HAVE_GUEST_DEBUG, Michael Roth, 2014/08/06