From nobody Sun Nov 24 04:16:10 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=1732119063; cv=none; d=zohomail.com; s=zohoarc; b=JcHcoJaXkZJNGc90v07Cqs3BPO1yX8u2fXCPwIWRfMNJxah7/cVE+bt0I21S0aUFrJyfepE07sVxYFWK4hM6uQuu3LN6n7OsPGdmkG+j4jBm3HrNFjwuNS4q/+/0NT/KCGa+1MUKt8INtOwyAGBwE7BOOH0Y2OdrD2G12lWOdFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119063; 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=zOYtrnvEvG83z5vRlbIcdGleYIJ5nDxz0RK7KgnrE1o=; b=CSUnz9ywhf0NmP6AUggSKsH2h+ioYdrsS7wf3TZLnqPV31yq9oPhNhgwpjoinJsI6oI+t58qw15eCsLxsdkO6WFvuHwLY51ZyM6cCZOBVu+4BxkP4PMxyaVqFnZjCp2vtX85WZ5Am52svi5ac0F9X/xMmKj6hePaAn3y6gENfSs= 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 1732119063302167.9608708413847; Wed, 20 Nov 2024 08:11:03 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3FDD8146C; Wed, 20 Nov 2024 11:11:02 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1455F1583; Wed, 20 Nov 2024 11:09:43 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0303C1461; Wed, 20 Nov 2024 11:09:36 -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 5E8961461 for ; Wed, 20 Nov 2024 11:09:36 -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 1tDn0w-0005yc-0T; Wed, 20 Nov 2024 16:53:10 +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=ziqxSOpMWgHjOZhMMLiwdGWktV9uvnHcjvos5dF0JpI=; b=Wrx8ZraaMf05 mcwPy2Lpm+9lCZLbcW5KmRKG1OG3XsMpxqz3TpcucGyJ+wnn+QnL1NPO7p5mF/+hBXsL6AvheudUU KuFpuK62TTJpEQ1nWXnWW0Pco9mKQfIeQJBsmQMTi7HxBCBw4+fpfQUpexlpPEl/N0CPBM5FVs2qz wkdjIihILFKVqU3D+XcUGuHz3FlIKR1oVbxb7e1oL/5m2o5w4/xh6n+d6lieOhBx8bjGkTJa/WoYB q+uFvT1bFGyMNSt/pwoX32QPaIijenVmPqAgllcTy1RLcbh5fv2aKfx24lWWFcsnneO4FK8Kv9wj+ YlvJ0Ak8vY4+FGiAfuYiag==; To: devel@lists.libvirt.org Subject: [PATCH 09/15] security: selinux: handle qcow2 data-file on image label set/restore Date: Wed, 20 Nov 2024 18:48:44 +0300 Message-ID: <20241120155229.1259-10-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: FQMBGTVAGTCZ4KMOPW3TGWMFTIIMWXJ6 X-Message-ID-Hash: FQMBGTVAGTCZ4KMOPW3TGWMFTIIMWXJ6 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: 1732119064286116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin Reviewed-by: Peter Krempa --- src/security/security_selinux.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 18daa521d1..05e24ff11b 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1934,8 +1934,16 @@ virSecuritySELinuxRestoreImageLabel(virSecurityManag= er *mgr, virStorageSource *src, virSecurityDomainImageLabelFlags flags= G_GNUC_UNUSED) { - return virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, - def, src, false); + if (virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, + def, src, false) < 0) + return -1; + + if (src->dataFileStore && + virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, + def, src->dataFileStore, fa= lse) < 0) + return -1; + + return 0; } =20 =20 @@ -2067,6 +2075,14 @@ virSecuritySELinuxSetImageLabel(virSecurityManager *= mgr, 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 && + virSecuritySELinuxSetImageLabelInternal(mgr, sharedFilesystems, + def, n->dataFileStore,= parent, + true) < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; =20 @@ -2929,6 +2945,13 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManager= *mgr, def, disk->src, migrated) < 0) rc =3D -1; + + if (disk->src->dataFileStore && + virSecuritySELinuxRestoreImageLabelInt(mgr, sharedFilesystems, + def, disk->src->dataFil= eStore, + migrated) < 0) + rc =3D -1; + } =20 for (i =3D 0; i < def->nhostdevs; i++) { --=20 2.43.5