From nobody Fri Nov 21 10:09:55 2025 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=1762883259; cv=none; d=zohomail.com; s=zohoarc; b=E/0GPvUB6UGjrv12f30H750B3h/liIAP6JvHYfsNbPSkSXhsp4faa7lRatd+VSguAE6c4rkqs86vxk2GzFqe61Sb/RBS8bs0jYZZo3m2b4uoxKFJQrzeO8nLp4/Usvo2ZGEqQDxt5Hulzqjl6uCovBxsTvj3VY2uTehNuU9IXos= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762883259; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=Bwo0rdrXK8ngxgNhb/mjj7Mpoq34bxoMIkkK2y8QfYg=; b=aYNtuLLxdZo9dIZD1qaMY1dm2giGZzlZbJ8hZThr+gqAzn6W4+ApsHMpvbk0UO8pQCfNH97OYxpopWG/15AsOKqDuPxcbbyyFIYSCtLyne0RVgld12epIQ5m4OWQfrvMBkZpM9zy+JrVVvBfgVGWj0UZgxBvGQ9ghDh1VL+S8eA= 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 1762883259232452.1917079166136; Tue, 11 Nov 2025 09:47:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 19BE441BAE; Tue, 11 Nov 2025 12:47:37 -0500 (EST) Received: from [172.19.199.29] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 173C944A51; Tue, 11 Nov 2025 12:40:53 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 077DE44151; Tue, 11 Nov 2025 12:40:07 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1304B4414F for ; Tue, 11 Nov 2025 12:40:07 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-Eugx5jprNb283qg2Z6cnzw-1; Tue, 11 Nov 2025 12:40:04 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CA11318007F2 for ; Tue, 11 Nov 2025 17:40:03 +0000 (UTC) Received: from colepc.home (unknown [10.22.82.11]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3130A195608E; Tue, 11 Nov 2025 17:40:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762882806; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bwo0rdrXK8ngxgNhb/mjj7Mpoq34bxoMIkkK2y8QfYg=; b=biJxNSoitMRc3YCm7DFy4lG8ycmZp5V73mxwQozg/xdFpN9KJPdiQbiGMbiPGRL1RfErzx bg+TbV+bc+UZ9w5AbTKpfLXNq/H53BG2ZpIM/TiRe2RcVHIRwOXip7qV7phc/oRft/G3WM Pm4Baebtbla5AQLTWsTbRJFyjmoWuvc= X-MC-Unique: Eugx5jprNb283qg2Z6cnzw-1 X-Mimecast-MFC-AGG-ID: Eugx5jprNb283qg2Z6cnzw_1762882803 To: devel@lists.libvirt.org Subject: [PATCH 4/4] selinux: Mark anything using content_context as shared Date: Tue, 11 Nov 2025 12:39:56 -0500 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GthFRCdeVyjTnf6xE9uCF1jaN4YKNtvo6NCvntdM8p8_1762882803 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ASGR6MIRQXGWE5ZHIXKEVG7CU7KM2PDE X-Message-ID-Hash: ASGR6MIRQXGWE5ZHIXKEVG7CU7KM2PDE X-MailFrom: crobinso@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Cole Robinson X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Cole Robinson via Devel Reply-To: Cole Robinson X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1762883260516158500 Content-Type: text/plain; charset="utf-8" This marks kernel, initrd, dtb, and similar elements with is_shared, meaning we skip label restore if xattr label remembering is not enabled or supported (like on qemu:///session). non-xattr based label restore is subject to race conditions if multiple VMs are starting and stopping using shared media: https://issues.redhat.com/browse/RHEL-126945 This convers every case that is using content_context (virt_content_t) as SetFileLabel time, which is how we are marking content as readonly. All the shareable cases (marked with file_context) are already skipping remembering/label restore entirely. Signed-off-by: Cole Robinson --- src/security/security_selinux.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 898f253256..2f3cc274a5 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2841,7 +2841,7 @@ virSecuritySELinuxRestoreSecuritySmartcardCallback(vi= rDomainDef *def, database =3D dev->data.cert.database; if (!database) database =3D VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE; - return virSecuritySELinuxRestoreFileLabel(mgr, database, true, fal= se); + return virSecuritySELinuxRestoreFileLabel(mgr, database, true, tru= e); =20 case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: return virSecuritySELinuxRestoreChardevLabel(mgr, def, @@ -2878,7 +2878,7 @@ virSecuritySELinuxRestoreSysinfoLabel(virSecurityMana= ger *mgr, virSysinfoFWCfgDef *f =3D &def->fw_cfgs[i]; =20 if (f->file && - virSecuritySELinuxRestoreFileLabel(mgr, f->file, true, false) = < 0) + virSecuritySELinuxRestoreFileLabel(mgr, f->file, true, true) <= 0) return -1; } =20 @@ -2974,23 +2974,23 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManage= r *mgr, } =20 if (def->os.kernel && - virSecuritySELinuxRestoreFileLabel(mgr, def->os.kernel, true, fals= e) < 0) + virSecuritySELinuxRestoreFileLabel(mgr, def->os.kernel, true, true= ) < 0) rc =3D -1; =20 if (def->os.initrd && - virSecuritySELinuxRestoreFileLabel(mgr, def->os.initrd, true, fals= e) < 0) + virSecuritySELinuxRestoreFileLabel(mgr, def->os.initrd, true, true= ) < 0) rc =3D -1; =20 if (def->os.shim && - virSecuritySELinuxRestoreFileLabel(mgr, def->os.shim, true, false)= < 0) + virSecuritySELinuxRestoreFileLabel(mgr, def->os.shim, true, true) = < 0) rc =3D -1; =20 if (def->os.dtb && - virSecuritySELinuxRestoreFileLabel(mgr, def->os.dtb, true, false) = < 0) + virSecuritySELinuxRestoreFileLabel(mgr, def->os.dtb, true, true) <= 0) rc =3D -1; =20 for (i =3D 0; i < def->os.nacpiTables; i++) { - if (virSecuritySELinuxRestoreFileLabel(mgr, def->os.acpiTables[i]-= >path, true, false) < 0) + if (virSecuritySELinuxRestoreFileLabel(mgr, def->os.acpiTables[i]-= >path, true, true) < 0) rc =3D -1; } =20 --=20 2.51.1