From: Peter Lieven Date: Mon, 27 Oct 2014 09:18:48 +0000 (+0100) Subject: block/iscsi: check for oversized requests X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~491^2~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc9e716369282ed687821d52cb3170369626f99f;p=sdk%2Femulator%2Fqemu.git block/iscsi: check for oversized requests Cancel oversized requests early. They would generate an iSCSI protocol error anyway; after having transferred possibly a lot of data over the wire. Suggested-By: Max Reitz Signed-off-by: Peter Lieven Signed-off-by: Stefan Hajnoczi --- diff --git a/block/iscsi.c b/block/iscsi.c index a4ba33b..111065d 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -362,6 +362,12 @@ static int coroutine_fn iscsi_co_writev(BlockDriverState *bs, return -EINVAL; } + if (bs->bl.max_transfer_length && nb_sectors > bs->bl.max_transfer_length) { + error_report("iSCSI Error: Write of %d sectors exceeds max_xfer_len " + "of %d sectors", nb_sectors, bs->bl.max_transfer_length); + return -EINVAL; + } + lba = sector_qemu2lun(sector_num, iscsilun); num_sectors = sector_qemu2lun(nb_sectors, iscsilun); iscsi_co_init_iscsitask(iscsilun, &iTask); @@ -529,6 +535,12 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs, return -EINVAL; } + if (bs->bl.max_transfer_length && nb_sectors > bs->bl.max_transfer_length) { + error_report("iSCSI Error: Read of %d sectors exceeds max_xfer_len " + "of %d sectors", nb_sectors, bs->bl.max_transfer_length); + return -EINVAL; + } + if (iscsilun->lbprz && nb_sectors >= ISCSI_CHECKALLOC_THRES && !iscsi_allocationmap_is_allocated(iscsilun, sector_num, nb_sectors)) { int64_t ret;