From nobody Thu Sep 19 01:07:46 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1721651232751165.19135287070867; Mon, 22 Jul 2024 05:27:12 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id AF3FBCD2; Mon, 22 Jul 2024 08:27:11 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E8516DB5; Mon, 22 Jul 2024 08:23:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 10AF1A45; Mon, 22 Jul 2024 08:23:52 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 7969FB69 for ; Mon, 22 Jul 2024 08:23:44 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-xYlOWM2ZM2SKNSI4MLRbWg-1; Mon, 22 Jul 2024 08:23:42 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 785B21955BF7 for ; Mon, 22 Jul 2024 12:23:41 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 816F13000192 for ; Mon, 22 Jul 2024 12:23:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721651024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qXcCEoy4bKvFEvLc5LP39WyNC9UTjbHzvtjaMpKFtkY=; b=VoHBH0EFDRqZKtwiqxr8NuDcahZOc1ruO1MW5d1Fo7adT8alKhieqfbyiaKGASBqqHzn1q 3vacsi+2p68MsvKeHdigaUvE9GHQlrn1ynBYrJxUolb1idEvX7rUO506RqCqHO1peHCiRp qSBdk/2fbaQzC8JiQG3LlQhl2g2/u/g= X-MC-Unique: xYlOWM2ZM2SKNSI4MLRbWg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/5] security: Set seclabels for pstore device Date: Mon, 22 Jul 2024 14:23:32 +0200 Message-ID: <4d097882268cfdf33fd71296076ea651cbc71c66.1721650895.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TAUOLBGSLUM2ZSUEMQW5C7PYYH4GCO4D X-Message-ID-Hash: TAUOLBGSLUM2ZSUEMQW5C7PYYH4GCO4D X-MailFrom: mprivozn@redhat.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 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1721651234284116600 Content-Type: text/plain; charset="utf-8"; x-default="true" The acpi-erst backend for pstore device exposes a path in the host accessible to the guest and as such we must set seclabels on it to grant QEMU RW access. Signed-off-by: Michal Privoznik --- src/security/security_dac.c | 10 ++++++++++ src/security/security_selinux.c | 9 +++++++++ src/security/virt-aa-helper.c | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 1a3b51a298..59fc5b840f 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1995,6 +1995,10 @@ virSecurityDACRestoreAllLabel(virSecurityManager *mg= r, virSecurityDACRestoreFileLabel(mgr, def->os.slic_table) < 0) rc =3D -1; =20 + if (def->pstore && + virSecurityDACRestoreFileLabel(mgr, def->pstore->path) < 0) + rc =3D -1; + return rc; } =20 @@ -2240,6 +2244,12 @@ virSecurityDACSetAllLabel(virSecurityManager *mgr, user, group, true) < 0) return -1; =20 + if (def->pstore && + virSecurityDACSetOwnership(mgr, NULL, + def->pstore->path, + user, group, true) < 0) + return -1; + return 0; } =20 diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index e29f627bc2..ba0ce8fb9d 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2911,6 +2911,10 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManager= *mgr, virSecuritySELinuxRestoreFileLabel(mgr, def->os.slic_table, true) = < 0) rc =3D -1; =20 + if (def->pstore && + virSecuritySELinuxRestoreFileLabel(mgr, def->pstore->path, true) <= 0) + rc =3D -1; + return rc; } =20 @@ -3335,6 +3339,11 @@ virSecuritySELinuxSetAllLabel(virSecurityManager *mg= r, data->content_context, true) < 0) return -1; =20 + if (def->pstore && + virSecuritySELinuxSetFilecon(mgr, def->pstore->path, + data->content_context, true) < 0) + return -1; + return 0; } =20 diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 4d2b8ac4ab..067a17f331 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1002,6 +1002,10 @@ get_files(vahControl * ctl) if (vah_add_file(&buf, ctl->def->os.slic_table, "r") !=3D 0) goto cleanup; =20 + if (ctl->def->pstore) + if (vah_add_file(&buf, ctl->def->pstore->path, "rw") !=3D 0) + goto cleanup; + if (ctl->def->os.loader && ctl->def->os.loader->path) { bool readonly =3D false; virTristateBoolToBool(ctl->def->os.loader->readonly, &readonly); --=20 2.44.2