|
|
9ae3a8 |
From 8fb3ac70845fbe261407e7782d3e6233e368da8f Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 13 Dec 2017 13:38:37 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 06/41] fw_cfg: avoid calculating invalid current entry pointer
|
|
|
9ae3a8 |
MIME-Version: 1.0
|
|
|
9ae3a8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9ae3a8 |
Content-Transfer-Encoding: 8bit
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20171213133912.26176-7-marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 78355
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 06/41] fw_cfg: avoid calculating invalid current entry pointer
|
|
|
9ae3a8 |
Bugzilla: 1411490
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: "Gabriel L. Somlo" <somlo@cmu.edu>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
When calculating a pointer to the currently selected fw_cfg item, the
|
|
|
9ae3a8 |
following is used:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
When s->cur_entry is FW_CFG_INVALID, we are calculating the address of
|
|
|
9ae3a8 |
a non-existent element in s->entries[arch][...], which is undefined.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This patch ensures the resulting entry pointer is set to NULL whenever
|
|
|
9ae3a8 |
s->cur_entry is FW_CFG_INVALID.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
|
|
|
9ae3a8 |
Message-id: 1446733972-1602-5-git-send-email-somlo@cmu.edu
|
|
|
9ae3a8 |
Cc: Marc Marí <markmb@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
|
|
|
9ae3a8 |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
(cherry picked from commit 66f8fd9dda312191b78d2a2ba2848bcee76127a2)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RHEL: fix minor conflicts due to previous partial backport in commit
|
|
|
9ae3a8 |
ba24567fd90702ea40ff320a79bc921b38510f22.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/nvram/fw_cfg.c | 3 ++-
|
|
|
9ae3a8 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
index 85e950c..1317df7 100644
|
|
|
9ae3a8 |
--- a/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
+++ b/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
@@ -301,7 +301,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
|
|
|
9ae3a8 |
- e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
|
|
|
9ae3a8 |
+ e = (s->cur_entry == FW_CFG_INVALID) ? NULL :
|
|
|
9ae3a8 |
+ &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (dma.control & FW_CFG_DMA_CTL_READ) {
|
|
|
9ae3a8 |
read = 1;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|