From nobody Tue Sep 9 19:03:25 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=1753279311; cv=none; d=zohomail.com; s=zohoarc; b=RbGrX+/Q0INfoGM6LB4cFmcxcwcI5lPjR/aQrJwMvMYROhZK5+et5ewQZzS7lABeLvjDyhSTYNjApa9pgHDBBES1fEO13j8tralbo6GiAe13019HBqirCZovvKgkHh0tekz/ZPls5jn/kvv3WE3KG9oTx43LbqCOn6xdxgYZjB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753279311; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post: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=C9ud16n708CMprb3a6cFAoVB4xa5sLFKivVNAzQGQoM=; b=IFBQas3d8r+fCyGmAwk/0P4GxZ8pANtpNLEzsxYtLITUfuywt4h+K034co6YqQWURetVqEg6HEFBWQbv9HV2lJ83ald9ZBRxzeYJvdvEQMdqRuCIXFWlTU7WuytoLxtBRMSkHVboe/be5+41X2mWk5xr2S/3roKmacAI/SMkgKs= 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 1753279311816703.3575411732065; Wed, 23 Jul 2025 07:01:51 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B46631423; Wed, 23 Jul 2025 10:01:50 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8DAB9DB6; Wed, 23 Jul 2025 10:00:31 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 572E81423; Wed, 23 Jul 2025 10:00:27 -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 4C67C128F for ; Wed, 23 Jul 2025 10:00:20 -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-322-NksIDpPXPVmsQ4BjiKQqag-1; Wed, 23 Jul 2025 10:00:16 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CEDC61800295 for ; Wed, 23 Jul 2025 14:00:13 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 26EFB19560B7 for ; Wed, 23 Jul 2025 14:00:12 +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, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS 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=1753279220; 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=8ckD9HyLfVZtO1N0T6UTNjJ53gonM62CkbhRkmw4mlI=; b=LcSsi3lugnNC+/Q7s+4/22ohYGnWhGnA2Apazhi75MlRJj3tsteuSH1lwaUyge78D5N6+8 EkUGstYLz9c3uWSMMxhTLiYJg2qGmXmfLD3MrUv6JtmnDexqbCZ+FrY5u6ghTJkmSjwsvs s51+1Rhkfqj3Keh0hEmwh9MIhw6FodQ= X-MC-Unique: NksIDpPXPVmsQ4BjiKQqag-1 X-Mimecast-MFC-AGG-ID: NksIDpPXPVmsQ4BjiKQqag_1753279213 To: devel@lists.libvirt.org Subject: [PATCH 2/5] security_selinux: Drop needless checks for seclabel->model == "selinux" Date: Wed, 23 Jul 2025 16:00:05 +0200 Message-ID: <2f22d75957c1c2420c25f1f1d268e38cbbe55e4e.1753279190.git.mprivozn@redhat.com> 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-MFC-PROC-ID: bka3CEWlaAHzI5TMXpDXeW8RAToEhXETwejMlAN-HC8_1753279213 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: V7BM3IDEEA575AELDY5QXYSAAXWZJOUF X-Message-ID-Hash: V7BM3IDEEA575AELDY5QXYSAAXWZJOUF 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: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1753279315536116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik In few instances, after virDomainDefGetSecurityLabelDef(SECURITY_SELINUX_NAME) was called, we take the returned secdef and compare secdef->model against SECURITY_SELINUX_NAME. This makes no sense because virDomainDefGetSecurityLabelDef() has already done this comparison. Signed-off-by: Michal Privoznik --- src/security/security_selinux.c | 51 --------------------------------- 1 file changed, 51 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 402e0b7737..61a47f23c4 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -899,14 +899,6 @@ virSecuritySELinuxGenLabel(virSecurityManager *mgr, return rc; } =20 - if (seclabel->model && - STRNEQ(seclabel->model, SECURITY_SELINUX_NAME)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("security label model %1$s is not supported with = selinux"), - seclabel->model); - return rc; - } - VIR_DEBUG("type=3D%d", seclabel->type); =20 switch (seclabel->type) { @@ -3020,13 +3012,6 @@ virSecuritySELinuxVerify(virSecurityManager *mgr G_G= NUC_UNUSED, if (secdef =3D=3D NULL) return 0; =20 - if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("security label driver mismatch: '%1$s' model con= figured for domain, but hypervisor driver is '%2$s'."), - secdef->model, SECURITY_SELINUX_NAME); - return -1; - } - if (secdef->type =3D=3D VIR_DOMAIN_SECLABEL_STATIC) { if (security_check_context(secdef->label) !=3D 0) { virReportError(VIR_ERR_XML_ERROR, @@ -3049,13 +3034,6 @@ virSecuritySELinuxSetProcessLabel(virSecurityManager= *mgr G_GNUC_UNUSED, return 0; =20 VIR_DEBUG("label=3D%s", secdef->label); - if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("security label driver mismatch: '%1$s' model con= figured for domain, but hypervisor driver is '%2$s'."), - secdef->model, SECURITY_SELINUX_NAME); - if (security_getenforce() =3D=3D 1) - return -1; - } =20 if (setexeccon_raw(secdef->label) =3D=3D -1) { virReportSystemError(errno, @@ -3084,13 +3062,6 @@ virSecuritySELinuxSetChildProcessLabel(virSecurityMa= nager *mgr G_GNUC_UNUSED, return 0; =20 VIR_DEBUG("label=3D%s", secdef->label); - if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("security label driver mismatch: '%1$s' model con= figured for domain, but hypervisor driver is '%2$s'."), - secdef->model, SECURITY_SELINUX_NAME); - if (security_getenforce() =3D=3D 1) - return -1; - } =20 /* pick either the common label used by most binaries exec'ed by * libvirt, or the specific label of this binary. @@ -3132,13 +3103,6 @@ virSecuritySELinuxSetDaemonSocketLabel(virSecurityMa= nager *mgr G_GNUC_UNUSED, if (!secdef || !secdef->label) return 0; =20 - if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("security label driver mismatch: '%1$s' model con= figured for domain, but hypervisor driver is '%2$s'."), - secdef->model, SECURITY_SELINUX_NAME); - goto error; - } - if (getcon_raw(&scon) =3D=3D -1) { virReportSystemError(errno, _("unable to get current process context '%1$= s'"), @@ -3175,13 +3139,6 @@ virSecuritySELinuxSetSocketLabel(virSecurityManager = *mgr G_GNUC_UNUSED, if (!secdef || !secdef->label) return 0; =20 - if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("security label driver mismatch: '%1$s' model con= figured for domain, but hypervisor driver is '%2$s'."), - secdef->model, SECURITY_SELINUX_NAME); - goto error; - } - VIR_DEBUG("Setting VM %s socket context %s", vm->name, secdef->label); if (setsockcreatecon_raw(secdef->label) =3D=3D -1) { @@ -3211,14 +3168,6 @@ virSecuritySELinuxClearSocketLabel(virSecurityManage= r *mgr G_GNUC_UNUSED, if (!secdef || !secdef->label) return 0; =20 - if (STRNEQ(SECURITY_SELINUX_NAME, secdef->model)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("security label driver mismatch: '%1$s' model con= figured for domain, but hypervisor driver is '%2$s'."), - secdef->model, SECURITY_SELINUX_NAME); - if (security_getenforce() =3D=3D 1) - return -1; - } - if (setsockcreatecon_raw(NULL) =3D=3D -1) { virReportSystemError(errno, _("unable to clear socket security context '%= 1$s'"), --=20 2.49.1