From nobody Thu Nov 6 19:05:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488226591384273.082879560896; Mon, 27 Feb 2017 12:16:31 -0800 (PST) Received: from localhost ([::1]:56534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciRig-0004il-4Y for importer@patchew.org; Mon, 27 Feb 2017 15:16:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciRck-0007vs-3h for qemu-devel@nongnu.org; Mon, 27 Feb 2017 15:10:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciRcj-00031j-6z for qemu-devel@nongnu.org; Mon, 27 Feb 2017 15:10:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciRce-0002zw-G6; Mon, 27 Feb 2017 15:10:16 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC5AE81222; Mon, 27 Feb 2017 20:10:16 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RK9n8M003294; Mon, 27 Feb 2017 15:10:14 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 27 Feb 2017 21:09:10 +0100 Message-Id: <1488226184-9044-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1488226184-9044-1-git-send-email-kwolf@redhat.com> References: <1488226184-9044-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 27 Feb 2017 20:10:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 09/43] vvfat: Implement .bdrv_child_perm() 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: kwolf@redhat.com, jcody@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" vvfat is the last remaining driver that can have children, but doesn't implement .bdrv_child_perm() yet. The default handlers aren't suitable here, so let's implement a very simple driver-specific one that protects the internal child from being used by other users as good as our permissions permit. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 2 +- block/vvfat.c | 22 ++++++++++++++++++++++ include/block/block_int.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 20dd1c5..7ae8264 100644 --- a/block.c +++ b/block.c @@ -823,7 +823,7 @@ static void bdrv_backing_options(int *child_flags, QDic= t *child_options, *child_flags =3D flags; } =20 -static const BdrvChildRole child_backing =3D { +const BdrvChildRole child_backing =3D { .inherit_options =3D bdrv_backing_options, .drained_begin =3D bdrv_child_cb_drained_begin, .drained_end =3D bdrv_child_cb_drained_end, diff --git a/block/vvfat.c b/block/vvfat.c index 7f230be..72b482c 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3052,6 +3052,27 @@ err: return ret; } =20 +static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c, + const BdrvChildRole *role, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + BDRVVVFATState *s =3D bs->opaque; + + assert(c =3D=3D s->qcow || role =3D=3D &child_backing); + + if (c =3D=3D s->qcow) { + /* This is a private node, nobody should try to attach to it */ + *nperm =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE; + *nshared =3D BLK_PERM_WRITE_UNCHANGED; + } else { + /* The backing file is there so 'commit' can use it. vvfat doesn't + * access it in any way. */ + *nperm =3D 0; + *nshared =3D BLK_PERM_ALL; + } +} + static void vvfat_close(BlockDriverState *bs) { BDRVVVFATState *s =3D bs->opaque; @@ -3077,6 +3098,7 @@ static BlockDriver bdrv_vvfat =3D { .bdrv_file_open =3D vvfat_open, .bdrv_refresh_limits =3D vvfat_refresh_limits, .bdrv_close =3D vvfat_close, + .bdrv_child_perm =3D vvfat_child_perm, =20 .bdrv_co_preadv =3D vvfat_co_preadv, .bdrv_co_pwritev =3D vvfat_co_pwritev, diff --git a/include/block/block_int.h b/include/block/block_int.h index eb0598e..63d5446 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -466,6 +466,7 @@ struct BdrvChildRole { =20 extern const BdrvChildRole child_file; extern const BdrvChildRole child_format; +extern const BdrvChildRole child_backing; =20 struct BdrvChild { BlockDriverState *bs; --=20 1.8.3.1