From patchwork Mon Mar 16 06:06:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 11439773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3B5C13B1 for ; Mon, 16 Mar 2020 06:11:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 895CC20674 for ; Mon, 16 Mar 2020 06:11:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 895CC20674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDiyE-0000p3-On for patchwork-qemu-devel@patchwork.kernel.org; Mon, 16 Mar 2020 02:11:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51041) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDitk-0007es-Fh for qemu-devel@nongnu.org; Mon, 16 Mar 2020 02:06:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDitj-0008FO-Kn for qemu-devel@nongnu.org; Mon, 16 Mar 2020 02:06:48 -0400 Received: from relay.sw.ru ([185.231.240.75]:49928) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jDitg-0007MJ-LT; Mon, 16 Mar 2020 02:06:44 -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 1jDitX-0004fQ-Uz; Mon, 16 Mar 2020 09:06:36 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH 0/2] zero pointer after bdrv_unref_child Date: Mon, 16 Mar 2020 09:06:29 +0300 Message-Id: <20200316060631.30052-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 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, den@openvz.org, vsementsov@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Hi all! I faced use-after-free of bs->backing pointer after bdrv_unref_child in bdrv_set_backing_hd. Fix it, and do similar thing for s->data_file in qcow2.c. I'm not sure that this is the full fix. Is it safe to keep bs->backing during bdrv_unref_child itself? Is it safe to keep bs->backing during all-child-unref loop in bdrv_close? Vladimir Sementsov-Ogievskiy (2): block: bdrv_set_backing_bs: fix use-after-free block/qcow2: zero data_file child after free block.c | 2 +- block/qcow2.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)