From nobody Tue May 7 15:43:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564166327; cv=none; d=zoho.com; s=zohoarc; b=TGfHKHkUR91EdmlaOtiMQL1yy579FVOdXePUbN/rnfadtERay/z2HyoO1riOOrn9nZl0ecXcMYtjEkOTzAH10LQt5lAUYlacot6ut/VaYB0KpeSQy0piAp+XCKxC2yCEvR5JUQsJwmw7SfZDNiJqNyh8RcIqcDm9cdDmih87Gyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564166327; 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:ARC-Authentication-Results; bh=9ZindOwi4SXalz5iC88a5D1GjAxlbV8kRf3rlC1Vmus=; b=euiSf+8Fhza39RKu122qwnoHrXIlEC0vv5JwmRJDwmzMCAgWogODkLWZVPbtDsnWevE12rEJR6NzJaOqr8ult2NJnAzNCUd56GUNLmBwGz/L/f5K1L0ZjIClEFrHAsP89oVaJBdRrKnmaAywhLTchb6n606DeyEsmGG6Z2jq5ZA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564166327517442.1236774265709; Fri, 26 Jul 2019 11:38:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 323183092676; Fri, 26 Jul 2019 18:38:45 +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 05DDB1D3; Fri, 26 Jul 2019 18:38:43 +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 DF59C149E2; Fri, 26 Jul 2019 18:38:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6QIcfCK010182 for ; Fri, 26 Jul 2019 14:38:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 319FE61B89; Fri, 26 Jul 2019 18:38:41 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 268E81CD; Fri, 26 Jul 2019 18:38:35 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D175681F35; Fri, 26 Jul 2019 18:38:32 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6QIbeLg120597; Fri, 26 Jul 2019 14:38:32 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 2u05e6w3v1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jul 2019 14:38:32 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x6QIZZiC018594; Fri, 26 Jul 2019 18:38:31 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma05wdc.us.ibm.com with ESMTP id 2tymfe0y9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 Jul 2019 18:38:31 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6QIcURH42140010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Jul 2019 18:38:30 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7DBBC605B; Fri, 26 Jul 2019 18:38:30 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E9ACC6057; Fri, 26 Jul 2019 18:38:30 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Jul 2019 18:38:30 +0000 (GMT) From: Stefan Berger To: libvir-list@redhat.com, mprivozn@redhat.com Date: Fri, 26 Jul 2019 14:38:22 -0400 Message-Id: <20190726183822.1895339-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=724 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907260219 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 26 Jul 2019 18:38:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 26 Jul 2019 18:38:33 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'stefanb@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Stefan Berger Subject: [libvirt] [PATCH] RFC: security: Make sure to decrease ref count label value 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 26 Jul 2019 18:38:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" I noticed that if a domain fails to restore, the ref count in the xattr 'trusted.libvirt.security.ref_selinux' keeps on increasing indefinitely and the VM will never restore even if the root cause for the restore failure has been removed. The reason seems to be that the code to decrease the ref count never gets called because the block above it fails due to virSecuritySELinuxTransactionAppend() failing. The simple solution seems to be to revert the order in which things are done. Signed-off-by: Stefan Berger --- src/security/security_selinux.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index ea20373a90..9fd29e9bca 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1499,14 +1499,9 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManage= rPtr mgr, goto cleanup; } =20 - if ((rc =3D virSecuritySELinuxTransactionAppend(path, NULL, - false, recall, true)) < = 0) { - goto cleanup; - } else if (rc > 0) { - ret =3D 0; - goto cleanup; - } - + /* Recall the label so the ref count label decreases its counter + * even if transaction append below fails. + */ if (recall) { rc =3D virSecuritySELinuxRecallLabel(newpath, &fcon); if (rc =3D=3D -2) { @@ -1519,6 +1514,14 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManage= rPtr mgr, } } =20 + if ((rc =3D virSecuritySELinuxTransactionAppend(path, NULL, + false, recall, true)) < = 0) { + goto cleanup; + } else if (rc > 0) { + ret =3D 0; + goto cleanup; + } + if (!recall || rc =3D=3D -2) { if (stat(newpath, &buf) !=3D 0) { VIR_WARN("cannot stat %s: %s", newpath, --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list