From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id D09563858D39 for ; Mon, 6 Mar 2023 14:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D09563858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org References: <20230302112519.914641-1-arsen@gentoo.org> <87bklajbna.fsf@oldenburg.str.redhat.com> <86y1odlbss.fsf@gentoo.org> <86fsakz5mr.fsf@gentoo.org> <87bkl6xmta.fsf@oldenburg.str.redhat.com> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Arsen =?utf-8?Q?Arsenovi=C4=87?= To: Florian Weimer Cc: libc-alpha@sourceware.org, Carlos O'Donell , Gentoo Toolchain Subject: Re: [PATCH] elf,nptl: Add -z lazy -z norelro to tests that need it Date: Mon, 06 Mar 2023 15:17:35 +0100 In-reply-to: <87bkl6xmta.fsf@oldenburg.str.redhat.com> Message-ID: <87ttyym02j.fsf@gentoo.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Florian Weimer writes: > * Arsen Arsenovi=C4=87: > >> Arsen Arsenovi=C4=87 writes: >> >>> Hm. Something went awry while I was debugging this. I looked at a test >>> again just now and noticed that the symbols some of these tests were >>> crashing on came from libc (dlopen here) while loading constload2 (which >>> is dlopen'd from constload1). The backtrace contains a PLT trampoline >>> which then fixups dlopen inside the RELRO segment. >>> >>> I take it dlopen@got[plt] is not supposed to be in the RELRO range? >>> >>> I could have sworn this failed when fixing up bar (void) as a result of >>> constload2 dlopening constload3... but maybe that was a different >>> failure. >>> >>> Let's put this patch on hold while I investigate further. >>> >>> FWIW, this should be easy to reproduce by building with CC=3D'gcc >>> -Wl,-z,relro,-z,now' or so, I think. >> >> Ah, I think I see the issue: >> >> ~/gnu/glibc/b2$ diff -u0 shlib.lds.-Wl,-z,{lazy,now},-z,relro=20 >> --- shlib.lds.-Wl,-z,lazy,-z,relro 2023-03-04 19:54:42.977032934 +0100 >> +++ shlib.lds.-Wl,-z,now,-z,relro 2023-03-04 18:57:03.195010040 +0100 >> @@ -1 +1 @@ >> -/* Script for -shared -z combreloc -z separate-code */ >> +/* Script for -shared -z combreloc -z separate-code -z relro -z now */ >> @@ -153,3 +153,2 @@ >> - .got : { *(.got) *(.igot) } >> - . =3D DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >=3D 24 ? 24 : 0, .= ); >> - .got.plt : { *(.got.plt) *(.igot.plt) } >> + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } >> + . =3D DATA_SEGMENT_RELRO_END (0, .); >> ~/gnu/glibc/b2 1 $=20 >> >> The builds system assumes that all the flags used while building glibc >> use the same linker script, and that this will be the same linker script >> as the one that's used initially to generate shlib.lds. This is not >> true when -z relro is set and -z {now,lazy} are being varied. >> >> This also explains why the problem only arose after we introduced >> -Wl,-z,now. > > Interesting, thanks for looking into this. > > Does the issue go away if you configure with --enable-bind-now? > > That's what we are doing, and we don't see those test failures. From=20a brief look, it would seem to still leave some failures which might be related (specifically the relro hardening tests). I haven't investigated. A patchset by Adhemerval seems to remove the linker script altogether piqued my interest. I'll test his patch on our toolchain, I suspect that it removes this problem altogether. I'll keep you posted. https://inbox.sourceware.org/libc-alpha/20221227211145.3765256-1-adhemerval= .zanella@linaro.org/ Thanks, have a lovely day. =2D-=20 Arsen Arsenovi=C4=87 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iIcEARYKAC8WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCZAX3JBEcYXJzZW5AZ2Vu dG9vLm9yZwAKCRBSwpQwHqLEkxG4APsGcR2QnRddjjGhZyUTG8DOcVYG7aB5U1hd EdlqnN6KwwD/VS3jmpHo84/ZZQtgUPmPEkGOcSSv7BNsvQ/n4zKI1wg= =sCWT -----END PGP SIGNATURE----- --=-=-=--