From: Peter Lieven Date: Fri, 22 Aug 2014 08:08:49 +0000 (+0200) Subject: block/iscsi: fix memory corruption on iscsi resize X-Git-Tag: v2.1.1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c4edd743c819813b3f409754f525309d72be53d;p=thirdparty%2Fqemu.git 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 Signed-off-by: Kevin Wolf (cherry picked from commit d832fb4d66ead62da4af7e44cce34cd939e865e1) Signed-off-by: Michael Roth --- diff --git a/block/iscsi.c b/block/iscsi.c index a7bb6970acf..ed883c35017 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)); }