From patchwork Mon Jun 20 09:24:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 9186963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51DA7607D1 for ; Mon, 20 Jun 2016 09:25:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B78220748 for ; Mon, 20 Jun 2016 09:25:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F88524DA2; Mon, 20 Jun 2016 09:25:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 540E920748 for ; Mon, 20 Jun 2016 09:25:12 +0000 (UTC) Received: from localhost ([::1]:42256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEvSB-0008Su-28 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 05:25:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEvRw-0008Sl-B4 for qemu-devel@nongnu.org; Mon, 20 Jun 2016 05:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEvRq-0006ry-Fa for qemu-devel@nongnu.org; Mon, 20 Jun 2016 05:24:56 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:53260 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEvRq-0006rY-5v for qemu-devel@nongnu.org; Mon, 20 Jun 2016 05:24:50 -0400 Received: (qmail 1016 invoked by uid 89); 20 Jun 2016 09:24:46 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.99.2/21757. hbedv: 8.3.40.44/7.12.99.34. avast: 1.2.2/16061901. spamassassin: 3.4.1. Clear:RC:1(195.62.97.28):. Processed in 0.114545 secs); 20 Jun 2016 09:24:46 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted); 20 Jun 2016 09:24:45 -0000 X-GL_Whitelist: yes Received: (qmail 26858 invoked from network); 20 Jun 2016 09:24:44 -0000 Received: from lieven-pc.kamp-intra.net (HELO lieven-pc) (relay@kamp.de@::ffff:172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPA; 20 Jun 2016 09:24:44 -0000 Received: by lieven-pc (Postfix, from userid 1000) id 98AE520A80; Mon, 20 Jun 2016 11:24:44 +0200 (CEST) From: Peter Lieven To: qemu-block@nongnu.org Date: Mon, 20 Jun 2016 11:24:40 +0200 Message-Id: <1466414680-18383-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:248:0:51::16 Subject: [Qemu-devel] [PATCH] iscsi: fix assertion in is_sector_request_lun_aligned X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Peter Lieven , qemu-devel@nongnu.org, mreitz@redhat.com, ronniesahlberg@gmail.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit 94d047a added an assertion the the request alignment check. This introduced 2 issues: a) A off-by-one error since a request of BDRV_REQUEST_MAX_SECTORS is actually allowed. b) The bdrv_get_block_status call in the read path to check the allocation status requests up to INT_MAX sectors which triggers the assertion. Fixes: 94d047a35bf663e28f8fef137544d8ea78165add Signed-off-by: Peter Lieven Reviewed-by: Eric Blake --- block/iscsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 7e78ade..9bb5ff6 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -417,7 +417,7 @@ static bool is_byte_request_lun_aligned(int64_t offset, int count, static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_sectors, IscsiLun *iscsilun) { - assert(nb_sectors < BDRV_REQUEST_MAX_SECTORS); + assert(nb_sectors <= BDRV_REQUEST_MAX_SECTORS); return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS, nb_sectors << BDRV_SECTOR_BITS, iscsilun); @@ -661,7 +661,8 @@ static int coroutine_fn iscsi_co_readv(BlockDriverState *bs, int64_t ret; int pnum; BlockDriverState *file; - ret = iscsi_co_get_block_status(bs, sector_num, INT_MAX, &pnum, &file); + ret = iscsi_co_get_block_status(bs, sector_num, + BDRV_REQUEST_MAX_SECTORS, &pnum, &file); if (ret < 0) { return ret; }