Blame SOURCES/kvm-device_tree-Fix-integer-overflowing-in-load_device_t.patch

383d26
From e530c18fd567718e38683d73354fb56d4d3eb6aa Mon Sep 17 00:00:00 2001
383d26
From: Sergio Lopez Pascual <slp@redhat.com>
383d26
Date: Mon, 15 Apr 2019 10:50:01 +0200
383d26
Subject: [PATCH 161/163] device_tree: Fix integer overflowing in
383d26
 load_device_tree()
383d26
MIME-Version: 1.0
383d26
Content-Type: text/plain; charset=UTF-8
383d26
Content-Transfer-Encoding: 8bit
383d26
383d26
RH-Author: Sergio Lopez Pascual <slp@redhat.com>
383d26
Message-id: <20190415105001.42933-2-slp@redhat.com>
383d26
Patchwork-id: 85665
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 1/1] device_tree: Fix integer overflowing in load_device_tree()
383d26
Bugzilla: 1693115
383d26
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
RH-Acked-by: John Snow <jsnow@redhat.com>
383d26
383d26
From: Markus Armbruster <armbru@redhat.com>
383d26
383d26
If the value of get_image_size() exceeds INT_MAX / 2 - 10000, the
383d26
computation of @dt_size overflows to a negative number, which then
383d26
gets converted to a very large size_t for g_malloc0() and
383d26
load_image_size().  In the (fortunately improbable) case g_malloc0()
383d26
succeeds and load_image_size() survives, we'd assign the negative
383d26
number to *sizep.  What that would do to the callers I can't say, but
383d26
it's unlikely to be good.
383d26
383d26
Fix by rejecting images whose size would overflow.
383d26
383d26
Reported-by: Kurtis Miller <kurtis.miller@nccgroup.com>
383d26
Signed-off-by: Markus Armbruster <armbru@redhat.com>
383d26
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
383d26
Message-Id: <20190409174018.25798-1-armbru@redhat.com>
383d26
(cherry picked from commit 065e6298a75164b4347682b63381dbe752c2b156)
383d26
Signed-off-by: Sergio Lopez <slp@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 device_tree.c | 4 ++++
383d26
 1 file changed, 4 insertions(+)
383d26
383d26
diff --git a/device_tree.c b/device_tree.c
383d26
index 19458b3..2457f58 100644
383d26
--- a/device_tree.c
383d26
+++ b/device_tree.c
383d26
@@ -84,6 +84,10 @@ void *load_device_tree(const char *filename_path, int *sizep)
383d26
                      filename_path);
383d26
         goto fail;
383d26
     }
383d26
+    if (dt_size > INT_MAX / 2 - 10000) {
383d26
+        error_report("Device tree file '%s' is too large", filename_path);
383d26
+        goto fail;
383d26
+    }
383d26
 
383d26
     /* Expand to 2x size to give enough room for manipulation.  */
383d26
     dt_size += 10000;
383d26
-- 
383d26
1.8.3.1
383d26