From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMhAA-000441-A5 for qemu-devel@nongnu.org; Wed, 27 Aug 2014 13:37:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMhA3-00038Z-6B for qemu-devel@nongnu.org; Wed, 27 Aug 2014 13:37:38 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:45652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMhA2-00036r-V6 for qemu-devel@nongnu.org; Wed, 27 Aug 2014 13:37:31 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Aug 2014 11:37:30 -0600 From: Michael Roth Date: Wed, 27 Aug 2014 12:36:13 -0500 Message-Id: <1409160982-16389-17-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1409160982-16389-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1409160982-16389-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 16/25] 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: 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: Kevin Wolf (cherry picked from commit d832fb4d66ead62da4af7e44cce34cd939e865e1) Signed-off-by: Michael Roth --- block/iscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index a7bb697..ed883c3 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)); } -- 1.9.1