From nobody Mon May 6 12:53:22 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; 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=1575574366; cv=none; d=zohomail.com; s=zohoarc; b=GqzCzSPMVfEo8pQmwD96qVWuIjwBhV3Eu9CNPG3EPTieA4RWEYxAv+cxhTwPmL3FB7ieioKcX7K6erBQWsTxpQbflrXMH5Bqrzhr1SE+EzthwNvoPTe5wGI8CTetCr9rMC01kfx0BLjV1ni7HefNCyPSdSbg6QpFtRJFUSRt/6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575574366; 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=0tz9TA+qgv0u09xxN6x/vOjR2UZVbUcTLcKZ9Kav2WU=; b=Hn1eo8zdOBC7HF35edXelvnaCKNb46gT9HUvfruEo7OAzfQhVWyR5oesBnk332QDR2fNVY3u/JNLY3YAm+1v+oG0mF9up1TrDmXy5E85/6R4VSTQUYXrk/FOjoGPpJ6QowVnqVfXibk2aCT6XD/WHbG1+dYCKNDreJaumcOp0Qk= 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 1575574366296226.26351516895716; Thu, 5 Dec 2019 11:32:46 -0800 (PST) Received: from localhost ([::1]:60174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icwrk-00075U-R7 for importer@patchew.org; Thu, 05 Dec 2019 14:32:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56391) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icwq8-0006XZ-OC for qemu-devel@nongnu.org; Thu, 05 Dec 2019 14:31:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icwq7-0001ND-Bb for qemu-devel@nongnu.org; Thu, 05 Dec 2019 14:31:04 -0500 Received: from relay.sw.ru ([185.231.240.75]:51528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1icwq0-0001A4-Qt; Thu, 05 Dec 2019 14:30:57 -0500 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 1icwpt-0001aj-II; Thu, 05 Dec 2019 22:30:49 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH for-4.2?] block/qcow2-bitmap: fix crash bug in qcow2_co_remove_persistent_dirty_bitmap Date: Thu, 5 Dec 2019 22:30:49 +0300 Message-Id: <20191205193049.30666-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, vsementsov@virtuozzo.com, jsnow@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Here is double bug: First, return error but not set errp. This may lead to: qmp block-dirty-bitmap-remove may report success when actually failed block-dirty-bitmap-remove used in a transaction will crash, as qmp_transaction will think that it returned success and will cal block_dirty_bitmap_remove_commit which will crash, as state->bitmap is NULL Second (like in anecdote), this case is not an error at all. As it is documented in the comment above bdrv_co_remove_persistent_dirty_bitmap definition, absence of bitmap is not an error, and similar case handled at start of qcow2_co_remove_persistent_dirty_bitmap, it returns 0 when there is no bitmaps at all.. But when there are some bitmaps, but not the requested one, it return error with errp unset. Fix that. Fixes: b56a1e31759b750 Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Reviewed-by: John Snow --- Hi all! Ohm, suddenly we faced this bug. It's a regression in 4.2. I'm very sorry for introducing it, and it sad that it's found so late.. Personally, I think that this one worth rc5, as it makes new bitmap interfaces unusable. But the decision is yours. Last minute edit: hmm, actually, transaction action introduced in 4.2, so crash is not a regression, only broken block-dirty-bitmap-remove command is a regression... Maybe it's OK for stable. block/qcow2-bitmap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 8abaf632fc..c6c8ebbe89 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1469,8 +1469,10 @@ int coroutine_fn qcow2_co_remove_persistent_dirty_bi= tmap(BlockDriverState *bs, Qcow2BitmapList *bm_list; =20 if (s->nb_bitmaps =3D=3D 0) { - /* Absence of the bitmap is not an error: see explanation above - * bdrv_remove_persistent_dirty_bitmap() definition. */ + /* + * Absence of the bitmap is not an error: see explanation above + * bdrv_co_remove_persistent_dirty_bitmap() definition. + */ return 0; } =20 @@ -1485,7 +1487,8 @@ int coroutine_fn qcow2_co_remove_persistent_dirty_bit= map(BlockDriverState *bs, =20 bm =3D find_bitmap_by_name(bm_list, name); if (bm =3D=3D NULL) { - ret =3D -EINVAL; + /* Absence of the bitmap is not an error, see above. */ + ret =3D 0; goto out; } =20 --=20 2.21.0