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