thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-vmdk-Fix-integer-overflow-in-offset-calculation.patch

9ae3a8
From ed2a49b247a70b0e841296f5a63285390b842e06 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <ed2a49b247a70b0e841296f5a63285390b842e06.1418766606.git.jen@redhat.com>
9ae3a8
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Thu, 4 Dec 2014 00:05:24 -0600
9ae3a8
Subject: [CHANGE 30/31] vmdk: Fix integer overflow in offset calculation
9ae3a8
To: rhvirt-patches@redhat.com,
9ae3a8
    jen@redhat.com
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1417651524-18041-31-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 62703
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 30/30] vmdk: Fix integer overflow in offset calculation
9ae3a8
Bugzilla: 1002493
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
This fixes the bug introduced by commit c6ac36e (vmdk: Optimize cluster
9ae3a8
allocation).
9ae3a8
9ae3a8
$ ~/build/master/qemu-io /stor/vm/arch.vmdk -c 'write 2G 1k'
9ae3a8
write failed: Invalid argument
9ae3a8
9ae3a8
Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
9ae3a8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: 1411437381-11234-1-git-send-email-famz@redhat.com
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit d1319b077a4bd980ca1b8a167b02b519330dd26b)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	tests/qemu-iotests/group
9ae3a8
9ae3a8
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
9ae3a8
---
9ae3a8
 block/vmdk.c               |  2 +-
9ae3a8
 tests/qemu-iotests/105     | 70 ++++++++++++++++++++++++++++++++++++++++++++++
9ae3a8
 tests/qemu-iotests/105.out | 21 ++++++++++++++
9ae3a8
 tests/qemu-iotests/group   |  1 +
9ae3a8
 4 files changed, 93 insertions(+), 1 deletion(-)
9ae3a8
 create mode 100755 tests/qemu-iotests/105
9ae3a8
 create mode 100644 tests/qemu-iotests/105.out
9ae3a8
9ae3a8
diff --git a/block/vmdk.c b/block/vmdk.c
9ae3a8
index 0593a1a..cfcaa84 100644
9ae3a8
--- a/block/vmdk.c
9ae3a8
+++ b/block/vmdk.c
9ae3a8
@@ -1116,7 +1116,7 @@ static int get_cluster_offset(BlockDriverState *bs,
9ae3a8
     uint32_t min_count, *l2_table;
9ae3a8
     bool zeroed = false;
9ae3a8
     int64_t ret;
9ae3a8
-    int32_t cluster_sector;
9ae3a8
+    int64_t cluster_sector;
9ae3a8
 
9ae3a8
     if (m_data) {
9ae3a8
         m_data->valid = 0;
9ae3a8
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
9ae3a8
new file mode 100755
9ae3a8
index 0000000..9bae49e
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qemu-iotests/105
9ae3a8
@@ -0,0 +1,70 @@
9ae3a8
+#!/bin/bash
9ae3a8
+#
9ae3a8
+# Create, read, write big image
9ae3a8
+#
9ae3a8
+# Copyright (C) 2014 Red Hat, Inc.
9ae3a8
+#
9ae3a8
+# This program is free software; you can redistribute it and/or modify
9ae3a8
+# it under the terms of the GNU General Public License as published by
9ae3a8
+# the Free Software Foundation; either version 2 of the License, or
9ae3a8
+# (at your option) any later version.
9ae3a8
+#
9ae3a8
+# This program is distributed in the hope that it will be useful,
9ae3a8
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
9ae3a8
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ae3a8
+# GNU General Public License for more details.
9ae3a8
+#
9ae3a8
+# You should have received a copy of the GNU General Public License
9ae3a8
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
9ae3a8
+#
9ae3a8
+
9ae3a8
+# creator
9ae3a8
+owner=famz@redhat.com
9ae3a8
+
9ae3a8
+seq=`basename $0`
9ae3a8
+echo "QA output created by $seq"
9ae3a8
+
9ae3a8
+here=`pwd`
9ae3a8
+tmp=/tmp/$$
9ae3a8
+status=1	# failure is the default!
9ae3a8
+
9ae3a8
+_cleanup()
9ae3a8
+{
9ae3a8
+	_cleanup_test_img
9ae3a8
+}
9ae3a8
+trap "_cleanup; exit \$status" 0 1 2 3 15
9ae3a8
+
9ae3a8
+# get standard environment, filters and checks
9ae3a8
+. ./common.rc
9ae3a8
+. ./common.filter
9ae3a8
+
9ae3a8
+_supported_fmt qcow2 vmdk vhdx qed
9ae3a8
+_supported_proto generic
9ae3a8
+_supported_os Linux
9ae3a8
+_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
9ae3a8
+                     "subformat=twoGbMaxExtentSparse"
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "creating large image"
9ae3a8
+_make_test_img 16T
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "small read"
9ae3a8
+$QEMU_IO -c "read 1024 4096" "$TEST_IMG" | _filter_qemu_io
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "small write"
9ae3a8
+$QEMU_IO -c "write 8192 4096" "$TEST_IMG" | _filter_qemu_io
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "small read at high offset"
9ae3a8
+$QEMU_IO -c "read 14T 4096" "$TEST_IMG" | _filter_qemu_io
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "small write at high offset"
9ae3a8
+$QEMU_IO -c "write 14T 4096" "$TEST_IMG" | _filter_qemu_io
9ae3a8
+
9ae3a8
+# success, all done
9ae3a8
+echo "*** done"
9ae3a8
+rm -f $seq.full
9ae3a8
+status=0
9ae3a8
diff --git a/tests/qemu-iotests/105.out b/tests/qemu-iotests/105.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..13ffcb5
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qemu-iotests/105.out
9ae3a8
@@ -0,0 +1,21 @@
9ae3a8
+QA output created by 105
9ae3a8
+
9ae3a8
+creating large image
9ae3a8
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=17592186044416
9ae3a8
+
9ae3a8
+small read
9ae3a8
+read 4096/4096 bytes at offset 1024
9ae3a8
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+
9ae3a8
+small write
9ae3a8
+wrote 4096/4096 bytes at offset 8192
9ae3a8
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+
9ae3a8
+small read at high offset
9ae3a8
+read 4096/4096 bytes at offset 15393162788864
9ae3a8
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+
9ae3a8
+small write at high offset
9ae3a8
+wrote 4096/4096 bytes at offset 15393162788864
9ae3a8
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+*** done
9ae3a8
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
9ae3a8
index 572438e..cd8384a 100644
9ae3a8
--- a/tests/qemu-iotests/group
9ae3a8
+++ b/tests/qemu-iotests/group
9ae3a8
@@ -85,3 +85,4 @@
9ae3a8
 087 rw auto quick
9ae3a8
 088 rw auto
9ae3a8
 092 rw auto quick
9ae3a8
+105 rw auto quick
9ae3a8
-- 
9ae3a8
2.1.0
9ae3a8