From patchwork Sun Feb 2 21:12:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 105874 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 9FB843858408 for ; Sun, 2 Feb 2025 21:15:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FB843858408 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KK+eSyb2 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id BE8223858C54 for ; Sun, 2 Feb 2025 21:12:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE8223858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BE8223858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738530775; cv=none; b=NyztXrvWDaX3M9TCXB8WZCWzaBg4Bu9lpAgDprP1Xa9rZusplv4Zq4NZeVue4/jmKGCZrNxPxrhs1WoF6tQLiu/cdkrLWGOaGXRjCbU530vlb9+SySyKF3D0n4oP7yX9VKO1kO7auWji7BZzxE+3gEG9CMh9lmGgPzz+Fuz+enY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1738530775; c=relaxed/simple; bh=EHhihUiX5MBQf01KvdtnW7JHNYhAnJvT16guLdEgz8U=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=Cjj8AY6GhMn25VynA3ZiFCjqsEKziIgC28FEumxC42tc1HpDVY1Zy9HSnHOTduNt8SzMF1m70pnkbBEEFkDswq60EPTePFB+7ANm+mmB21dXVWT2sV+9d/HJmoHXFbMYWa2/nX9iwQ83crjwLw1ZZi7nk41dofy0zFnJA9sIOUc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE8223858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738530775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=68tMdtRlKSUzbnNikSdaDZiwFTG9JznP78KQ5syKBtA=; b=KK+eSyb2jXtGggxESyWTgdNX3QQoHz3OpzkJkd4xMFngB0HKvHsScf9XafFrAtDtYo8SL9 SUZxjdTDfpHa71dJ8pNUymwE4sVAa47uN34ilKcFT9LHWnRp/BfpQhW3voJv60XoSWroNi Mr+KNXlQ0ALcK3GgSs+yyvw77YY33fw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-nLmZ1apQPD-uXLb06bXTHQ-1; Sun, 02 Feb 2025 16:12:54 -0500 X-MC-Unique: nLmZ1apQPD-uXLb06bXTHQ-1 X-Mimecast-MFC-AGG-ID: nLmZ1apQPD-uXLb06bXTHQ Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A9C77180035F for ; Sun, 2 Feb 2025 21:12:53 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.2]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B7E6B19560AA for ; Sun, 2 Feb 2025 21:12:52 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v4 01/14] elf: Default to ENOENT error in _dl_map_new_object In-Reply-To: Message-ID: References: X-From-Line: b8af950b2ffb80d5cda19e67ad89730236203b02 Mon Sep 17 00:00:00 2001 Date: Sun, 02 Feb 2025 22:12:49 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JkEtEHMAoWerdGlcg62Xk636h1yx7xPI19GKsNn2_xw_1738530773 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The errno leak was originally observed as elf/tst-rtld-does-not-exist, elf/tst-rtld-dash-dash test failures on an AArch64 system without protection keys support: the ENOSPC error from the pkey_alloc system call leaked into the printed error message, causing the test failure. Without the pkey_alloc call, errno is 0. Setting ENOENT unconditionally still changes the error message, so update the test expectations accordingly. --- elf/dl-load.c | 5 +++++ elf/tst-rtld-dash-dash.sh | 2 +- elf/tst-rtld-does-not-exist.sh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 4998652adf..e328d678b4 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1939,6 +1939,11 @@ _dl_map_new_object (struct link_map *loader, const char *name, /* Will be true if we found a DSO which is of the other ELF class. */ bool found_other_class = false; + /* Default errno to ENOENT. The code may not end up doing any + system calls before setting fd to -1 because there are no search + paths. */ + __set_errno (ENOENT); + #ifdef SHARED /* Give the auditing libraries a chance to change the name before we try anything. */ diff --git a/elf/tst-rtld-dash-dash.sh b/elf/tst-rtld-dash-dash.sh index 5b00110d38..cf31552168 100644 --- a/elf/tst-rtld-dash-dash.sh +++ b/elf/tst-rtld-dash-dash.sh @@ -31,7 +31,7 @@ echo "output (with expected error):" cat "$tmp_out" if test $status -eq 127 \ - && grep -q "^--program-does-not-exist: error while loading shared libraries: --program-does-not-exist: cannot open shared object file$" "$tmp_out" \ + && grep -q "^--program-does-not-exist: error while loading shared libraries: --program-does-not-exist: cannot open shared object file: No such file or directory$" "$tmp_out" \ && test "$(wc -l < "$tmp_out")" -eq 1 ; then status=0 else diff --git a/elf/tst-rtld-does-not-exist.sh b/elf/tst-rtld-does-not-exist.sh index 9f404aecbf..418cfb445e 100644 --- a/elf/tst-rtld-does-not-exist.sh +++ b/elf/tst-rtld-does-not-exist.sh @@ -31,7 +31,7 @@ echo "output (with expected error):" cat "$tmp_out" if test $status -eq 127 \ - && grep -q "^program-does-not-exist: error while loading shared libraries: program-does-not-exist: cannot open shared object file$" "$tmp_out" \ + && grep -q "^program-does-not-exist: error while loading shared libraries: program-does-not-exist: cannot open shared object file: No such file or directory$" "$tmp_out" \ && test "$(wc -l < "$tmp_out")" -eq 1 ; then status=0 else