From nobody Thu Sep 19 01:19:12 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 1719906109170343.4982357622474; Tue, 2 Jul 2024 00:41:49 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2705E14B5; Tue, 2 Jul 2024 03:41:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4D81A1530; Tue, 2 Jul 2024 03:38:35 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 20589148F; Tue, 2 Jul 2024 03:38:29 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 93C6C148F for ; Tue, 2 Jul 2024 03:38:17 -0400 (EDT) Received: from mx-prod-mc-04.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-628-tvLDEfh-NTq_iGLmyDQOSg-1; Tue, 02 Jul 2024 03:38:15 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C478019560B4 for ; Tue, 2 Jul 2024 07:38:14 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E771D19560A3 for ; Tue, 2 Jul 2024 07:38:13 +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_H4,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=1719905897; 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=s1UVKF1i9Cm1+k157qd4ua4VqkWzRGE2hMnLQclcqCg=; b=g+Mo1MWdT13SX64wbWvLaP/Kjip2eJR04uhSwRe2ZIV+6TBt5aNCqpxrH+3x/5UTnb5QA5 i+IH70TifnwlH+B5zkbe05YeehyIXgtK9Uwj6FqO3GZFVyxgQX2XuYPZNYnATm2aXLkjfr G+2hODWI99wNzD2W6HI8wEfAFywlCZI= X-MC-Unique: tvLDEfh-NTq_iGLmyDQOSg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/5] security: Set seclabels for pstore device Date: Tue, 2 Jul 2024 09:38:05 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OBX5QLM6P2YRTSQC2PZWOHWKGE7FSQUQ X-Message-ID-Hash: OBX5QLM6P2YRTSQC2PZWOHWKGE7FSQUQ 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: 1719906110187100001 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 402cbd9602..84e4fae966 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1001,6 +1001,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) if (vah_add_file(&buf, ctl->def->os.loader->path, "rk") !=3D 0) goto cleanup; --=20 2.44.2