cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-fw_cfg-prohibit-insertion-of-duplicate-fw_cfg-file-n.patch

5d360b
From 08eb83666fe11d81813270541bcb76bad8bd5902 Mon Sep 17 00:00:00 2001
5d360b
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
5d360b
Date: Wed, 13 Dec 2017 13:38:34 +0100
5d360b
Subject: [PATCH 03/41] fw_cfg: prohibit insertion of duplicate fw_cfg file
5d360b
 names
5d360b
MIME-Version: 1.0
5d360b
Content-Type: text/plain; charset=UTF-8
5d360b
Content-Transfer-Encoding: 8bit
5d360b
5d360b
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Message-id: <20171213133912.26176-4-marcandre.lureau@redhat.com>
5d360b
Patchwork-id: 78351
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 03/41] fw_cfg: prohibit insertion of duplicate fw_cfg file names
5d360b
Bugzilla: 1411490
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
From: "Gabriel L. Somlo" <somlo@cmu.edu>
5d360b
5d360b
Exit with an error (instead of simply logging a trace event)
5d360b
whenever the same fw_cfg file name is added multiple times via
5d360b
one of the fw_cfg_add_file[_callback]() host-side API calls.
5d360b
5d360b
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
5d360b
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
5d360b
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
5d360b
(cherry picked from commit 0eb973f91521c6bcb6399d25327711d083f6eb10)
5d360b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 hw/nvram/fw_cfg.c | 11 ++++++-----
5d360b
 trace-events      |  1 -
5d360b
 2 files changed, 6 insertions(+), 6 deletions(-)
5d360b
5d360b
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
5d360b
index 149e2fb..a33e861 100644
5d360b
--- a/hw/nvram/fw_cfg.c
5d360b
+++ b/hw/nvram/fw_cfg.c
5d360b
@@ -443,18 +443,19 @@ void fw_cfg_add_file_callback(FWCfgState *s,  const char *filename,
5d360b
     index = be32_to_cpu(s->files->count);
5d360b
     assert(index < FW_CFG_FILE_SLOTS);
5d360b
 
5d360b
-    fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index,
5d360b
-                                   callback, callback_opaque, data, len);
5d360b
-
5d360b
     pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name),
5d360b
             filename);
5d360b
     for (i = 0; i < index; i++) {
5d360b
         if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
5d360b
-            trace_fw_cfg_add_file_dupe(s, s->files->f[index].name);
5d360b
-            return;
5d360b
+            error_report("duplicate fw_cfg file name: %s",
5d360b
+                         s->files->f[index].name);
5d360b
+            exit(1);
5d360b
         }
5d360b
     }
5d360b
 
5d360b
+    fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index,
5d360b
+                                   callback, callback_opaque, data, len);
5d360b
+
5d360b
     s->files->f[index].size   = cpu_to_be32(len);
5d360b
     s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
5d360b
     trace_fw_cfg_add_file(s, index, s->files->f[index].name, len);
5d360b
diff --git a/trace-events b/trace-events
5d360b
index a987dfa..8c3ce0c 100644
5d360b
--- a/trace-events
5d360b
+++ b/trace-events
5d360b
@@ -178,7 +178,6 @@ ecc_diag_mem_readb(uint64_t addr, uint32_t ret) "Read diagnostic %"PRId64"= %02x
5d360b
 # hw/nvram/fw_cfg.c
5d360b
 fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d"
5d360b
 fw_cfg_read(void *s, uint8_t ret) "%p = %d"
5d360b
-fw_cfg_add_file_dupe(void *s, char *name) "%p %s"
5d360b
 fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd bytes)"
5d360b
 
5d360b
 # hw/block/hd-geometry.c
5d360b
-- 
5d360b
1.8.3.1
5d360b