From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZfli-0005hG-75 for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZflb-0002xa-RY for qemu-devel@nongnu.org; Wed, 09 Sep 2015 09:50:33 -0400 From: Paolo Bonzini Date: Wed, 9 Sep 2015 15:49:36 +0200 Message-Id: <1441806613-13775-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> References: <1441806613-13775-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 06/43] block/iscsi: validate block size returned from target 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 It has been reported that at least tgtd returns a block size of 0 for LUN 0. To avoid running into divide by zero later on and protect against other problematic block sizes validate the block size right at connection time. Cc: qemu-stable@nongnu.org Reported-by: Andrey Korolyov Signed-off-by: Peter Lieven Message-Id: <1439552016-8557-1-git-send-email-pl@kamp.de> Signed-off-by: Paolo Bonzini --- block/iscsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index 5002916..93f1ee4 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1214,6 +1214,10 @@ static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp) if (task == NULL || task->status != SCSI_STATUS_GOOD) { error_setg(errp, "iSCSI: failed to send readcapacity10 command."); + } else if (!iscsilun->block_size || + iscsilun->block_size % BDRV_SECTOR_SIZE) { + error_setg(errp, "iSCSI: the target returned an invalid " + "block size of %d.", iscsilun->block_size); } if (task) { scsi_free_scsi_task(task); -- 2.4.3