From nobody Wed May 8 01:50:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1625060476; cv=none; d=zohomail.com; s=zohoarc; b=PyST/kxfxjFPG4vl6PBrVmdqAM0/52LjL5VETPWq6R+aZSdfPcTKbXSFdb8iDOgbR6zgUDAFfv2uVmRZRfIuEVZc73LghPDSLgDbbtPkxiIxgHVNNMs6KrBGtoz0iPl1F8vxtyWhJWDDk8L7NJUKw4hxGt4AFo0L7N5E3G6gy/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625060476; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=4E/ARXRV0C+k4tFWfNPdjHwSEPq1kQ1afsBysP3jFl8=; b=Rf8Co/gZ/pCUPAVV2mehGMbkStHVrevAl2IiPwCD1s01SxF4ju1cHXsXhJpdrKuwOPIhnhNkwAUphs/ivCxu4NJLeXxs7D723hUoGgWrq5Lsn4ms3xoo5FG3lYVGqx61h3R4QhbMC4k7N7BlQaNGCQGvF3Jw8yURRqSpw+mFUdQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625060476898731.753772160526; Wed, 30 Jun 2021 06:41:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-581-oFxiKzidP16opYCeEceTzw-1; Wed, 30 Jun 2021 09:41:13 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D8AF80414C; Wed, 30 Jun 2021 13:41:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E49BC60843; Wed, 30 Jun 2021 13:41:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9FD7318095C2; Wed, 30 Jun 2021 13:41:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15UDeG6V031695 for ; Wed, 30 Jun 2021 09:40:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 10BDC131F7; Wed, 30 Jun 2021 13:40:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-116.ams2.redhat.com [10.36.114.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05099E2F9; Wed, 30 Jun 2021 13:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625060475; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4E/ARXRV0C+k4tFWfNPdjHwSEPq1kQ1afsBysP3jFl8=; b=UE7xgNnQpiKqquu2iCqlyvs+25w6YVpqcrnkfvFZfjQAsRb9HimW5lo0V8bKcU5r3oFKio YFHFMIv0Xj/CmK03C07PYZtRdXW28NsVXxfb+uwBTvvjxxrlar/1JJwTaU9PKERZgBsVK/ VcqCQaexebVF1Ts0pXmGIbzfUcrJ/1o= X-MC-Unique: oFxiKzidP16opYCeEceTzw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2] security: fix SELinux label generation logic Date: Wed, 30 Jun 2021 14:40:08 +0100 Message-Id: <20210630134008.877134-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Peter Krempa X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) A process can access a file if the set of MCS categories for the file is equal-to *or* a subset-of, the set of MCS categories for the process. If there are two VMs: a) svirt_t:s0:c117 b) svirt_t:s0:c117,c720 Then VM (b) is able to access files labelled for VM (a). IOW, we must discard case where the categories are equal because that is a subset of many other valid category pairs. Fixes: https://gitlab.com/libvirt/libvirt/-/issues/153 CVE-2021-3631 Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrang=C3=A9 --- Pushed to git, just publishing v2 to show the CVE allocation for the historical record. src/security/security_selinux.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index b50f4463cc..0c2cf1d1c7 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -383,7 +383,15 @@ virSecuritySELinuxMCSFind(virSecurityManager *mgr, VIR_DEBUG("Try cat %s:c%d,c%d", sens, c1 + catMin, c2 + catMin); =20 if (c1 =3D=3D c2) { - mcs =3D g_strdup_printf("%s:c%d", sens, catMin + c1); + /* + * A process can access a file if the set of MCS categories + * for the file is equal-to *or* a subset-of, the set of + * MCS categories for the process. + * + * IOW, we must discard case where the categories are equal + * because that is a subset of other category pairs. + */ + continue; } else { if (c1 > c2) { int t =3D c1; --=20 2.31.1