|
|
7711c0 |
From e530c18fd567718e38683d73354fb56d4d3eb6aa Mon Sep 17 00:00:00 2001
|
|
|
550fc5 |
From: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
7711c0 |
Date: Mon, 15 Apr 2019 10:50:01 +0200
|
|
|
7711c0 |
Subject: [PATCH 161/163] device_tree: Fix integer overflowing in
|
|
|
7711c0 |
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>
|
|
|
7711c0 |
Message-id: <20190415105001.42933-2-slp@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85665
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 1/1] device_tree: Fix integer overflowing in load_device_tree()
|
|
|
7711c0 |
Bugzilla: 1693115
|
|
|
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 |
|