diff mbox

block/iscsi: fix memory corruption on iscsi resize

Message ID 1408694929-1771-1-git-send-email-pl@kamp.de
State New
Headers show

Commit Message

Peter Lieven Aug. 22, 2014, 8:08 a.m. UTC
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>
---
 block/iscsi.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kevin Wolf Aug. 22, 2014, 8:55 a.m. UTC | #1
Am 22.08.2014 um 10:08 hat Peter Lieven geschrieben:
> 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>

Thanks, applied to the block branch.

Kevin
diff mbox

Patch

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));
     }