public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Arsen Arsenović" <arsen@gentoo.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org, Carlos O'Donell <carlos@redhat.com>,
	Gentoo Toolchain <toolchain@gentoo.org>
Subject: Re: [PATCH] elf,nptl: Add -z lazy -z norelro to tests that need it
Date: Mon, 06 Mar 2023 15:17:35 +0100	[thread overview]
Message-ID: <87ttyym02j.fsf@gentoo.org> (raw)
In-Reply-To: <87bkl6xmta.fsf@oldenburg.str.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2778 bytes --]


Florian Weimer <fweimer@redhat.com> writes:

> * Arsen Arsenović:
>
>> Arsen Arsenović <arsen@gentoo.org> 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='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 
>>   --- 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) }
>>   -  . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
>>   -  .got.plt        : { *(.got.plt) *(.igot.plt) }
>>   +  .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
>>   +  . = DATA_SEGMENT_RELRO_END (0, .);
>>   ~/gnu/glibc/b2 1 $ 
>>
>> 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 a 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.
-- 
Arsen Arsenović

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

  reply	other threads:[~2023-03-06 14:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 11:25 Arsen Arsenović
2023-03-03 11:51 ` Florian Weimer
2023-03-03 21:54   ` Arsen Arsenović
2023-03-04 17:46     ` Arsen Arsenović
2023-03-06  9:15       ` Florian Weimer
2023-03-06 14:17         ` Arsen Arsenović [this message]
2023-03-06 16:42           ` Arsen Arsenović

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttyym02j.fsf@gentoo.org \
    --to=arsen@gentoo.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=toolchain@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).