From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWKcP-00007C-60 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 04:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWKcL-000655-A2 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 04:39:09 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:33707 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWKcK-00064N-Tl for qemu-devel@nongnu.org; Mon, 31 Aug 2015 04:39:05 -0400 References: <1439552016-8557-1-git-send-email-pl@kamp.de> From: Peter Lieven Message-ID: <55E41297.5000303@kamp.de> Date: Mon, 31 Aug 2015 10:38:47 +0200 MIME-Version: 1.0 In-Reply-To: <1439552016-8557-1-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] 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, qemu-block@nongnu.org Cc: pbonzini@redhat.com, andrey@xdel.ru, qemu-stable@nongnu.org, ronniesahlberg@gmail.com Am 14.08.2015 um 13:33 schrieb 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 > --- > block/iscsi.c | 4 ++++ > dtc | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/block/iscsi.c b/block/iscsi.c > index 5002916..fac3a7a 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); Ping