summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Lieven <pl@kamp.de>2014-08-22 10:08:49 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2014-09-08 11:23:05 -0500
commit8c4edd743c819813b3f409754f525309d72be53d (patch)
tree7c70f6eafb05b14094dc8b4ffaa48b0d134cbf78
parent504e2a7139d4790517ebdf2772f7daec27dc3f69 (diff)
downloadqemu-8c4edd743c819813b3f409754f525309d72be53d.tar.gz
block/iscsi: fix memory corruption on iscsi resize
bs->total_sectors is not yet updated at this point. resulting in memory corruption if the volume has grown and data is written to the newly availble areas. CC: qemu-stable@nongnu.org Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com> (cherry picked from commit d832fb4d66ead62da4af7e44cce34cd939e865e1) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--block/iscsi.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/block/iscsi.c b/block/iscsi.c
index a7bb6970ac..ed883c3501 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1509,7 +1509,8 @@ static int iscsi_truncate(BlockDriverState *bs, int64_t offset)
if (iscsilun->allocationmap != NULL) {
g_free(iscsilun->allocationmap);
iscsilun->allocationmap =
- bitmap_new(DIV_ROUND_UP(bs->total_sectors,
+ bitmap_new(DIV_ROUND_UP(sector_lun2qemu(iscsilun->num_blocks,
+ iscsilun),
iscsilun->cluster_sectors));
}