From patchwork Tue Jun 28 17:33:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 641668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rfDCd6RMCz9ssM for ; Wed, 29 Jun 2016 04:02:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=hpDEkbPl; dkim-atps=neutral Received: from localhost ([::1]:38558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHxKl-0002cl-Pj for incoming@patchwork.ozlabs.org; Tue, 28 Jun 2016 14:02:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHwuh-0000tE-5F for qemu-devel@nongnu.org; Tue, 28 Jun 2016 13:35:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHwuf-0003BD-2P for qemu-devel@nongnu.org; Tue, 28 Jun 2016 13:35:06 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHwue-0003Ah-RA for qemu-devel@nongnu.org; Tue, 28 Jun 2016 13:35:04 -0400 Received: by mail-wm0-x243.google.com with SMTP id r201so7672300wme.0 for ; Tue, 28 Jun 2016 10:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=l0ekAbNhMHxQrQYw4WUr8HRlnTp5bRK1rY97eiv04dI=; b=hpDEkbPlvA8p2WsaniUu3y0v8Qn8wO3bY+R97hkX+wVZrnlx+V/H7f3WvvhRTRH1r2 Zq+hs3pcmGU+LwIq4QofK/9sOZbI2RozfthQGh+ob0CFqkrh+t4s2C62HRq1y6JGx4EF aUOEbeKJhGZkUpXu07Y/nFdSnsLcJBmatiRydGCNEKzGd6MlboPRmqoei9s15WlK/Uru v3pQuN++x7LpYngldcCL4K5JAZX4c7Ep8V6iz33J9MWZjt1PO6FdmPriwcbdkE2iKzBN WW8b4z8Nhg9lwTGqUxX5KIDoM98f32+iGTqp5VzGpNsL5NGwVFG35R9ribMDcFJqSTqO J2kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=l0ekAbNhMHxQrQYw4WUr8HRlnTp5bRK1rY97eiv04dI=; b=Aef1Us1mqLS4SUEszjU7f4TiNrzbQhHbGEbwmoZRlKsyqJyNTy/Zz40ulFRxQgT0+V /jFLMvG7E5AbZjhcnZMLKEtj3CXVvgeX4+R1JLcUdv7JmffudOHXao9RdUBYdMafRbkV Q2WaMFAQRVD1uiod29gMtcI2DwA3Q9hMEp1LTeJNu1KKXbs6LsBuSAIWXAen2O3Tf3Jo YOAinF4hTszDL3EX1BU+5wpQndADpWn9Yse8uNX32pmKjjK1Cf0aVAHDpoLGQbh4xM4e VmVJz5RPwMX6t+Jw0Z9cdE39UbKbY+HXY1OXh3Mr8BM0taEX4ijmzdzpwgsFoeLKWgoK 3Fkg== X-Gm-Message-State: ALyK8tKQPrNt+WEuJH/k4pi6F8p06wth+QKMmbhHtZp+0Zpm9zqPYo8aYNy58QIYNEMPnA== X-Received: by 10.28.140.202 with SMTP id o193mr18366667wmd.55.1467135304188; Tue, 28 Jun 2016 10:35:04 -0700 (PDT) Received: from donizetti.lan (94-39-188-118.adsl-ull.clienti.tiscali.it. [94.39.188.118]) by smtp.gmail.com with ESMTPSA id c142sm5305wme.18.2016.06.28.10.35.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2016 10:35:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 28 Jun 2016 19:33:54 +0200 Message-Id: <1467135242-874-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467135242-874-1-git-send-email-pbonzini@redhat.com> References: <1467135242-874-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 24/32] 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: Peter Lieven Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Lieven 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 Message-Id: <1466414680-18383-1-git-send-email-pl@kamp.de> Signed-off-by: Paolo Bonzini --- 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; }