From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS,URIBL_BLACK shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 49E1C1F5AE for ; Mon, 19 Jul 2021 14:34:20 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 338153951805 for ; Mon, 19 Jul 2021 14:34:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 338153951805 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626705259; bh=WG0cjdjf04uSY+9N+MYwa4ylfr94AIW6PB0QL86dspI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UcnOALh3VgXeHuF1QUUrnIrltX9u1l/SXql4J2TWkQGkvKxhQcZfJtZw3DTx7AZSP +XWSiFg98eS+eiCSb5iRZ6wxNmCBWV6uHgaXCafAuFaTddqFtk6PbkxXJa7tAdrLDb jG/D1b4gXMmQUMIIy44Hgae9KvoNpY4oK/BXfMok= Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 125F0386481C for ; Mon, 19 Jul 2021 14:33:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 125F0386481C Received: by mail-pg1-x532.google.com with SMTP id 37so19226700pgq.0 for ; Mon, 19 Jul 2021 07:33:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WG0cjdjf04uSY+9N+MYwa4ylfr94AIW6PB0QL86dspI=; b=Wr31xDgXEkkQEr7WCqhJBXdqU/IXWpdN98LXXCPm3rOvVdcW9FE2YBhziCxzhBHaXH FHRrTNbZCCiUx8T8fKqr22PM/QhdowG67zZ0u6/hKxsvucwgWFUuWkvauZe59NlyAtME mhxkKPYkS2IbIbcgHrPsDLTS6p3m8JI/21L1qchXu8ch2HakPF1cMUV2rl7tFvml+7bj lMJNBEZFgH3Rq37F1Ig3nBgEFNIOuriVRVyQLavZJ8xkvFaRigHnfH5QCHcrL18oIejK VEpKSoQF5wGVQflE1zhp3BYh4PD063Rk5eT+KGdbbFViPrUirEyPpV4+zAuw2jbnhlKK rUfw== X-Gm-Message-State: AOAM533YNEIgOfe0yMTRNXakLHnPuywW03zi9zrU0hfpNKqf441n9MNc H9T7ar7G9Kwm4cS3gGWgsMGdzXw4kHwrJA== X-Google-Smtp-Source: ABdhPJx6GdFrcd0ara2tAlDX/IjXUY1nBaLqvGgYTt4hHby+dGV53BfxBV5KO0pe6u0N3BGl0LCDXA== X-Received: by 2002:a65:6a42:: with SMTP id o2mr25134636pgu.316.1626705195044; Mon, 19 Jul 2021 07:33:15 -0700 (PDT) Received: from birita.. ([2804:431:c7ca:1133:c8a4:b05d:5ba9:3665]) by smtp.gmail.com with ESMTPSA id y13sm21461214pgp.16.2021.07.19.07.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 07:33:14 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 1/6] elf: Fix audit regression Date: Mon, 19 Jul 2021 11:33:04 -0300 Message-Id: <20210719143309.2848878-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210719143309.2848878-1-adhemerval.zanella@linaro.org> References: <20210719143309.2848878-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Adhemerval Zanella via Libc-alpha Reply-To: Adhemerval Zanella Cc: John Mellor-Crummey Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Commit 03e187a41d9 added a regression when an audit module does not have libc as DT_NEEDED (although unusual it is possible). Checked on x86_64-linux-gnu. --- elf/Makefile | 12 +++++++++++- elf/dl-open.c | 10 +--------- elf/tst-audit17.c | 25 +++++++++++++++++++++++++ elf/tst-auditmod17.c | 23 +++++++++++++++++++++++ 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 elf/tst-audit17.c create mode 100644 elf/tst-auditmod17.c diff --git a/elf/Makefile b/elf/Makefile index 4fe60947ad..3216d67bb4 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -219,7 +219,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \ tst-dlopen-self tst-auditmany tst-initfinilazyfail tst-dlopenfail \ tst-dlopenfail-2 \ tst-filterobj tst-filterobj-dlopen tst-auxobj tst-auxobj-dlopen \ - tst-audit14 tst-audit15 tst-audit16 \ + tst-audit14 tst-audit15 tst-audit16 tst-audit17 \ tst-single_threaded tst-single_threaded-pthread \ tst-tls-ie tst-tls-ie-dlmopen argv0test \ tst-glibc-hwcaps tst-glibc-hwcaps-prepend tst-glibc-hwcaps-mask \ @@ -1478,6 +1478,16 @@ $(objpfx)tst-auditlogmod-3.so: $(libsupport) $(objpfx)tst-audit16.out: \ $(objpfx)tst-auditlogmod-1.so $(objpfx)tst-auditlogmod-2.so \ $(objpfx)tst-auditlogmod-3.so +$(objpfx)tst-audit17.out: $(objpfx)tst-auditmod17.so +# The test check if a audit library without libc.so on DT_NEEDED works as +# intended, so it uses an explicit link rule. +$(objpfx)tst-auditmod17.so: $(objpfx)tst-auditmod17.os + $(CC) -nostdlib -nostartfiles -shared -o $@.new \ + $(filter-out $(map-file),$^) + $(call after-link,$@.new) + mv -f $@.new $@ +CFLAGS-.os += $(call elide-stack-protector,.os,tst-auditmod17) +tst-audit17-ENV = LD_AUDIT=$(objpfx)tst-auditmod17.so # tst-sonamemove links against an older implementation of the library. LDFLAGS-tst-sonamemove-linkmod1.so = \ diff --git a/elf/dl-open.c b/elf/dl-open.c index d2240d8747..218a8312a3 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -770,15 +770,7 @@ dl_open_worker (void *a) if (!args->libc_already_loaded) { struct link_map *libc_map = GL(dl_ns)[args->nsid].libc_map; -#ifdef SHARED - bool initial = libc_map->l_ns == LM_ID_BASE; -#else - /* In the static case, there is only one namespace, but it - contains a secondary libc (the primary libc is statically - linked). */ - bool initial = false; -#endif - _dl_call_libc_early_init (libc_map, initial); + _dl_call_libc_early_init (libc_map, false); } /* Run the initializer functions of new objects. Temporarily diff --git a/elf/tst-audit17.c b/elf/tst-audit17.c new file mode 100644 index 0000000000..92986699d4 --- /dev/null +++ b/elf/tst-audit17.c @@ -0,0 +1,25 @@ +/* Check DT_AUDIT with audit not linked against libc. + Copyright (C) 2021 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 + . */ + +static int +do_test (void) +{ + return 0; +} + +#include diff --git a/elf/tst-auditmod17.c b/elf/tst-auditmod17.c new file mode 100644 index 0000000000..7a4467f597 --- /dev/null +++ b/elf/tst-auditmod17.c @@ -0,0 +1,23 @@ +/* Check DT_AUDIT with audit not linked against libc. + Copyright (C) 2021 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 + . */ + +unsigned int +la_version (unsigned int version) +{ + return version; +} -- 2.30.2