From nobody Fri Nov 14 00:50:20 2025 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; 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=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1584001273; cv=none; d=zohomail.com; s=zohoarc; b=AHzAGEl8TlS6+eUhH6DGqKMExrs8xTn+xkL5m0TiEi4j4YftItT0jHHi8LWcISneUzyKbOa12zotlwyci6Yac+yF0ylFfuzExCHVX2BJxmXbCIDAqffp3vLXtTF8TBcIeIwF8O8DdJ8v+WZHzAn3JUw579YR5FQmsFrDPmZ7S0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584001273; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=sjzo9m/mBZy354IYzbQoAsKsLfN2nxgVNUXwtacen1s=; b=SiK/Q4KO34tovxSm7gV0z+4ri86DzkEWbBMd/19yg73L1JiHmu00I0gyiX1BL5vbIQrtAMXqe+KUeQ+Gh2FVJwCkkQcB4+aRYtB9M21F/HEASyqUHWT73CUSvqwdW5zINwDjVVdrBHCsVDIPPMtXY1FSfuaDNxVyen5yNf27hac= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1584001273843708.1363049956017; Thu, 12 Mar 2020 01:21:13 -0700 (PDT) Received: from localhost ([::1]:37410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCJ5c-0006sI-JN for importer@patchew.org; Thu, 12 Mar 2020 04:21:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44137) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCJ4h-00067M-7s for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:20:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCJ4c-0007Ud-6Q for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:20:15 -0400 Received: from relay.sw.ru ([185.231.240.75]:47084) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCJ4Z-0007Mr-BP; Thu, 12 Mar 2020 04:20:07 -0400 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jCJ4S-0004G7-Lu; Thu, 12 Mar 2020 11:20:00 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH] block/io: fix bdrv_co_do_copy_on_readv Date: Thu, 12 Mar 2020 11:19:49 +0300 Message-Id: <20200312081949.5350-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 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: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, qemu-stable@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 --- 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.21.0