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