From: Florian Weimer <fweimer@redhat.com>
To: Andreas Schwab <schwab@suse.de>
Cc: Roland McGrath <roland@hack.frob.com>,
Joseph Myers <joseph@codesourcery.com>,
libc-alpha@sourceware.org
Subject: _rtld_global_ro and static dlopen (was: Re: Pending fixes for all-ABIs builds)
Date: Thu, 10 Nov 2016 16:30:00 -0000 [thread overview]
Message-ID: <a4385b78-a3d4-4919-0321-50251fe217ad@redhat.com> (raw)
In-Reply-To: <mvm4m3fbs68.fsf@hawking.suse.de>
On 11/10/2016 10:27 AM, Andreas Schwab wrote:
> On Nov 10 2016, Florian Weimer <fweimer@redhat.com> wrote:
>
>> Could we put this information into rtld_global_ro, instead of having a
>> separate variable? (Assuming that rtld_global_ro is indeed in read-only
>> memory after relocation.)
>
> It cannot be read-only, it is set only after ld.so is initialized.
I know that glibc has trouble with multiple definitions, but at least
one copy of _rtld_global_ro *is* read-only after relocation:
(gdb) print memset (&_rtld_global_ro, 1, 1)
Program received signal SIGSEGV, Segmentation fault.
__memset_sse2 () at ../sysdeps/x86_64/memset.S:110
110 movb %cl, (%rdi)
It also contains a function pointer to _dl_lookup_symbol_x, so I think
this data structure should work for locating ld.so functions.
Is the problem that we determine too late that we are running in a
nested configuration, and the inner ld.so has already been relocated?
Maybe gdb is lying to me, but it seems that we run the inner libc.so
with a _rtld_global_ro which has not been initialized beyond what is in
the default initializer. It seems that dl_main never runs.
But this means that most uses of GLRO inside libc.so.6 are broken. And
indeed, GLRO (dl_auxv) does not work as intended, and results in a NULL
pointer dereference in getauxval:
https://sourceware.org/bugzilla/show_bug.cgi?id=20802
How can we fix this? Could we synthesize a link map which interposes
the necessary definitions?
Thanks,
Florian
prev parent reply other threads:[~2016-11-10 16:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 23:25 Pending fixes for all-ABIs builds Joseph Myers
2016-11-08 8:28 ` Florian Weimer
2016-11-08 23:22 ` Joseph Myers
2016-11-09 8:14 ` Florian Weimer
2016-11-09 8:18 ` Joseph Myers
2016-11-09 9:01 ` Andreas Schwab
2016-11-09 11:56 ` Florian Weimer
2016-11-09 13:26 ` Andreas Schwab
2016-11-09 13:39 ` Florian Weimer
2016-11-09 13:47 ` Andreas Schwab
2016-11-09 13:52 ` Florian Weimer
2016-11-09 14:50 ` Andreas Schwab
2016-11-09 14:54 ` Florian Weimer
2016-11-09 22:00 ` Roland McGrath
2016-11-10 7:58 ` Florian Weimer
2016-11-10 9:28 ` Andreas Schwab
2016-11-10 16:30 ` Florian Weimer [this message]
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=a4385b78-a3d4-4919-0321-50251fe217ad@redhat.com \
--to=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=roland@hack.frob.com \
--cc=schwab@suse.de \
/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).