public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Fangrui Song <maskray@google.com>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: "Cristian Rodríguez" <cristian@rodriguez.im>,
	"H.J. Lu" <hjl.tools@gmail.com>,
	"Florian Weimer" <fweimer@redhat.com>,
	libc-alpha@sourceware.org, "Vitaly Buka" <vitalybuka@google.com>,
	"Fangrui Song" <i@maskray.me>,
	"Evgenii Stepanov" <eugenis@google.com>,
	"Kostya Serebryany" <kcc@google.com>,
	"Dmitry Vyukov" <dvyukov@google.com>
Subject: Re: [PATCH] aarch64: Remove ld.so __tls_get_addr plt usage
Date: Wed, 10 Apr 2024 08:29:16 +0100	[thread overview]
Message-ID: <ZhY/zIkjSDhtKNes@arm.com> (raw)
In-Reply-To: <CAFP8O3+rzjfPrMt_rquq4c9tgGBzh8qHuMVsTPTh-PaKPAQ12g@mail.gmail.com>

The 04/09/2024 10:50, Fangrui Song wrote:
> On Tue, Apr 9, 2024 at 7:03 AM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
> > On 09/04/24 05:30, Szabolcs Nagy wrote:
> > > The 04/08/2024 13:57, Adhemerval Zanella Netto wrote:
> > >> On 08/04/24 04:26, Szabolcs Nagy wrote:
> > >>> i know sanitizers interpose __tls_get_addr, because
> > >>> https://sourceware.org/bugzilla/show_bug.cgi?id=16291
> > >>> i don't know if that hack works at all now for tlsdesc
> > >>> (where the ld.so calls __tls_get_addr, not user code)
> > >>>
> > >>> my question was if we investigated this issue since it
> > >>> is useful to document then in the commit msg (or news
> > >>> entry if this affects users)
> > >>
> > >> This change 'breaks' the sanitizer trick to get the dynamic TLS, with
> > >> this patch I now see:
> > >>
> > >>   MemorySanitizer-AARCH64 :: dtls_test.c
> > >>   SanitizerCommon-asan-aarch64-Linux :: Linux/resize_tls_dynamic.cpp
> > >>   SanitizerCommon-msan-aarch64-Linux :: Linux/resize_tls_dynamic.cpp
> > >>   SanitizerCommon-tsan-aarch64-Linux :: Linux/resize_tls_dynamic.cpp
> > >>
> > >> And it does not fail on x86 only because it uses -mtls=gnu as default
> > >> (the same tests fail on x86 with -mtls=gnu2).
> > >>
> > >> Now that GCC and distributions are aiming to use GNU2/DESC as the
> > >> default TLS, this hack will also break on x86.  So the question is
> > >> whether we revert 050f7298e1ecc39887c329037575ccd972071255 and
> > >> document that __tls_get_addr should be interposable, or move with this
> > >> change and try to come up with a possible solution for BZ#16291.
> > >>
> > >> I bringing this because we will have another two ABIs with tlsdesc
> > >> support (loongarch and riscv).
> 
> Last time I analyzed the __tls_get_addr interceptor in sanitizers, I
> have made quite some notes at
> https://maskray.me/blog/2021-02-14-all-about-thread-local-storage#why-does-compiler-rt-need-to-know-tls-blocks

says

> Note: aarch64 uses TLSDESC by default and there is no interposable symbol.

not quite true: the tlsdesc call cannot be interposed, but then
ld.so internally calls __tls_get_addr via a PLT that can be.
(only for first time dynamic tls setup, but that's enough to
get dynamic tls boundaries)

you need another way to detect the static tls area, but that's
true for non-tlsdesc too.

> Current TLSDESC implementations not providing an interposable symbol
> is indeed an issue, but I haven't carefully analyzed it on an aarch64
> machine.

we are planning to remove the interposable symbol in the
next glibc version, so the current __tls_get_addr trick
won't work for x86_64, aarch64, loongarch, riscv.


  reply	other threads:[~2024-04-10  7:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 12:35 Adhemerval Zanella
2024-04-05 14:58 ` Szabolcs Nagy
2024-04-05 16:29   ` Adhemerval Zanella Netto
2024-04-06 17:40     ` Szabolcs Nagy
2024-04-08  8:04       ` Florian Weimer
2024-04-07 20:29   ` Cristian Rodríguez
2024-04-08  7:26     ` Szabolcs Nagy
2024-04-08 16:57       ` Adhemerval Zanella Netto
2024-04-09  8:30         ` Szabolcs Nagy
2024-04-09 14:03           ` Adhemerval Zanella Netto
2024-04-09 14:05             ` H.J. Lu
2024-04-09 14:11             ` Palmer Dabbelt
2024-04-09 14:46               ` H.J. Lu
2024-04-09 17:50             ` Fangrui Song
2024-04-10  7:29               ` Szabolcs Nagy [this message]
2024-04-10  8:23               ` Florian Weimer
2024-04-10 15:46                 ` enh
2024-04-15 11:41                   ` Florian Weimer
2024-04-15 20:22                 ` Adhemerval Zanella Netto

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=ZhY/zIkjSDhtKNes@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=cristian@rodriguez.im \
    --cc=dvyukov@google.com \
    --cc=eugenis@google.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=i@maskray.me \
    --cc=kcc@google.com \
    --cc=libc-alpha@sourceware.org \
    --cc=maskray@google.com \
    --cc=vitalybuka@google.com \
    /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).