From nobody Mon Apr 29 15:40:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584459515; cv=none; d=zohomail.com; s=zohoarc; b=dXaWGaNjvKrytX5VecW8ouoMh1tLpYatihYtc11pahgFCqTpd8X/SkKU3m7N1tfpFb5wS3q76iaXeYmNTPqq7Fal2XHjrm+Ml5oewGtOItjokTo61937TiVpzTWNwQbqoyT+enPsBGxL03Dt14DSkBfbt63qNoFY7jwmeGhZ8lE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584459515; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ws8HDmVwvDV5AY92fxD3+WmuLSy/5BMimrFpbSm5Wjc=; b=Y/tstuI+Z7BvcUkN/QBCMCen70WUeWfK2Sv15FAAEP9hq4FAraX8+IMZrV29HbOWfT79OfAlelAK0hqhAUIncFCYWG3gtasUMcH+vm+Y6J/R+lIxQYRjyIuIHuACdEXGYE5RAoZItXtTV7e/63TCGAP3lU1BMACj3PASSdaMfGI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584459515026221.4394424359234; Tue, 17 Mar 2020 08:38:35 -0700 (PDT) Received: from localhost ([::1]:34930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEEIb-0008T1-PC for importer@patchew.org; Tue, 17 Mar 2020 11:38:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35087) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEDzV-0005Rh-CN for qemu-devel@nongnu.org; Tue, 17 Mar 2020 11:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEDzU-0008R6-02 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 11:18:49 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:49647) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEDzT-0008P1-Sh for qemu-devel@nongnu.org; Tue, 17 Mar 2020 11:18:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-f_MuiGN0OduPi4lGZ0i4Yg-1; Tue, 17 Mar 2020 11:18:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B7DF8017DF; Tue, 17 Mar 2020 15:18:40 +0000 (UTC) Received: from localhost (ovpn-114-232.ams2.redhat.com [10.36.114.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23E4810840CD; Tue, 17 Mar 2020 15:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584458326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ws8HDmVwvDV5AY92fxD3+WmuLSy/5BMimrFpbSm5Wjc=; b=WbgS4uHYIHaCH6jhoNBXum0IuagetjfBioHAMhu8USM2VEIbcNWAZ3H3l7HuPc8CEg3E9u 7ypH3Y1orzrQC18/te/pmCMTCdTdYqw6AWZWLqL3JX8KjI9GuYMN3winIq1D3ve1oRmy/v ZwjwSzeepXZh4O6FkDGIw7lvhqRrLc0= X-MC-Unique: f_MuiGN0OduPi4lGZ0i4Yg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 1/1] block/io: fix bdrv_co_do_copy_on_readv Date: Tue, 17 Mar 2020 15:18:31 +0000 Message-Id: <20200317151831.531965-2-stefanha@redhat.com> In-Reply-To: <20200317151831.531965-1-stefanha@redhat.com> References: <20200317151831.531965-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 216.205.24.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Peter Maydell , qemu-stable@nongnu.org, Max Reitz , Stefan Hajnoczi , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Prior to 1143ec5ebf4 it was OK to qemu_iovec_from_buf() from aligned-up buffer to original qiov, as qemu_iovec_from_buf() will stop at qiov end anyway. But after 1143ec5ebf4 we assume that bdrv_co_do_copy_on_readv works on part of original qiov, defined by qiov_offset and bytes. So we must not touch qiov behind qiov_offset+bytes bound. Fix it. Cc: qemu-stable@nongnu.org # v4.2 Fixes: 1143ec5ebf4 Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow Message-id: 20200312081949.5350-1-vsementsov@virtuozzo.com Signed-off-by: Stefan Hajnoczi --- block/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/io.c b/block/io.c index 7e4cb74cf4..aba67f66b9 100644 --- a/block/io.c +++ b/block/io.c @@ -1399,7 +1399,7 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bdrv= Child *child, if (!(flags & BDRV_REQ_PREFETCH)) { qemu_iovec_from_buf(qiov, qiov_offset + progress, bounce_buffer + skip_bytes, - pnum - skip_bytes); + MIN(pnum - skip_bytes, bytes - progres= s)); } } else if (!(flags & BDRV_REQ_PREFETCH)) { /* Read directly into the destination */ --=20 2.24.1