From nobody Mon May 6 06:53:27 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522678548892698.2120772098322; Mon, 2 Apr 2018 07:15:48 -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 325DA356D2; Mon, 2 Apr 2018 14:15:47 +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 E2F6A7652E; Mon, 2 Apr 2018 14:15:46 +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 09E26180596E; Mon, 2 Apr 2018 14:15:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w32EFiZM023058 for ; Mon, 2 Apr 2018 10:15:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id CB0B96046C; Mon, 2 Apr 2018 14:15:44 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DE40601B3 for ; Mon, 2 Apr 2018 14:15:44 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 10:15:38 -0400 Message-Id: <20180402141539.1490-2-jferlan@redhat.com> In-Reply-To: <20180402141539.1490-1-jferlan@redhat.com> References: <20180402141539.1490-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] lxc: Fix possible leaked @vm in lxcDomainCreateXMLWithFiles 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: , MIME-Version: 1.0 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.30]); Mon, 02 Apr 2018 14:15:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In error paths, if we call virDomainObjListRemove we will leak the @vm because we have called with a reffed and locked @vm. So rather than set it to NULL, relock the @vm and allow the virDomainObjEndAPI to perform the magic of Unlock/Unref. Signed-off-by: John Ferlan --- src/lxc/lxc_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4f600f3df7..54f853cbae 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1245,7 +1245,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) { if (!vm->persistent) { virDomainObjListRemove(driver->domains, vm); - vm =3D NULL; + virObjectLock(vm); } goto cleanup; } @@ -1258,7 +1258,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, virLXCDomainObjEndJob(driver, vm); if (!vm->persistent) { virDomainObjListRemove(driver->domains, vm); - vm =3D NULL; + virObjectLock(vm); } goto cleanup; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 06:53:27 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152267854876547.18419374925679; Mon, 2 Apr 2018 07:15:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55B9D883A4; Mon, 2 Apr 2018 14:15:47 +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 33C526046C; Mon, 2 Apr 2018 14:15:47 +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 E94A44CA9C; Mon, 2 Apr 2018 14:15:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w32EFjn5023068 for ; Mon, 2 Apr 2018 10:15:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3876A601B3; Mon, 2 Apr 2018 14:15:45 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-52.phx2.redhat.com [10.3.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFF5B6046C for ; Mon, 2 Apr 2018 14:15:44 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 2 Apr 2018 10:15:39 -0400 Message-Id: <20180402141539.1490-3-jferlan@redhat.com> In-Reply-To: <20180402141539.1490-1-jferlan@redhat.com> References: <20180402141539.1490-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] lxc: Fix object locking after virDomainObjListRemove 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: , MIME-Version: 1.0 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 02 Apr 2018 14:15:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The virDomainObjListRemove will return an unlocked @vm after calling with a reffed object, thus prior to calling virDomainObjEndAPI we should relock. Signed-off-by: John Ferlan --- src/lxc/lxc_driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 54f853cbae..9cf67b9854 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -493,6 +493,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->newDef ? vm->newDef : vm->def) < 0) { virDomainObjListRemove(driver->domains, vm); + virObjectLock(vm); goto cleanup; } =20 @@ -557,6 +558,7 @@ static int lxcDomainUndefineFlags(virDomainPtr dom, vm->persistent =3D 0; } else { virDomainObjListRemove(driver->domains, vm); + virObjectLock(vm); } =20 ret =3D 0; @@ -1529,8 +1531,10 @@ lxcDomainDestroyFlags(virDomainPtr dom, =20 endjob: virLXCDomainObjEndJob(driver, vm); - if (!vm->persistent) + if (!vm->persistent) { virDomainObjListRemove(driver->domains, vm); + virObjectLock(vm); + } =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list