thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
9ae3a8
From 08eb83666fe11d81813270541bcb76bad8bd5902 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:34 +0100
9ae3a8
Subject: [PATCH 03/41] fw_cfg: prohibit insertion of duplicate fw_cfg file
9ae3a8
 names
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-4-marcandre.lureau@redhat.com>
9ae3a8
Patchwork-id: 78351
9ae3a8
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 03/41] fw_cfg: prohibit insertion of duplicate fw_cfg file names
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
Exit with an error (instead of simply logging a trace event)
9ae3a8
whenever the same fw_cfg file name is added multiple times via
9ae3a8
one of the fw_cfg_add_file[_callback]() host-side API calls.
9ae3a8
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 0eb973f91521c6bcb6399d25327711d083f6eb10)
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 | 11 ++++++-----
9ae3a8
 trace-events      |  1 -
9ae3a8
 2 files changed, 6 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
9ae3a8
index 149e2fb..a33e861 100644
9ae3a8
--- a/hw/nvram/fw_cfg.c
9ae3a8
+++ b/hw/nvram/fw_cfg.c
9ae3a8
@@ -443,18 +443,19 @@ void fw_cfg_add_file_callback(FWCfgState *s,  const char *filename,
9ae3a8
     index = be32_to_cpu(s->files->count);
9ae3a8
     assert(index < FW_CFG_FILE_SLOTS);
9ae3a8
 
9ae3a8
-    fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index,
9ae3a8
-                                   callback, callback_opaque, data, len);
9ae3a8
-
9ae3a8
     pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name),
9ae3a8
             filename);
9ae3a8
     for (i = 0; i < index; i++) {
9ae3a8
         if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
9ae3a8
-            trace_fw_cfg_add_file_dupe(s, s->files->f[index].name);
9ae3a8
-            return;
9ae3a8
+            error_report("duplicate fw_cfg file name: %s",
9ae3a8
+                         s->files->f[index].name);
9ae3a8
+            exit(1);
9ae3a8
         }
9ae3a8
     }
9ae3a8
 
9ae3a8
+    fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index,
9ae3a8
+                                   callback, callback_opaque, data, len);
9ae3a8
+
9ae3a8
     s->files->f[index].size   = cpu_to_be32(len);
9ae3a8
     s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
9ae3a8
     trace_fw_cfg_add_file(s, index, s->files->f[index].name, len);
9ae3a8
diff --git a/trace-events b/trace-events
9ae3a8
index a987dfa..8c3ce0c 100644
9ae3a8
--- a/trace-events
9ae3a8
+++ b/trace-events
9ae3a8
@@ -178,7 +178,6 @@ ecc_diag_mem_readb(uint64_t addr, uint32_t ret) "Read diagnostic %"PRId64"= %02x
9ae3a8
 # hw/nvram/fw_cfg.c
9ae3a8
 fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
9ae3a8
 fw_cfg_read(void *s, uint8_t ret) "%p = %d"
9ae3a8
-fw_cfg_add_file_dupe(void *s, char *name) "%p %s"
9ae3a8
 fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd bytes)"
9ae3a8
 
9ae3a8
 # hw/block/hd-geometry.c
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8