From patchwork Thu Mar 2 11:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Arsen_Arsenovi=C4=87?= X-Patchwork-Id: 65900 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 6B0A23858288 for ; Thu, 2 Mar 2023 11:39:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B0A23858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677757161; bh=pR0YRALGOKTZgw9rLulrSQ9I/m2fJCbv3hotNApMjAw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=EaEzl35I08aNWPDwQHA9FKXh9G+aIWvUa4FE1eWzrlo/ZNjtfXULzmk737xAAiAiW Sw7/RXF3qEVPi4AgyXw3UZIwbGDmoP/Dx6G3BFYMd6PJRsh+CTdO2dzFUc0zr7oxG3 2oLT9QWiMn+QTBVzTdCF42TGSqK9a8hQN9OqqvNA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id E69F93858D33 for ; Thu, 2 Mar 2023 11:38:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E69F93858D33 To: libc-alpha@sourceware.org Cc: Carlos O'Donell , Gentoo Toolchain , =?utf-8?q?Arsen_Arsenovi=C4=87?= Subject: [PATCH] elf,nptl: Add -z lazy -z norelro to tests that need it Date: Thu, 2 Mar 2023 12:25:19 +0100 Message-Id: <20230302112519.914641-1-arsen@gentoo.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 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: , X-Patchwork-Original-From: =?utf-8?q?Arsen_Arsenovi=C4=87_via_Libc-alpha?= From: =?utf-8?q?Arsen_Arsenovi=C4=87?= Reply-To: =?utf-8?q?Arsen_Arsenovi=C4=87?= Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Some toolchains, such as that used on Gentoo Hardened, set -z now -z relro out of the box. These flags break tests that rely on fixups in underlinked libraries being applied after a dlopen happens. --- Morning, This patch fixes a few test failures that we encounter on Gentoo when using a toolchain that builds packages with full relro. All of these failures come down to underlinked test objects, which are inherently in opposition with it. Tested on x86_64-pc-linux-gnu against 2.37 and 59a6d5e9477695c41d6feef7ef8636f8f744f3c5, so it should be okay for backporting too. Have a lovely day! elf/Makefile | 22 +++++++++++++++++++++- nptl/Makefile | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/elf/Makefile b/elf/Makefile index 0d19964d42..3387b7e6c9 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1190,6 +1190,11 @@ postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \ ifeq (yes,$(have-tunables)) $(eval $(call include_dsosort_tests,dso-sort-tests-1.def)) $(eval $(call include_dsosort_tests,dso-sort-tests-2.def)) + +# BZ15311 is intentionally underlinked. +LDFLAGS-tst-bz15311-b.so += -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-tst-bz15311-c.so += -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-tst-bz15311-d.so += -Wl,-z,lazy -Wl,-z,norelro endif check-abi: $(objpfx)check-abi-ld.out \ @@ -1514,6 +1519,20 @@ LDFLAGS-tst-initorderb2.so = -Wl,--no-as-needed LDFLAGS-tst-tlsmod5.so = -nostdlib -Wl,--no-as-needed LDFLAGS-tst-tlsmod6.so = -nostdlib -Wl,--no-as-needed +# The following tests are underlinked or rely on fixups being applied after a +# dlopen call. On toolchains that set -z now and -z relro by default, this +# leads to failures to load or fix up the executables being tested. +LDFLAGS-circlemod2.so = -Wl,-z,lazy +LDFLAGS-tst-tls20mod-bad.so = -Wl,-z,lazy +LDFLAGS-reldep6mod1.so += -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-constload2.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-constload3.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-dblloadmod3.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-ifuncmod6.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-ltglobmod2.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-testobj1.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-testobj6.so = -Wl,-z,lazy -Wl,-z,norelro + testobj1.so-no-z-defs = yes testobj3.so-no-z-defs = yes testobj4.so-no-z-defs = yes @@ -1612,6 +1631,7 @@ $(objpfx)multiload.out: $(objpfx)testobj1.so LDFLAGS-origtest = -rdynamic $(objpfx)origtest.out: $(objpfx)testobj1.so +$(objpfx)resolvfail.out: $(objpfx)testobj1.so ifeq ($(have-thread-library),yes) $(objpfx)resolvfail: $(shared-thread-library) endif @@ -2337,7 +2357,7 @@ LDFLAGS-tst-audit25a = -Wl,-z,lazy $(objpfx)tst-audit25mod1.so: $(objpfx)tst-audit25mod3.so LDFLAGS-tst-audit25mod1.so = -Wl,-z,now $(objpfx)tst-audit25mod2.so: $(objpfx)tst-audit25mod4.so -LDFLAGS-tst-audit25mod2.so = -Wl,-z,lazy +LDFLAGS-tst-audit25mod2.so = -Wl,-z,lazy -Wl,-z,norelro tst-audit25a-ARGS = -- $(host-test-program-cmd) $(objpfx)tst-audit25b.out: $(objpfx)tst-auditmod25.so diff --git a/nptl/Makefile b/nptl/Makefile index 8cec6faee3..140add412c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -569,7 +569,7 @@ $(objpfx)tst-compat-forwarder: $(objpfx)tst-compat-forwarder-mod.so tst-mutex10-ENV = GLIBC_TUNABLES=glibc.elision.enable=1 # Protect against a build using -Wl,-z,now. -LDFLAGS-tst-audit-threads-mod1.so = -Wl,-z,lazy +LDFLAGS-tst-audit-threads-mod1.so = -Wl,-z,lazy -Wl,-z,norelro LDFLAGS-tst-audit-threads-mod2.so = -Wl,-z,lazy LDFLAGS-tst-audit-threads = -Wl,-z,lazy $(objpfx)tst-audit-threads: $(objpfx)tst-audit-threads-mod2.so