From nobody Fri Nov 22 05:01:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1732119183; cv=none; d=zohomail.com; s=zohoarc; b=YfRtuX5NooKJZEJivGfdu3LAqzOi4b9Z9GolFf6UREqrs+5nSK5CLw9ykvQW3aiImO+Lb7QZfx6v475dSEWV5QuyBGb46F9tVjxO/stjvK3i0McbnRAMQrD/+8vY9IadfA+JhRX2AW6WlOogHJEGq2vET6LUhEI8tM5BQ97OGnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119183; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=NXi8KS69D1/kKNd7/janq0Rfs/qCAwjuWF9V0VSMhY0=; b=Z2CQimiOu8+AgDcj+vsFs4NyKlBWKJIpa+7UmvmIJvI7jRySBCPGPKw2lSF46Amnx1M+cU+DDj9jgGclm5c0tfUrBmia/m4vtZ0IsyYcWADkHpdmSLZQeBkRCjoGi+yaLBwuHD71Y1HCj5OTe9dp82P4eoFdMfx6uS6FhDuOSkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732119183919339.3938367835027; Wed, 20 Nov 2024 08:13:03 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id C81D115AB; Wed, 20 Nov 2024 11:13:02 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A02A515A6; Wed, 20 Nov 2024 11:10:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C32FE1514; Wed, 20 Nov 2024 11:09:54 -0500 (EST) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 44F8E1589 for ; Wed, 20 Nov 2024 11:09:43 -0500 (EST) Received: from [130.117.225.1] (helo=vz9-barybin-2.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1tDn0u-0005yc-1n; Wed, 20 Nov 2024 16:53:08 +0100 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=cCr58UpUPu9iphJ7RV+4U57orKDgcLGzagWycbokrIg=; b=Kj5JSM0gFJAT K1Wt0OZ5RQytaCAqub58GD4XY5eLdbTr17r0GBtKp7cFQSBQzGBovNrc4y5G1jP3OuCDvE+rjUXOi VpGwBKrt0kv43NhL1FeyAptlG0tqZrsxd33bhn56lq2kHOIb6sjPuijSfDWfp8vVtpyVKYBunBCt0 GkHca4lb3UN/bhbSr/8wIdmKKUwLbQgFN+MOdQ01Ovf/cRpHyr/Z5qt8jugCdBczLcbvel1qvkFiF azgpIhCVbmtbWiiNgMqQ9O496+eb6GoRo3Gqa+Q0NPpcFx5ttrX8vC9yjTbKet6s0Lm4zIcM9eGRV 9sD94y+pWBhIuJdT9qFYTg==; To: devel@lists.libvirt.org Subject: [PATCH 08/15] security: DAC: handle qcow2 data-file on image label set/restore Date: Wed, 20 Nov 2024 18:48:43 +0300 Message-ID: <20241120155229.1259-9-nikolai.barybin@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241120155229.1259-1-nikolai.barybin@virtuozzo.com> References: <20241120155229.1259-1-nikolai.barybin@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FAHDFU7TYKHLFMP6SD2755ZDD2I7KUPU X-Message-ID-Hash: FAHDFU7TYKHLFMP6SD2755ZDD2I7KUPU X-MailFrom: nikolai.barybin@virtuozzo.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: den@openvz.org, Nikolai Barybin X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Nikolai Barybin via Devel Reply-To: Nikolai Barybin X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732119184654116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/security/security_dac.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index a179378a78..0505f4e4a3 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -969,6 +969,13 @@ virSecurityDACSetImageLabel(virSecurityManager *mgr, def, n, parent, isChainTop= ) < 0) return -1; =20 + /* Unlike backing images, data files are not designed to be shared= by + * anyone. Thus, we always consider them as chain top. */ + if (n->dataFileStore && + virSecurityDACSetImageLabelInternal(mgr, sharedFilesystems, de= f, + n->dataFileStore, n, true)= < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; =20 @@ -1065,8 +1072,16 @@ virSecurityDACRestoreImageLabel(virSecurityManager *= mgr, virStorageSource *src, virSecurityDomainImageLabelFlags flags G_G= NUC_UNUSED) { - return virSecurityDACRestoreImageLabelInt(mgr, sharedFilesystems, - def, src, false); + if (virSecurityDACRestoreImageLabelInt(mgr, sharedFilesystems, + def, src, false) < 0) + return -1; + + if (src->dataFileStore && + virSecurityDACRestoreImageLabelInt(mgr, sharedFilesystems, + def, src->dataFileStore, false)= < 0) + return -1; + + return 0; } =20 =20 @@ -1946,6 +1961,14 @@ virSecurityDACRestoreAllLabel(virSecurityManager *mg= r, def->disks[i]->src, migrated) < 0) rc =3D -1; + + if (def->disks[i]->src->dataFileStore && + virSecurityDACRestoreImageLabelInt(mgr, + sharedFilesystems, + def, + def->disks[i]->src->dataFil= eStore, + migrated) < 0) + rc =3D -1; } =20 for (i =3D 0; i < def->ngraphics; i++) { --=20 2.43.5