From nobody Mon Feb 9 11:48:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1680309770; cv=none; d=zohomail.com; s=zohoarc; b=c8/YCXDNzgxAI/p0fA98ePaN8fl0QN8goOs6eeW02GZo7sEOPS5oBsqTOKY02IxwLIL+t/yp+aKZiLJZTUuFrVQxnvJ5Iwnb6rWaR+Xlpk6c3xTFCPKK6/whe/FOOo6DH7m6sn/OygrgvmX3aicFTMUB80v4nZ5MeHizIfr4FDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680309770; 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=HcF4N0a0zCAH/QgfsxxBeQ7EK20GTDGt9K5WVszgGNA=; b=bLYsozDOLKMrW7Ct+4cRdji5UC7PaJTuct1PHasOl3/WgIgPZ6aKpLqaPz3fadIhXpcxHL2b12xxZi2SqNRIalmt5gJzHbvFxtZQf/LLlYTebSV1Y3j2uqZ3V8sb29ddOFDObpPNDuEX7MbNm5iqyJVQCJyQ4SnhPFPcCZntPJs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1680309770099343.8213031515784; Fri, 31 Mar 2023 17:42:50 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-386-tp9Tb6blNKW5TAov__E2uA-1; Fri, 31 Mar 2023 20:42:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5B5811C0418C; Sat, 1 Apr 2023 00:42:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED35DC15BA0; Sat, 1 Apr 2023 00:42:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A41A019465BC; Sat, 1 Apr 2023 00:42:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 01A8C19465A0 for ; Sat, 1 Apr 2023 00:42:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BA5EA40521FF; Sat, 1 Apr 2023 00:42:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B31A14052200 for ; Sat, 1 Apr 2023 00:42:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46E931C05EAE for ; Sat, 1 Apr 2023 00:42:24 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-I5gTbF0OOQ2sFNu8H-hC5g-1; Fri, 31 Mar 2023 20:42:16 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32VMc9Ia007581 for ; Sat, 1 Apr 2023 00:42:16 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pp6t8m27v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 01 Apr 2023 00:42:15 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32V6ScuK031802 for ; Sat, 1 Apr 2023 00:42:14 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3phrk6ntkv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 01 Apr 2023 00:42:14 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3310gAXI28115386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 1 Apr 2023 00:42:10 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8305820043; Sat, 1 Apr 2023 00:42:10 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70C3920049; Sat, 1 Apr 2023 00:42:10 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTPS; Sat, 1 Apr 2023 00:42:10 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 1E0AFE05BB; Sat, 1 Apr 2023 02:42:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680309769; 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=HcF4N0a0zCAH/QgfsxxBeQ7EK20GTDGt9K5WVszgGNA=; b=N0amCdb43L9gryfn1FS6QT0c5qXZkiOVUUmnrAXMv/qwFimYp7gYmnEIIFyM9u9IOfF+r/ qKueGsCpwoPiTqtJ5zssoZqADx7X4mgxBD9SbGxih3gdvuhoFal7Ym5/8n3L8Tnkyz9Afr 8KcphJevqo9W8HE9NZnylQkKLwaJ9jc= X-MC-Unique: tp9Tb6blNKW5TAov__E2uA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: I5gTbF0OOQ2sFNu8H-hC5g-1 From: Eric Farman To: libvir-list@redhat.com Subject: [PATCH] security: do not remember/recall labels for VFIO MDEVs Date: Sat, 1 Apr 2023 02:42:04 +0200 Message-Id: <20230401004204.496246-1-farman@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: cNaWuqAFS0pjmhpLrJ_O3PzjqA5jn2gj X-Proofpoint-ORIG-GUID: cNaWuqAFS0pjmhpLrJ_O3PzjqA5jn2gj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-31_07,2023-03-31_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=663 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304010003 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tony Krowiak , Boris Fiuczynski , Marc Hartmayer Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: linux.ibm.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1680309772501100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Commit dbf1f68410 ("security: do not remember/recall labels for VFIO") rightly changed the DAC and SELinux labeling parameters to fix a problem with "VFIO hostdevs" but really only addressed the PCI codepaths. As a result, we can still encounter this with VFIO MDEVs such as vfio-ccw and vfio-ap, which can fail on a hotplug: [test@host ~]# mdevctl stop -u 11f2d2bc-4083-431d-a023-eff72715c4f0 [test@host ~]# mdevctl start -u 11f2d2bc-4083-431d-a023-eff72715c4f0 [test@host ~]# cat disk.xml
[test@host ~]# virsh attach-device guest ~/disk.xml error: Failed to attach device from /home/test/disk.xml error: Requested operation is not valid: Setting different SELinux label = on /dev/vfio/3 which is already in use Make the same changes as reported in commit dbf1f68410, for the mdev paths. Reported-by: Matthew Rosato Signed-off-by: Eric Farman Reviewed-by: Michal Privoznik --- src/security/security_dac.c | 4 ++-- src/security/security_selinux.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 9be8f458d1..bceb6a5c24 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1310,7 +1310,7 @@ virSecurityDACSetHostdevLabel(virSecurityManager *mgr, if (!(vfiodev =3D virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuids= tr))) return -1; =20 - ret =3D virSecurityDACSetHostdevLabelHelper(vfiodev, true, &cbdata= ); + ret =3D virSecurityDACSetHostdevLabelHelper(vfiodev, false, &cbdat= a); break; } =20 @@ -1466,7 +1466,7 @@ virSecurityDACRestoreHostdevLabel(virSecurityManager = *mgr, if (!(vfiodev =3D virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuids= tr))) return -1; =20 - ret =3D virSecurityDACRestoreFileLabel(mgr, vfiodev); + ret =3D virSecurityDACRestoreFileLabelInternal(mgr, NULL, vfiodev,= false); break; } =20 diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index e43962435f..9c23735aa3 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2217,7 +2217,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityMa= nager *mgr, if (!(vfiodev =3D virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuids= tr))) return ret; =20 - ret =3D virSecuritySELinuxSetHostdevLabelHelper(vfiodev, true, &da= ta); + ret =3D virSecuritySELinuxSetHostdevLabelHelper(vfiodev, false, &d= ata); break; } =20 @@ -2445,7 +2445,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecuri= tyManager *mgr, if (!(vfiodev =3D virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuids= tr))) return -1; =20 - ret =3D virSecuritySELinuxRestoreFileLabel(mgr, vfiodev, true); + ret =3D virSecuritySELinuxRestoreFileLabel(mgr, vfiodev, false); break; } =20 --=20 2.37.2