From nobody Sat Apr 27 00:19:57 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565923409; cv=none; d=zoho.com; s=zohoarc; b=Kd3EoaRvj3c8Am1S/bRWX7yJWqZ2Ers908xSHysjy3w95lJNAL0C2jN/ESenJwrEDF+di+I6ZXQ+itvdk1rH0/zWglhq4+DkGuG7su+Dl4e9Eq6KFHHqg68KEwblyLQy4zg+atRZzvE4jNj40kS7ZJvWaceCcaZtJKK/bmPoNvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565923409; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lr6StpvZcwP7FLhET/iyuPbQEX0L2NtnKpzLUgzlh+w=; b=lRDSKCCzmD8r0cBy2s3g2a2Mrjkc0vgVM7aQIcu9tL5unNUL/pgWCgSo9+V+rSfmbRaAOKLcNW+7RbhbSEXkb8VKdYyMAWuhRFQDyL8b6Ja3neZTw2p2MiqPhXLpOczmId3QHD9g7G9l2NLRzIN/3qp+zXH/P6enLrPukwNg/Rg= 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565923409927616.4259245592012; Thu, 15 Aug 2019 19:43:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8FE3A4E832; Fri, 16 Aug 2019 02:43:28 +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 5AD8984252; Fri, 16 Aug 2019 02:43:28 +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 1C10718005A0; Fri, 16 Aug 2019 02:43:28 +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 x7G2g825030299 for ; Thu, 15 Aug 2019 22:42:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B97584252; Fri, 16 Aug 2019 02:42:08 +0000 (UTC) Received: from vhost2.laine.org (ovpn-117-27.phx2.redhat.com [10.3.117.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32FB4841FD; Fri, 16 Aug 2019 02:42:08 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Thu, 15 Aug 2019 22:41:59 -0400 Message-Id: <20190816024200.29474-2-laine@redhat.com> In-Reply-To: <20190816024200.29474-1-laine@redhat.com> References: <20190816024200.29474-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: yalzhang@redhat.com Subject: [libvirt] [PATCH 1/2] network: fix crash during cleanup from failure to allocate port 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 16 Aug 2019 02:43:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" During networkPortCreateXML, if networkAllocatePort() failed, networkReleasePort() would be called, which would (in the case of network pools of macvtap passthrough devices) attempt to find the allocated device by comparing port->plug.direct.linkdev to each device in the pool. Since port->plug.direct.linkdev was still NULL, the attempted strcmp would result in a SEGV. Calling networkReleasePort() during error cleanup is something that should only be done if networkAllocatePort() has already succeeded. It turns out there is one other possible error exit from networkPortCreateXML() that happens after networkAllocatePort() has succeeded, so the code to call networkReleasePort() was just moved down to there. Resolves: https://bugzilla.redhat.com/1741390 Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/network/bridge_driver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 1a5d08a00d..dae1def8de 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -5592,20 +5592,20 @@ networkPortCreateXML(virNetworkPtr net, rc =3D networkNotifyPort(obj, portdef); else rc =3D networkAllocatePort(obj, portdef); - if (rc < 0) { + if (rc < 0) + goto cleanup; + + if (virNetworkObjAddPort(obj, portdef, driver->stateDir) < 0) { virErrorPtr saved; + saved =3D virSaveLastError(); ignore_value(networkReleasePort(obj, portdef)); + virNetworkPortDefFree(portdef); virSetError(saved); virFreeError(saved); goto cleanup; } =20 - if (virNetworkObjAddPort(obj, portdef, driver->stateDir) < 0) { - virNetworkPortDefFree(portdef); - goto cleanup; - } - ret =3D virGetNetworkPort(net, portdef->uuid); cleanup: virNetworkObjEndAPI(&obj); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 00:19:57 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565923416; cv=none; d=zoho.com; s=zohoarc; b=DpDB1p9kr5GtpA7bzq44J61mMBfxEczlcVZb+ADcgxgCQrS2Kj4LN7w/eBB8W8r5uaDh58ND3iUZ6mffEUuzR3p9cXoYwy30ZzQq/U9S7Nf6aeMYO2a0v7Lw5/QTI+0yhhBZqsKQlcT8X0GVDjDuN4Cfnd/sov3EsW3R5p/TByI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565923416; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sdu70JIw+yRk5syGLPoChCEX6jFG9jFrBPiHggEWIUs=; b=iwMRbkBB3jLwKQGFIN+CquuwNd03Rzmts/wIRhzKzbSqa7wLwp1MqZn63yaMnf9e21lBWgYYDz+3Hled2yQvlkGEM0LTWbAc/34KXO7zihutdQjJWJkSZsH35HxSlWJZs/2qd5819OO9xkSFqYyb6HAk1GBaJkrwbBfpGTF0CIw= 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565923416140807.9541888723386; Thu, 15 Aug 2019 19:43:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C37913082A98; Fri, 16 Aug 2019 02:43:34 +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 A16FF43FDB; Fri, 16 Aug 2019 02:43:34 +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 6B986180085A; Fri, 16 Aug 2019 02:43:34 +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 x7G2g9Ck030304 for ; Thu, 15 Aug 2019 22:42:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4238984252; Fri, 16 Aug 2019 02:42:09 +0000 (UTC) Received: from vhost2.laine.org (ovpn-117-27.phx2.redhat.com [10.3.117.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD74B841FD; Fri, 16 Aug 2019 02:42:08 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Thu, 15 Aug 2019 22:42:00 -0400 Message-Id: <20190816024200.29474-3-laine@redhat.com> In-Reply-To: <20190816024200.29474-1-laine@redhat.com> References: <20190816024200.29474-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: yalzhang@redhat.com Subject: [libvirt] [PATCH 2/2] network: replace virSaveLastError() with virErrorPreserveLast() 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 16 Aug 2019 02:43:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virErrorPreserveLast()/virErrorRestore() (added in commit 8333e7455 back in 2017), do a better better job of saving and restoring the last libvirt error than virSaveLastError()/virErrorRestore() (they're simpler, and they also save/restore the system errno). Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/network/bridge_driver.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index dae1def8de..9059296e55 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2987,13 +2987,12 @@ networkStartNetwork(virNetworkDriverStatePtr driver, =20 cleanup: if (ret < 0) { + virErrorPtr save_err; + + virErrorPreserveLast(&save_err); virNetworkObjUnsetDefTransient(obj); - virErrorPtr save_err =3D virSaveLastError(); - int save_errno =3D errno; networkShutdownNetwork(driver, obj); - virSetError(save_err); - virFreeError(save_err); - errno =3D save_errno; + virErrorRestore(&save_err); } return ret; } @@ -5596,13 +5595,13 @@ networkPortCreateXML(virNetworkPtr net, goto cleanup; =20 if (virNetworkObjAddPort(obj, portdef, driver->stateDir) < 0) { - virErrorPtr saved; + virErrorPtr save_err; =20 - saved =3D virSaveLastError(); + virErrorPreserveLast(&save_err); ignore_value(networkReleasePort(obj, portdef)); virNetworkPortDefFree(portdef); - virSetError(saved); - virFreeError(saved); + virErrorRestore(&save_err); + goto cleanup; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list