thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
5d360b
From 0dcf104966d3fc385510a6a2d8b8dd81d731da61 Mon Sep 17 00:00:00 2001
5d360b
From: Max Reitz <mreitz@redhat.com>
5d360b
Date: Mon, 27 Nov 2017 18:09:28 +0100
5d360b
Subject: [PATCH 9/9] qcow2: Avoid making the L1 table too big
5d360b
5d360b
RH-Author: Max Reitz <mreitz@redhat.com>
5d360b
Message-id: <20171127180928.10364-3-mreitz@redhat.com>
5d360b
Patchwork-id: 77918
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH 2/2] qcow2: Avoid making the L1 table too big
5d360b
Bugzilla: 1459725
5d360b
RH-Acked-by: John Snow <jsnow@redhat.com>
5d360b
RH-Acked-by: Fam Zheng <famz@redhat.com>
5d360b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
5d360b
5d360b
We refuse to open images whose L1 table we deem "too big". Consequently,
5d360b
we should not produce such images ourselves.
5d360b
5d360b
Cc: qemu-stable@nongnu.org
5d360b
Signed-off-by: Max Reitz <mreitz@redhat.com>
5d360b
Message-id: 20160615153630.2116-3-mreitz@redhat.com
5d360b
Reviewed-by: Eric Blake <eblake@redhat.com>
5d360b
[mreitz: Added QEMU_BUILD_BUG_ON()]
5d360b
Signed-off-by: Max Reitz <mreitz@redhat.com>
5d360b
(cherry picked from commit 84c26520d3c1c9ff4a10455748139463278816d5)
5d360b
Signed-off-by: Max Reitz <mreitz@redhat.com>
5d360b
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 block/qcow2-cluster.c | 3 ++-
5d360b
 1 file changed, 2 insertions(+), 1 deletion(-)
5d360b
5d360b
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
5d360b
index f7938f6..589b040 100644
5d360b
--- a/block/qcow2-cluster.c
5d360b
+++ b/block/qcow2-cluster.c
5d360b
@@ -55,7 +55,8 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
5d360b
         }
5d360b
     }
5d360b
 
5d360b
-    if (new_l1_size > INT_MAX / sizeof(uint64_t)) {
5d360b
+    QEMU_BUILD_BUG_ON(QCOW_MAX_L1_SIZE > INT_MAX);
5d360b
+    if (new_l1_size > QCOW_MAX_L1_SIZE / sizeof(uint64_t)) {
5d360b
         return -EFBIG;
5d360b
     }
5d360b
 
5d360b
-- 
5d360b
1.8.3.1
5d360b