From nobody Fri Oct 18 08:52:57 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 1718014484107192.05347357747712; Mon, 10 Jun 2024 03:14:44 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1BCED19CB; Mon, 10 Jun 2024 06:14:43 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 22FBD1A2B; Mon, 10 Jun 2024 06:11:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4292C19DF; Mon, 10 Jun 2024 06:11:40 -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 4ACBA19B6 for ; Mon, 10 Jun 2024 06:11:30 -0400 (EDT) Received: from mx-prod-mc-02.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-433-xlJJ7kNTPP64yRBek4bDbA-1; Mon, 10 Jun 2024 06:11:28 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 91545195609E for ; Mon, 10 Jun 2024 10:11:27 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B0DB71955E84 for ; Mon, 10 Jun 2024 10:11:26 +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=3.0 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,RCVD_IN_SBL_CSS,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718014290; 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=MtBCT3A4iYqh7o3RZaxAMEFcs/DURmjyp97eT5kmcmo=; b=Pr3u/v1JEss/lN9M9fIxPx0UIfwH/bCuspgQSwXAy11+DaPMsPEl6t1N6ouNCVCaiBz7eo 5rcU1JNpUk6HbR+21XTzaHQjQCu9vFlVHu+9/4uJB6S1w6as++xuXsjkEhkby4JRDNEyFh gxUPWptkRPy8Rp86c4Cbn7t7k7NuceI= X-MC-Unique: xlJJ7kNTPP64yRBek4bDbA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/5] security: Set seclabels for pstore device Date: Mon, 10 Jun 2024 12:11:18 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UOILC6XIPDWILVQEZSYAT3OEE7F6SYTQ X-Message-ID-Hash: UOILC6XIPDWILVQEZSYAT3OEE7F6SYTQ 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: 1718014484916100001 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 669b90125c..0e1bb3ffa8 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1985,6 +1985,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 @@ -2220,6 +2224,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 0374581f07..2ab0b0b80c 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