From nobody Wed May 14 08:05:56 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524157847833716.282939594564; Thu, 19 Apr 2018 10:10:47 -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 6FAF281240; Thu, 19 Apr 2018 17:10:46 +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 3D4E384AC0; Thu, 19 Apr 2018 17:10: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 EC1B11805972; Thu, 19 Apr 2018 17:10:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3JHADW1015121 for ; Thu, 19 Apr 2018 13:10:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55FF12026E04; Thu, 19 Apr 2018 17:10:13 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88AA921A468D; Thu, 19 Apr 2018 17:10:12 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 19 Apr 2018 18:09:54 +0100 Message-Id: <20180419171002.17117-7-berrange@redhat.com> In-Reply-To: <20180419171002.17117-1-berrange@redhat.com> References: <20180419171002.17117-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/14] driver: tighten check for whether loadable module exists or not 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-Type: text/plain; charset="utf-8" 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.25]); Thu, 19 Apr 2018 17:10:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Currently we do a access(R_OK) check to see whether a loadable module exists, treating failure as non-fatal. This is unreasonably loose, as a module which exists but has had incorrect permissions set will turn into a silent skip. We only want to skip loading if the module genuinely does not exist on disk, due to the optional package not being installed. Furthermore, checking the return value of virDriverLoadModuleFile() is not a suitable witness that the module does not exist. This method can return NULL if dlopen() fails, for example due to being unable to resolve symbols in the library. This is should always be reported as an error because it is a sign of the bad installation where either the module build doesn't match the libvirtd build, or where some 3rd party libraries are missing or broken. Both these problems can be fixed by using virFileExists in the caller instead. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/driver.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/driver.c b/src/driver.c index ddda1e71f7..e02efe2615 100644 --- a/src/driver.c +++ b/src/driver.c @@ -53,11 +53,6 @@ virDriverLoadModuleFile(const char *file) =20 VIR_DEBUG("Load module file '%s'", file); =20 - if (access(file, R_OK) < 0) { - VIR_INFO("Module %s not accessible", file); - return NULL; - } - virUpdateSelfLastChanged(file); =20 if (!(handle =3D dlopen(file, flags))) @@ -105,11 +100,14 @@ virDriverLoadModuleFull(const char *path, int (*regsym)(void); int ret =3D -1; =20 - if (!(rethandle =3D virDriverLoadModuleFile(path))) { - ret =3D 1; - goto cleanup; + if (!virFileExists(path)) { + VIR_INFO("Module '%s' does not exists", path); + return 1; } =20 + if (!(rethandle =3D virDriverLoadModuleFile(path))) + goto cleanup; + if (!(regsym =3D virDriverLoadModuleFunc(rethandle, regfunc))) goto cleanup; =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list