From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH] hurd: Fix early rtld access to errno
Date: Sun, 18 Mar 2018 02:07:00 -0000 [thread overview]
Message-ID: <20180318020712.mks5ijnqzkugxgec@var.youpi.perso.aquilenet.fr> (raw)
In-Reply-To: <20180318015332.9759-1-samuel.thibault@ens-lyon.org>
Samuel Thibault, on dim. 18 mars 2018 02:53:32 +0100, wrote:
> * sysdeps/generic/dl-sysdep.h (RTLD_EXTERN_ERRNO): Define macro to 0.
> * sysdeps/mach/hurd/i386/dl-sysdep.h: Include <dl-sysdep.h>.
> [IS_IN(rtld)] (RTLD_EXTERN_ERRNO): Define macro to 1.
> [!IS_IN(rtld)] (RTLD_EXTERN_ERRNO): Define macro to 0.
> * include/errno.h [IS_IN(rtld) && !defined RTLD_EXTERN_ERRNO]: Error
> out.
> [!IS_IN(rtld)] (RTLD_EXTERN_ERRNO): Define to 0.
> [RTLD_EXTERN_ERRNO]: Do not use TLS access to errno.
All that being said, I'm surprised: AIUI this problem would be the
same on all platforms as soon as one would set RTLD_PRIVATE_ERRNO to
0.
Trying to set RTLD_PRIVATE_ERRNO to 0 on Linux x86_64 for instance,
ld.so crashes in
assert (info[DT_FLAGS] == NULL
|| (info[DT_FLAGS]->d_un.d_val & ~DF_BIND_NOW) == 0);
since __thread access produces DF_STATIC_TLS. Ignoring that check just
pushes the crash to open_verify()'s __set_errno call, on fs:(%eax) or
fs:0 access (depending whether initial-exec TLS model is enabled or
not). I guess that at that point Linux x86_64 hasn't initialized %fs
yet. I tried to just disable the use of __thread access to errno in
rtld with
> @@ -20,7 +24,7 @@
> # define errno rtld_errno
> extern int rtld_errno attribute_hidden;
>
> -# elif IS_IN_LIB
> +# elif IS_IN_LIB && !IS_IN(rtld)
>
> # include <tls.h>
>
But that's only pushing the issue to the __errno_location()
function. In sysdeps/mach/hurd/errno-loc.c I made the rtld version of
__errno_location() a weak function which avoids accessing TLS by using
a static variable, that function being overriden by libc as soon as it
gets loaded. I'm actually wondering why not all archs would need this
when RTLD_PRIVATE_ERRNO is 0.
Samuel
next prev parent reply other threads:[~2018-03-18 2:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-18 1:53 Samuel Thibault
2018-03-18 2:07 ` Samuel Thibault [this message]
2018-03-19 9:22 ` Florian Weimer
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=20180318020712.mks5ijnqzkugxgec@var.youpi.perso.aquilenet.fr \
--to=samuel.thibault@ens-lyon.org \
--cc=libc-alpha@sourceware.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).