[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/12] qcow2: Add two more unalignment checks
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 03/12] qcow2: Add two more unalignment checks |
Date: |
Fri, 23 Jan 2015 19:20:09 +0100 |
From: Max Reitz <address@hidden>
This adds checks for unaligned L2 table offsets and unaligned data
cluster offsets (actually the preallocated offsets for zero clusters) to
the zero cluster expansion function.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cluster.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 1fea514..183177d 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -1651,6 +1651,14 @@ static int expand_zero_clusters_in_l1(BlockDriverState
*bs, uint64_t *l1_table,
continue;
}
+ if (offset_into_cluster(s, l2_offset)) {
+ qcow2_signal_corruption(bs, true, -1, -1, "L2 table offset %#"
+ PRIx64 " unaligned (L1 index: %#x)",
+ l2_offset, i);
+ ret = -EIO;
+ goto fail;
+ }
+
if (is_active_l1) {
/* get active L2 tables from cache */
ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
@@ -1709,6 +1717,19 @@ static int expand_zero_clusters_in_l1(BlockDriverState
*bs, uint64_t *l1_table,
}
}
+ if (offset_into_cluster(s, offset)) {
+ qcow2_signal_corruption(bs, true, -1, -1, "Data cluster offset
"
+ "%#" PRIx64 " unaligned (L2 offset: %#"
+ PRIx64 ", L2 index: %#x)", offset,
+ l2_offset, j);
+ if (!preallocated) {
+ qcow2_free_clusters(bs, offset, s->cluster_size,
+ QCOW2_DISCARD_ALWAYS);
+ }
+ ret = -EIO;
+ goto fail;
+ }
+
ret = qcow2_pre_write_overlap_check(bs, 0, offset,
s->cluster_size);
if (ret < 0) {
if (!preallocated) {
--
1.8.3.1
- [Qemu-devel] [PULL 00/12] Block patches, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 01/12] virtio-blk: Pass req to virtio_blk_handle_scsi_req, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 04/12] iotests: Add tests for more corruption cases, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 05/12] block: vmdk - make ret variable usage clear, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 02/12] virtio-blk: Use blk_aio_ioctl, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 06/12] block: vmdk - move string allocations from stack to the heap, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 03/12] qcow2: Add two more unalignment checks,
Kevin Wolf <=
- [Qemu-devel] [PULL 08/12] block: remove unused variable in bdrv_commit, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 11/12] block: vhdx - force FileOffsetMB field to '0' for certain block states, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 12/12] iotests: Lower 064's memory usage, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 09/12] block: mirror - change string allocation to 2-bytes, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 10/12] block: update string sizes for filename, backing_file, exact_filename, Kevin Wolf, 2015/01/23
- [Qemu-devel] [PULL 07/12] block: qapi - move string allocation from stack to the heap, Kevin Wolf, 2015/01/23
- Re: [Qemu-devel] [PULL 00/12] Block patches, Peter Maydell, 2015/01/26