From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN0SM-0007mW-T3 for qemu-devel@nongnu.org; Thu, 28 Aug 2014 10:13:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XN0SI-0002qX-0L for qemu-devel@nongnu.org; Thu, 28 Aug 2014 10:13:42 -0400 Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 28 Aug 2014 16:13:20 +0200 Message-Id: <1409235205-21376-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1409235205-21376-1-git-send-email-pbonzini@redhat.com> References: <1409235205-21376-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 3/8] block/iscsi: fix memory corruption on iscsi resize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Lieven , qemu-stable@nongnu.org From: Peter Lieven 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: Paolo Bonzini --- block/iscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index 2c9cfc1..0bde13d 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1512,7 +1512,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)); } -- 1.8.3.1