[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/61] qcow2: Use pread for inactive L1 in overlap ch
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 11/61] qcow2: Use pread for inactive L1 in overlap check |
Date: |
Fri, 11 Oct 2013 17:05:01 +0200 |
From: Max Reitz <address@hidden>
Currently, qcow2_check_metadata_overlap uses bdrv_read to read inactive
L1 tables from disk. The number of sectors to read is calculated through
a truncating integer division, therefore, if the L1 table size is not a
multiple of the sector size, the final entries will not be read and
their entries in memory remain undefined (from the g_malloc).
Using bdrv_pread fixes this.
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-refcount.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 2d67885..4cb9c23 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -1719,12 +1719,11 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs,
int chk, int64_t offset,
for (i = 0; i < s->nb_snapshots; i++) {
uint64_t l1_ofs = s->snapshots[i].l1_table_offset;
uint32_t l1_sz = s->snapshots[i].l1_size;
- uint64_t *l1 = g_malloc(l1_sz * sizeof(uint64_t));
+ uint64_t l1_sz2 = l1_sz * sizeof(uint64_t);
+ uint64_t *l1 = g_malloc(l1_sz2);
int ret;
- ret = bdrv_read(bs->file, l1_ofs / BDRV_SECTOR_SIZE, (uint8_t *)l1,
- l1_sz * sizeof(uint64_t) / BDRV_SECTOR_SIZE);
-
+ ret = bdrv_pread(bs->file, l1_ofs, l1, l1_sz2);
if (ret < 0) {
g_free(l1);
return ret;
--
1.8.1.4
- [Qemu-devel] [PULL 01/61] blockjob: rename BlockJobType to BlockJobDriver, (continued)
- [Qemu-devel] [PULL 01/61] blockjob: rename BlockJobType to BlockJobDriver, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 02/61] qapi: Introduce enum BlockJobType, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 03/61] qapi: make use of new BlockJobType, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 04/61] qapi: Add ImageInfoSpecific type, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 05/61] block: Add bdrv_get_specific_info, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 06/61] block/qapi: Human-readable ImageInfoSpecific dump, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 07/61] qcow2: Add support for ImageInfoSpecific, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 09/61] qemu-iotests: Additional info from qemu-img info, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 10/61] qcow2: Alignment of snapshot table entries, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 08/61] qemu-iotests: Discard specific info in _img_info, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 11/61] qcow2: Use pread for inactive L1 in overlap check,
Kevin Wolf <=
- [Qemu-devel] [PULL 12/61] qcow2: Free preallocated zero clusters, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 13/61] qcow2: Always use error path on writing snapshots, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 14/61] qcow2: Free allocated snapshot table on error, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 16/61] block/get_block_status: avoid redundant callouts on raw devices, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 17/61] block: Add BlockDriver.bdrv_check_ext_snapshot., Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 15/61] qcow2: Assert against snapshot name/ID overflow, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 18/61] qemu-iotests: Discard preallocated zero clusters, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 19/61] ahci: set ahci mode on reset, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 21/61] qcow2: Add missing space in error message, Kevin Wolf, 2013/10/11
- [Qemu-devel] [PULL 20/61] block: qemu-iotests for vhdx, read sample dynamic image, Kevin Wolf, 2013/10/11