public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Fangrui Song <maskray@google.com>
Cc: libc-alpha@sourceware.org,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH] elf: Add __libc_get_static_tls_bounds [BZ #16291]
Date: Mon, 27 Sep 2021 15:02:53 +0200	[thread overview]
Message-ID: <877df2i32a.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20210925004227.1829014-1-maskray@google.com> (Fangrui Song's message of "Fri, 24 Sep 2021 17:42:27 -0700")

* Fangrui Song:

> Sanitizer runtimes need static TLS boundaries for a variety of use cases.
>
> * asan/hwasan/msan/tsan need to unpoison static TLS blocks to prevent false
>   positives due to reusing the TLS blocks with a previous thread.
> * lsan needs TCB for pointers into pthread_setspecific regions.
>
> See https://maskray.me/blog/2021-02-14-all-about-thread-local-storage
> for details.
>
> compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp GetTls has
> to infer the static TLS bounds from TP, _dl_get_tls_static_info, and
> hard-coded TCB sizes. Currently this is somewhat robust for
> aarch64/powerpc64/x86-64 but is brittle for many other architectures.
>
> This patch implements __libc_get_static_tls_bounds@@GLIBC_PRIVATE which
> is available in Android bionic since API level 31. This API allows the
> sanitizer code to be more robust. _dl_get_tls_static_info@@GLIBC_PRIVATE
> can probably be removed when Clang/GCC sanitizers drop reliance on it.
> I am unclear whether the version should be GLIBC_2.*.

Does this really cover the right memory region?  I assume LSAN needs
something that identifies pointers to malloc'ed memory that are stored
in non-malloc'ed (mmap'ed) memory.  The static TLS region is certainly a
place where such pointers can be stored.  But struct pthread also
contains other such pointers: the DTV, the TPP data, and POSIX TLS
(pthread_setspecific) data, and struct pthread is not obviously part of
the static TLS region.

Thanks,
Florian


  reply	other threads:[~2021-09-27 13:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-25  0:42 Fangrui Song
2021-09-27 13:02 ` Florian Weimer [this message]
2021-09-27 17:59   ` Fangrui Song
2021-10-06 20:23     ` Fangrui Song
2021-10-15  0:13       ` Fangrui Song
2021-10-19 19:37         ` Fāng-ruì Sòng
2021-10-28  5:16           ` Fāng-ruì Sòng
2021-11-29 19:30             ` Florian Weimer
2021-12-21  2:55               ` Fāng-ruì Sòng
2021-12-21  6:08                 ` Florian Weimer
2021-09-27 17:38 ` Joseph Myers
2021-09-27 17:47   ` 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=877df2i32a.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=maskray@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).