From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: "Michael Roth" <mdroth@linux.vnet.ibm.com>,
"Gabriel L. Somlo" <somlo@cmu.edu>,
qemu-stable@nongnu.org, "Marc Marí" <markmb@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 22/35] fw_cfg: avoid calculating invalid current entry pointer
Date: Mon, 21 Mar 2016 12:28:20 -0500 [thread overview]
Message-ID: <1458581313-19045-23-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1458581313-19045-1-git-send-email-mdroth@linux.vnet.ibm.com>
From: "Gabriel L. Somlo" <somlo@cmu.edu>
When calculating a pointer to the currently selected fw_cfg item, the
following is used:
FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
When s->cur_entry is FW_CFG_INVALID, we are calculating the address of
a non-existent element in s->entries[arch][...], which is undefined.
This patch ensures the resulting entry pointer is set to NULL whenever
s->cur_entry is FW_CFG_INVALID.
Reported-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Message-id: 1446733972-1602-5-git-send-email-somlo@cmu.edu
Cc: Marc Marí <markmb@redhat.com>
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 66f8fd9dda312191b78d2a2ba2848bcee76127a2)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
hw/nvram/fw_cfg.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 73b0a81..117809b 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -270,7 +270,8 @@ static int fw_cfg_select(FWCfgState *s, uint16_t key)
static uint8_t fw_cfg_read(FWCfgState *s)
{
int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
- FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
+ FWCfgEntry *e = (s->cur_entry == FW_CFG_INVALID) ? NULL :
+ &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
uint8_t ret;
if (s->cur_entry == FW_CFG_INVALID || !e->data || s->cur_offset >= e->len)
@@ -338,7 +339,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s)
}
arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
- e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
+ e = (s->cur_entry == FW_CFG_INVALID) ? NULL :
+ &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
if (dma.control & FW_CFG_DMA_CTL_READ) {
read = 1;
--
1.9.1
next prev parent reply other threads:[~2016-03-21 17:29 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-21 17:27 [Qemu-devel] [PATCH 00/35] Patch Round-up for stable 2.5.1, freeze on 2016-03-25 Michael Roth
2016-03-21 17:27 ` [Qemu-devel] [PATCH 01/35] ehci: make idt processing more robust Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 02/35] net: vmxnet3: avoid memory leakage in activate_device Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 03/35] target-ppc: kvm: fix floating point registers sync on little-endian hosts Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 04/35] configure: Fix shell syntax to placate OpenBSD's pdksh Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 05/35] xen/blkif: Avoid double access to src->nr_segments Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 06/35] xenfb: avoid reading twice the same fields from the shared page Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 07/35] virtio-9p: use accessor to get thread_pool Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 08/35] scsi: initialise info object with appropriate size Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 09/35] ivshmem: no need for opaque argument Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 10/35] ivshmem: remove redundant assignment, fix crash with msi=off Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 11/35] net: rocker: fix an incorrect array bounds check Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 12/35] block: Add blk_dev_has_tray() Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 13/35] blockdev: Fix 'change' for slot devices Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 14/35] net/dump: fix nfds->filename leak Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 15/35] net/filter: fix nf->netdev_id leak Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 16/35] net: ne2000: check ring buffer control registers Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 17/35] net: set endianness on all backend devices Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 18/35] ehci: update irq on reset Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 19/35] block/raw-posix: avoid bogus fixup for cylinders on DASD disks Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 20/35] s390x/ioinst: set type and len for SEI response Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 21/35] s390x/css: fix control flags during csch Michael Roth
2016-03-21 17:28 ` Michael Roth [this message]
2016-03-21 17:28 ` [Qemu-devel] [PATCH 23/35] cpus: use broadcast on qemu_pause_cond Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 24/35] qmp: Fix reference-counting of qnull on empty output visit Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 25/35] block: set device_list.tqe_prev to NULL on BDS removal Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 26/35] block: qemu-iotests - add test for snapshot, commit, snapshot bug Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 27/35] e1000: eliminate infinite loops on out-of-bounds transfer start Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 28/35] spapr: skip configuration section during migration of older machines Michael Roth
2016-03-22 7:49 ` [Qemu-devel] [Qemu-stable] " Greg Kurz
2016-03-22 22:35 ` Michael Roth
2016-03-23 7:59 ` Greg Kurz
2016-03-21 17:28 ` [Qemu-devel] [PATCH 29/35] hw/virtio: fix double use of a virtio flag Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 30/35] hw/virtio: group virtio flags into an enum Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 31/35] fw_cfg: unbreak migration compatibility for 2.4 and earlier machines Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 32/35] vhost-user: don't merge regions with different fds Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 33/35] target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 34/35] quorum: Fix crash in quorum_aio_cb() Michael Roth
2016-03-21 17:28 ` [Qemu-devel] [PATCH 35/35] vl.c: Fix regression in machine error message Michael Roth
2016-03-21 19:32 ` [Qemu-devel] [Qemu-stable] [PATCH 00/35] Patch Round-up for stable 2.5.1, freeze on 2016-03-25 Cole Robinson
2016-03-22 22:47 ` Michael Roth
2016-03-22 10:00 ` Peter Lieven
2016-03-22 22:45 ` Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458581313-19045-23-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=kraxel@redhat.com \
--cc=markmb@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=somlo@cmu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).