]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block/iscsi: fix memory corruption on iscsi resize
authorPeter Lieven <pl@kamp.de>
Fri, 22 Aug 2014 08:08:49 +0000 (10:08 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 8 Sep 2014 16:23:05 +0000 (11:23 -0500)
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>
block/iscsi.c

index a7bb6970acffaa2c06b360b98f84879214d7f981..ed883c350171818119bbc6d8acc16f85203af8d7 100644 (file)
@@ -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));
     }