From nobody Fri May 3 12:49:06 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=1625047449; cv=none; d=zohomail.com; s=zohoarc; b=nsYngA06p5HeEBTqlu6YMzs/18tKADtjwKDPeJWIndtpF/4SLqXK3GfZIyg0KksHYAd+1m7ZPEDAkahlwufuixNuNG/f36FyShQ7PvvS1tLrdqQiw3gW/GIC6qdu9YecwG96T9d/q8d7w+V0XKCtJgwXAPu4zrvf6AUMpMl0Gmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625047449; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lJm/YgPaklBVlnA4L8iY1j60qzBWIh+WjktzlJRCDB4=; b=j6gF+UztbU/FFl9aNqnJawdt1XE3hnqa2nKAVYXLmjC8L5Gqp0fj1wStX1mMU4p5tN+2H2hdV53NbsYhPMKlS+6yrTs/G6oqnTCXxBPTPSEpEr3gN/6K8wzUrSEEZcGB9Q+VD2EmskKhp/8hTD4I1n/g6p6lJuof4Yn7SvIrD6A= 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 1625047449390735.5911810817263; Wed, 30 Jun 2021 03:04:09 -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-281-s47vU5FnMdGWAsuo2JSBJg-1; Wed, 30 Jun 2021 06:04:06 -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 329D8A309C; Wed, 30 Jun 2021 10:03:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB38860854; Wed, 30 Jun 2021 10:03:15 +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 4AF724EA2A; Wed, 30 Jun 2021 10:03:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15UA3ELn021748 for ; Wed, 30 Jun 2021 06:03:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id B5D313AC4; Wed, 30 Jun 2021 10:03:14 +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 DEE895D6AD; Wed, 30 Jun 2021 10:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625047448; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lJm/YgPaklBVlnA4L8iY1j60qzBWIh+WjktzlJRCDB4=; b=OQTD1if7CsJ4KxLPpgxQLC4bSxeuZqP+jqc1NvygPnK8IV6pI63Xx2NnK1ja51fr+mj/RC XBesMpJTQAtz5dudWjJzHpdCrUk1G8+izKMfEw6NO6HaJiJGbCx85qhnelnr4HR3+MVGmz 7LDW+JEHabYgmSlyInZ/jFfy8jVdUf0= X-MC-Unique: s47vU5FnMdGWAsuo2JSBJg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH] security: fix SELinux label generation logic Date: Wed, 30 Jun 2021 11:03:12 +0100 Message-Id: <20210630100312.743000-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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-xxxx - tbd before pushing Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Krempa --- 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..c98dab0d6f 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