From nobody Thu Apr 2 23:55:51 2026 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=1774526039; cv=none; d=zohomail.com; s=zohoarc; b=Wbo+AxG2a0MpuyWTu8Cia04hUnP5DGwJ9fQ5Yq+M3JKY56izXS3VWmolyAsV82mBDLoopv5PXk/kMrxSxhigfaCJSnQ2X3T7LKZNXrhWjnLvDzSrPB2YRu42+1uvk7zuOLe681R4/HOtwydqyxPAmTZURzzmhIcZXE6sZVvcKOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774526039; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=P0gLymI+e9wrtk2eY1csDR375Q2lfP3yjvkqZpD1Yf8=; b=ZNzKbEHlklRb5+2VuRXBb8LvzsBk6pVp08vIWbagOB/kmqVmJEH/LmNOsBkcUZUbqUj7opREFo4Ral4bEfVZvXxAm7p2eNbI9u4tpSAnOoSbsDKkZETqi3lT6FTZr1bXoPx3qLpb6eWJaMkCeFPgX7RgxQKt1R3VjRe/jTHO/sg= 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 1774526039025262.1151651507631; Thu, 26 Mar 2026 04:53:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 46FEA3F351; Thu, 26 Mar 2026 07:53:58 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id DBEE3419A9; Thu, 26 Mar 2026 07:51:41 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0DBDC3F328; Thu, 26 Mar 2026 07:51:34 -0400 (EDT) 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 AFF5E3F2F8 for ; Thu, 26 Mar 2026 07:51:33 -0400 (EDT) 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-606-160A2sSPNH6gCyo7G6HN1w-1; Thu, 26 Mar 2026 07:51:32 -0400 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 760EF1800616 for ; Thu, 26 Mar 2026 11:51:31 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CE6A21955D84 for ; Thu, 26 Mar 2026 11:51:30 +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=-4.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,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=1774525893; 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=P0gLymI+e9wrtk2eY1csDR375Q2lfP3yjvkqZpD1Yf8=; b=iAUYEpJw1TdcQdsTopP+dAPf/5UzYJdg1EqP1APMAIVqxeefo1iN0dCnuIGiQIZqnVYsPr b/DFGitFBo15QhjXLQDyfd2LNgeGsUZztlRU8pUmi7fqsYLONH3YJsVwNAD9HsoFGNCbZR K3JpJ72WrIi0O0NFxziXf6BqljWfgcs= X-MC-Unique: 160A2sSPNH6gCyo7G6HN1w-1 X-Mimecast-MFC-AGG-ID: 160A2sSPNH6gCyo7G6HN1w_1774525891 To: devel@lists.libvirt.org Subject: [PATCH 3/3] security: Don't error out on seclabels of type='none' Date: Thu, 26 Mar 2026 12:51:25 +0100 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: 9eREp7DbIBD7ckmdzdKvN2BybunDAqvihw4dBk8fjRU_1774525891 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QC2GK5O5X5M3CIQC77B4U6H52NB3OBLE X-Message-ID-Hash: QC2GK5O5X5M3CIQC77B4U6H52NB3OBLE X-MailFrom: mprivozn@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 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: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1774526041094158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Ever since of commit v1.2.13-rc1~66 the model attribute of a is validated against secdriver names enabled. In nearly all cases this is something users want so that domain XML does not claim to set seclabels of a model that's not enabled. However, consider the following seclabel: It tells us to not bother setting selinux labels on given domain. A mgmt app might format this into domain XML if it sees selinux is disabled on the host. But if that's the case, selinux driver is not loaded and this virSecurityManagerCheckModel() doesn't find it and reports an error. Well, the error doesn't need to be reported as we will just ignore selinux as each driver callback checks if relabel is false (which it is for type=3D'none'). This is true for other secdrivers too. Resolves: https://redhat.atlassian.net/browse/RHEL-156689 Signed-off-by: Michal Privoznik Tested-by: Richard W.M. Jones --- src/security/security_manager.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/security/security_manager.c b/src/security/security_manage= r.c index f2f3bb4f19..7023ac2db8 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -727,7 +727,8 @@ virSecurityManagerReleaseLabel(virSecurityManager *mgr, =20 =20 static int virSecurityManagerCheckModel(virSecurityManager *mgr, - char *secmodel) + char *secmodel, + bool relabel) { g_autofree virSecurityManager **sec_managers =3D NULL; size_t i; @@ -744,6 +745,19 @@ static int virSecurityManagerCheckModel(virSecurityMan= ager *mgr, } } =20 + if (relabel =3D=3D false) { + const char * const knownModels[] =3D { + "none", "apparmor", "dac", "selinux" + }; + + for (i =3D 0; i < G_N_ELEMENTS(knownModels); i++) { + if (STREQ_NULLABLE(secmodel, knownModels[i])) { + VIR_INFO("Ignoring seclabel with model %s and relabel=3Dno= ", secmodel); + return 0; + } + } + } + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Security driver model '%1$s' is not available"), secmodel); @@ -758,8 +772,11 @@ virSecurityManagerCheckDomainLabel(virSecurityManager = *mgr, size_t i; =20 for (i =3D 0; i < def->nseclabels; i++) { - if (virSecurityManagerCheckModel(mgr, def->seclabels[i]->model) < = 0) + if (virSecurityManagerCheckModel(mgr, + def->seclabels[i]->model, + def->seclabels[i]->relabel) < 0) { return -1; + } } =20 return 0; @@ -773,8 +790,11 @@ virSecurityManagerCheckDiskLabel(virSecurityManager *m= gr, size_t i; =20 for (i =3D 0; i < disk->src->nseclabels; i++) { - if (virSecurityManagerCheckModel(mgr, disk->src->seclabels[i]->mod= el) < 0) + if (virSecurityManagerCheckModel(mgr, + disk->src->seclabels[i]->model, + disk->src->seclabels[i]->relabel)= < 0) { return -1; + } } =20 return 0; @@ -788,8 +808,11 @@ virSecurityManagerCheckChardevLabel(virSecurityManager= *mgr, size_t i; =20 for (i =3D 0; i < dev->source->nseclabels; i++) { - if (virSecurityManagerCheckModel(mgr, dev->source->seclabels[i]->m= odel) < 0) + if (virSecurityManagerCheckModel(mgr, + dev->source->seclabels[i]->model, + dev->source->seclabels[i]->relabe= l) < 0) { return -1; + } } =20 return 0; --=20 2.52.0