From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by sourceware.org (Postfix) with ESMTPS id 010713858D28 for ; Mon, 8 Apr 2024 15:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 010713858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 010713858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712591858; cv=none; b=fYHO6j5VJjKmyG7oOeVjKohZc5AZRKAQvgYhDHi2XrEw9SVS82kr7FQsraTMkWP2CikJt4SXpzhRb5tbzzccMAxsm3fC21TSLFBTZyXDF73wYK/ZHQmSsjQZUd81zh/0vBXFYvqtsyUVfnqyvXNSx4wl926ilxmbMP73vOAmKhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712591858; c=relaxed/simple; bh=hEXHE0ZWesWyC7Iby/glQBvQVS56ask0lGQgohsEdZ8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=XUDaN51U0waUxjMlgwo7qsmu9DFvMEqemxqKINz4rIKO1jYn8+Ds1FZGQ8qUTvu33GiFP67MJptsqZwLzEjhuY4fz1/KrNZTdQ4uxd2F0mmHn1iukleZjlx2/7uF3YluM3Nk8ocBBzHuMR6PGwZNXwUHFrYeDRds1VpU8jP66dk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-dd10ebcd702so4750045276.2 for ; Mon, 08 Apr 2024 08:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712591855; x=1713196655; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=osbqa9+4ttBlpwyLSwLRK7KcZulIHy8cC0gL19niYrc=; b=Quk9N8jds9mXU6Ka4E+QzLoKZUDQniTkRojqOatWZbWcgMWdCKHuQdCZTHFR1jgw1N oEdK8bUg8TwmdvlCD4zifiAuPsHTAjMQldvJzaycfXyd/gydXH1aI3T48pSNHq3rFy/N aI0UPBIvD12EDkaT4Vyg40rNUMzpT42Z5dPinTUk9WJY63brT+uCHlaMeIYGgxMhSWzH 5PyBPzvMQwK6YlyZ4URdi/6jm2pHY8Ws2oNVz9rRmjm0AduFZ8QDU2DNn8gXglPEjUhF onPJ2yFQVYrBfX1+RcR+/hYOkCIj5uZxgI6IovS6G8B1e7E1hw99W7PYD6u88+c2kPkm wAnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712591855; x=1713196655; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=osbqa9+4ttBlpwyLSwLRK7KcZulIHy8cC0gL19niYrc=; b=oHj46kz9nu6ifQ8ink1CSjROUxYW35L+FG6Q0NpbSF5UnHgPugzHedljBh9pdItZI9 na8Rdc84TEOob8qwj7owMfWbAcGa8lObJ8bdL1H8Vvq7PlF+/CAtNv9OrMq0dE2kRJGC j5rbTNPPW6HXPnELPtDj1qvx/n7C5ETlrmL0ztto3RCdlOHXFkaoBY59I+jg8Bc7TK9m uioaKa6g1ZW1aAzIxRvw1LULFAr2tWf2EmGYpPG7jIoLuQmNiE14ESlEaeD5J9bGW6xl Rz/i4B7JX0L7uX09QCQETFCtVq/1v2HeHiZfn0Ryr0keHnKgwVf79FzNXvnS5JRUThYW Dwsg== X-Gm-Message-State: AOJu0YwjTrebFgykcHUpBtuZmLYERl/xAcawT7oxF8ykkzTzlg5em5PM CnhfCUwMF4lLuY90IxcnG4s0jFZVTvmeabvjLxxpnrCDO0DzC4bMwI9+IiX5T8qHBMxlpw1nzId okirJVH4MAJBKe8p5i9K/pdcZs/M= X-Google-Smtp-Source: AGHT+IFpFZzvRuZLMPZahf7uCKKJz2dSCX97okgeZlbOJdXoUEWEpSuIZ0zxfMf1QT6HocvY7hwRX1NYRzNPG9+t7gg= X-Received: by 2002:a05:6902:70a:b0:dc7:1ab6:6aca with SMTP id k10-20020a056902070a00b00dc71ab66acamr8681151ybt.63.1712591855309; Mon, 08 Apr 2024 08:57:35 -0700 (PDT) MIME-Version: 1.0 References: <87le5nvosq.fsf@oldenburg.str.redhat.com> In-Reply-To: <87le5nvosq.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Mon, 8 Apr 2024 08:56:59 -0700 Message-ID: Subject: Re: [PATCH] elf: Add ld.so test with non-existing program name To: Florian Weimer Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3019.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Mon, Apr 8, 2024 at 8:48=E2=80=AFAM Florian Weimer = wrote: > > 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. > > --- > elf/Makefile | 7 +++++++ > elf/tst-rtld-does-not-exist.sh | 38 ++++++++++++++++++++++++++++++++++++= ++ > 2 files changed, 45 insertions(+) > > 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-te= st \ > '$(valgrind-suppressions-tst-valgrind-smoke)' > $@; $(eva= luate-test) > > +ifeq ($(run-built-tests),yes) > +tests-special +=3D $(objpfx)tst-rtld-does-not-exist.out > +endif > +$(objpfx)tst-rtld-does-not-exist.out: tst-rtld-does-not-exist.sh $(objpf= x)ld.so > + $(SHELL) $< $(objpfx)ld.so > $@; \ > + $(evaluate-test) > + > tests +=3D $(tests-execstack-$(have-z-execstack)) > ifeq ($(run-built-tests),yes) > tests-special +=3D \ > diff --git a/elf/tst-rtld-does-not-exist.sh b/elf/tst-rtld-does-not-exist= .sh > new file mode 100644 > index 0000000000..7b3ba05702 > --- /dev/null > +++ b/elf/tst-rtld-does-not-exist.sh > @@ -0,0 +1,38 @@ > +#!/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=3DC > + > +rtld=3D"$1" > +tmp_out=3D"$(mktemp)" > + > +$rtld program-does-not-exist 2>"$tmp_out" > +status=3D$? > +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 l= ibraries: program-does-not-exist: cannot open shared object file$" "$tmp_ou= t" \ > + && test "$(wc -l < "$tmp_out")" -eq 1 ; then > + status=3D0 > +else > + status=3D1 > +fi > +exit $status > > base-commit: f8d8b1b1e6d3b8b93f224efc796b7ea083fdb83f > LGTM. Reviewed-by: H.J. Lu Thanks. --=20 H.J.