From patchwork Mon Apr 8 16:42:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 88183 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 D094C385841C for ; Mon, 8 Apr 2024 16:43:05 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTPS id B9B0A3858D28 for ; Mon, 8 Apr 2024 16:42:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9B0A3858D28 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 B9B0A3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712594563; cv=none; b=sZBArtdB3ON+H0F8MNDdCMJRcWCS1MBN1Q9tHkPfu27p84n9xxjdRJ/ksd1GsvPxA2kZaFtey8IkPf9Zwydkv0nMs43w9DeXyEsZ5yHEF8heHGuDkzgHVKehJkmr5MeYx6VNaKWm/RleMCqNWV9rgu917mCXI8KDe/cI8ygIxIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712594563; c=relaxed/simple; bh=MN8DIxmtKnQ0l1dC5MTRWpxrekLG8zEBp+OUYlRTkwg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pS7UkMIY4bcjWyqXg7dmsPdvTugK2csdeACGEJFYzwFIvo5peproYTnovck8api41wMxzIsf17yyHMNKilQgmPqFGm3P0IyYURN9uMC9HdqgnRDkNllDvAjM8jBAfcOUhYzKSfa0M61bLmA5SM1LruX3R0XlhIBEV12Mi8/trOM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712594561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=gJygJ6RqqVum8uwq06sEB/Zbl6FXZjvzvLQzK1mKVqQ=; b=Vn9bprQlqu5r8zNhVqGGP/pRQQpi+yXXpRtFEVQGXjzs0f6qGSru86jMncj8kXP3KYatcU PuE3P0m4of6UEiQivXzUQpJ6ice512vvdOATn7K2DBgbVfawkmBQIhl4PS1HqD/Apq+t1M V/pvWdQgZSTZr3kv9W1pThq1DcFZhio= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-nTnu1Rm5Po2JRpGzgslWvw-1; Mon, 08 Apr 2024 12:42:39 -0400 X-MC-Unique: nTnu1Rm5Po2JRpGzgslWvw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A737B3813F21 for ; Mon, 8 Apr 2024 16:42:39 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D44E47B for ; Mon, 8 Apr 2024 16:42:38 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2] elf: Add ld.so test with non-existing program name Date: Mon, 08 Apr 2024 18:42:20 +0200 Message-ID: <877ch7vmab.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, 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 None of the existing tests seem to cover the case where _dl_signal_error is called without an active error handler. The new elf/tst-rtld-does-not-exist test triggers such a _dl_signal_error call from _dl_map_object. Reviewed-by: H.J. Lu --- v2: Delete temporary file. elf/Makefile | 7 +++++++ elf/tst-rtld-does-not-exist.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) base-commit: f8d8b1b1e6d3b8b93f224efc796b7ea083fdb83f diff --git a/elf/Makefile b/elf/Makefile index 4f1903391a..6dad11bcfb 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -621,6 +621,13 @@ $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so $(objpfx)v '$(run-program-env)' '$(rpath-link)' $(objpfx)valgrind-test \ '$(valgrind-suppressions-tst-valgrind-smoke)' > $@; $(evaluate-test) +ifeq ($(run-built-tests),yes) +tests-special += $(objpfx)tst-rtld-does-not-exist.out +endif +$(objpfx)tst-rtld-does-not-exist.out: tst-rtld-does-not-exist.sh $(objpfx)ld.so + $(SHELL) $< $(objpfx)ld.so > $@; \ + $(evaluate-test) + tests += $(tests-execstack-$(have-z-execstack)) ifeq ($(run-built-tests),yes) tests-special += \ diff --git a/elf/tst-rtld-does-not-exist.sh b/elf/tst-rtld-does-not-exist.sh new file mode 100644 index 0000000000..a4a781ccfd --- /dev/null +++ b/elf/tst-rtld-does-not-exist.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Check that running ld.so with a non-existing file prints an error. +# Copyright (C) 2024 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# . + +export LC_ALL=C + +rtld="$1" +tmp_out="$(mktemp)" + +$rtld program-does-not-exist 2>"$tmp_out" +status=$? +echo "$rtld exit status: $status" +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" \ + && test "$(wc -l < "$tmp_out")" -eq 1 ; then + status=0 +else + status=1 +fi +rm "$tmp_out" +exit $status