From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi45q-0006cY-7N for qemu-devel@nongnu.org; Sat, 25 Oct 2014 12:21:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xi45k-0005Me-BH for qemu-devel@nongnu.org; Sat, 25 Oct 2014 12:21:30 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:44813 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi45k-0005MP-23 for qemu-devel@nongnu.org; Sat, 25 Oct 2014 12:21:24 -0400 From: Peter Lieven Date: Sat, 25 Oct 2014 18:18:38 +0200 Message-Id: <1414253919-3044-7-git-send-email-pl@kamp.de> In-Reply-To: <1414253919-3044-1-git-send-email-pl@kamp.de> References: <1414253919-3044-1-git-send-email-pl@kamp.de> Subject: [Qemu-devel] [PATCHv5 6/6] block/iscsi: check for oversized requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, benoit@irqsave.net, ronniesahlberg@gmail.com, Peter Lieven , armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com 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 --- block/iscsi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index 85131b7..8747fc3 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -367,6 +367,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); @@ -534,6 +540,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; -- 1.7.9.5