From nobody Mon Apr 29 13:10:52 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 1512492085577660.702184922241; Tue, 5 Dec 2017 08:41:25 -0800 (PST) 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 23C3F6016B; Tue, 5 Dec 2017 16:41:24 +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 6D5AF63640; Tue, 5 Dec 2017 16:41:23 +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 440C31800BDE; Tue, 5 Dec 2017 16:41:22 +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 vB5GfK9K008776 for ; Tue, 5 Dec 2017 11:41:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id EFD2F7A1E1; Tue, 5 Dec 2017 16:41:20 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34DE0795BA; Tue, 5 Dec 2017 16:41:17 +0000 (UTC) From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Tue, 5 Dec 2017 16:41:15 +0000 Message-Id: <20171205164115.12972-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] nwfilter: don't crash listing filters in unprivileged daemon 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 05 Dec 2017 16:41:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The unprivileged libvirtd does not support nwfilter config, by leaves the driver active. It is supposed to result in all APIs being an effective no-op, but several APIs rely on driver->nwfilters being non-NULL, or they will reference a NULL pointer. Rather than adding checks for NULL in many places, just make sure driver->nwfilters is always initialized. Signed-off-by: Daniel P. Berrange Reviewed-by: John Ferlan --- src/nwfilter/nwfilter_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 2f9a51c405..89b767fe11 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -189,6 +189,8 @@ nwfilterStateInitialize(bool privileged, /* remember that we are going to use firewalld */ driver->watchingFirewallD =3D (sysbus !=3D NULL); driver->privileged =3D privileged; + if (!(driver->nwfilters =3D virNWFilterObjListNew())) + goto error; =20 if (!privileged) return 0; @@ -244,9 +246,6 @@ nwfilterStateInitialize(bool privileged, goto error; } =20 - if (!(driver->nwfilters =3D virNWFilterObjListNew())) - goto error; - if (virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->config= Dir) < 0) goto error; =20 @@ -271,6 +270,7 @@ nwfilterStateInitialize(bool privileged, virNWFilterIPAddrMapShutdown(); =20 err_free_driverstate: + virNWFilterObjListFree(driver->nwfilters); VIR_FREE(driver); =20 return -1; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list