Skip to contentSkip to conversation

vmdk: Fix integer overflow in offset calculation

PATCH Applied Fam Zheng 2 participants 2 messages Sep 23, 2014 – Oct 2, 2014 Block layer

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v5 1/1 vmdk: Fix integer overflow in offset calculation

This fixes the bug introduced by commit c6ac36e (vmdk: Optimize cluster allocation).

$ ~/build/master/qemu-io /stor/vm/arch.vmdk -c 'write 2G 1k'
write failed: Invalid argument

---
v5: Fix group file and output reference. (Max)
v4: Fix typo in file header: 1014 -> 2014.
v3: A new case 105 instead of embedding in 005. (Max)

---
 block/vmdk.c               |  2 +-
 tests/qemu-iotests/105     | 70 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/105.out | 21 ++++++++++++++
 tests/qemu-iotests/group   |  1 +
 4 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100755 tests/qemu-iotests/105
 create mode 100644 tests/qemu-iotests/105.out
block/vmdk.c +1 -1
index afdea1a..4ae6c75 100644
@@ -1113,7 +1113,7 @@ static int get_cluster_offset(BlockDriverState *bs,
     uint32_t min_count, *l2_table;
     bool zeroed = false;
     int64_t ret;
-    int32_t cluster_sector;
+    int64_t cluster_sector;
 
     if (m_data) {
         m_data->valid = 0;
tests/qemu-iotests/105 new file +70 -0

70 lines not on this page · raw message

tests/qemu-iotests/105.out new file +21 -0
new file mode 100644
index 0000000..13ffcb5
@@ -0,0 +1,21 @@
+QA output created by 105
+
+creating large image
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=17592186044416
+
+small read
+read 4096/4096 bytes at offset 1024
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+small write
+wrote 4096/4096 bytes at offset 8192
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+small read at high offset
+read 4096/4096 bytes at offset 15393162788864
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+small write at high offset
+wrote 4096/4096 bytes at offset 15393162788864
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+*** done
tests/qemu-iotests/group +1 -0
index 622685e..b230996 100644
@@ -105,3 +105,4 @@
 101 rw auto quick
 103 rw auto quick
 104 rw auto
+105 rw auto quick
Signature · 1 line
1.9.3
#1 lore raw
Quoted 14 lines · Fam Zheng

This fixes the bug introduced by commit c6ac36e (vmdk: Optimize cluster allocation).

$ ~/build/master/qemu-io /stor/vm/arch.vmdk -c 'write 2G 1k'
write failed: Invalid argument

---
v5: Fix group file and output reference. (Max)
v4: Fix typo in file header: 1014 -> 2014.
v3: A new case 105 instead of embedding in 005. (Max)

Quoted 8 lines
---
 block/vmdk.c               |  2 +-
 tests/qemu-iotests/105     | 70 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/105.out | 21 ++++++++++++++
 tests/qemu-iotests/group   |  1 +
 4 files changed, 93 insertions(+), 1 deletion(-)
 create mode 100755 tests/qemu-iotests/105
 create mode 100644 tests/qemu-iotests/105.out

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan