From patchwork Mon Mar 28 21:36:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Dirk_M=C3=BCller?= X-Patchwork-Id: 52426 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9A1E53858C50 for ; Mon, 28 Mar 2022 21:36:55 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 88C8A3858C50 for ; Mon, 28 Mar 2022 21:36:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 88C8A3858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dmllr.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=dmllr.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B02691FDAC; Mon, 28 Mar 2022 21:36:44 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9AC081332D; Mon, 28 Mar 2022 21:36:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id dPWtJGwqQmIZZQAAMHmgww (envelope-from ); Mon, 28 Mar 2022 21:36:44 +0000 From: =?utf-8?q?Dirk_M=C3=BCller?= To: elfutils-devel@sourceware.org Subject: [PATCH] Avoid dlopen on debuginfod-client when not configured Date: Mon, 28 Mar 2022 23:36:41 +0200 Message-Id: <20220328213641.8667-1-dirk@dmllr.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Cc: =?utf-8?q?Dirk_M=C3=BCller?= Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Loading debuginfod-client is expensive, especially when FIPS is enabled, as it goes through time intensive self-checks on load. Avoid dlopen() when no debuginfo url is set. Signed-off-by: Dirk Müller --- libdwfl/ChangeLog | 5 +++++ libdwfl/debuginfod-client.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 9c5c8517..1ec13f30 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2022-03-28 Dirk Müller + + * debuginfod-client.c (__libdwfl_debuginfod_init): Skip dlopen + if debuginfod url is unset. + 2022-02-18 Mark Wielaard * image-header.c (__libdw_image_header): Assign header values for diff --git a/libdwfl/debuginfod-client.c b/libdwfl/debuginfod-client.c index 99b66b6e..af9d1363 100644 --- a/libdwfl/debuginfod-client.c +++ b/libdwfl/debuginfod-client.c @@ -101,7 +101,17 @@ __libdwfl_debuginfod_end (debuginfod_client *c) void __attribute__ ((constructor)) __libdwfl_debuginfod_init (void) { - void *debuginfod_so = dlopen(DEBUGINFOD_SONAME, RTLD_LAZY); + void *debuginfod_so; + + /* Is there any server we can query? If not, don't do any work, + just return with ENOSYS. Don't even access the cache. */ + char *urls_envvar = getenv(DEBUGINFOD_URLS_ENV_VAR); + if (urls_envvar == NULL || urls_envvar[0] == '\0') + { + return; + } + + debuginfod_so = dlopen(DEBUGINFOD_SONAME, RTLD_LAZY); if (debuginfod_so != NULL) {