llvm-project/compiler-rt/lib/msan
Fangrui Song 9be8f8b34d [sanitizer] Simplify GetTls with dl_iterate_phdr
GetTls is the range of

* thread control block and optional TLS_PRE_TCB_SIZE
* static TLS blocks plus static TLS surplus

On glibc, lsan requires the range to include
`pthread::{specific_1stblock,specific}` so that allocations only referenced by
`pthread_setspecific` can be scanned.

This patch uses `dl_iterate_phdr` to collect TLS ranges. Find the one
with `dlpi_tls_modid==1` as one of the initially loaded module, then find
consecutive ranges. The boundaries give us addr and size.

This allows us to drop the glibc internal `_dl_get_tls_static_info` and
`InitTlsSize` entirely. Use the simplified method with non-Android Linux for
now, but in theory this can be used with *BSD and potentially other ELF OSes.

In the future, we can move `ThreadDescriptorSize` code to lsan (and consider
intercepting `pthread_setspecific`) to avoid hacks in generic code.

See https://reviews.llvm.org/D93972#2480556 for analysis on GetTls usage
across various sanitizers.

Differential Revision: https://reviews.llvm.org/D98926
2021-03-25 21:55:27 -07:00
..
tests [sanitizer] Fix msan test build on FreeBSD after 7afdc89c20 2021-01-28 23:54:04 +01:00
.clang-format [sanitizer] Remove unneeded blank lines 2018-05-09 00:44:26 +00:00
CMakeLists.txt [msan] Blacklist __gxx_personality_v0. 2019-10-31 10:22:52 -07:00
msan.cpp [sanitizer] Simplify GetTls with dl_iterate_phdr 2021-03-25 21:55:27 -07:00
msan.h [MSan] Enable for SystemZ 2020-04-16 12:15:01 +02:00
msan.syms.extra
msan_allocator.cpp [MSan] Enable for SystemZ 2020-04-16 12:15:01 +02:00
msan_allocator.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
msan_blacklist.txt [msan] Blacklist __gxx_personality_v0. 2019-10-31 10:22:52 -07:00
msan_chained_origin_depot.cpp [sanitizer] Move MSan's chained_origin_depot to sanitizer_common 2021-02-11 01:25:56 +00:00
msan_chained_origin_depot.h [sanitizer] Move MSan's chained_origin_depot to sanitizer_common 2021-02-11 01:25:56 +00:00
msan_flags.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
msan_flags.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
msan_interceptors.cpp [sanitizers] Fix interception of GLibc regexec 2021-03-08 10:53:55 +00:00
msan_interface_internal.h [sanitizers] Remove unneeded MaybeCall*DefaultOptions() and nullptr checks 2020-09-08 10:12:05 -07:00
msan_linux.cpp [msan] Delete unused glibc header <execinfo.h> 2020-12-27 21:59:23 -08:00
msan_new_delete.cpp Remove NOLINTs from compiler-rt 2019-09-11 23:19:48 +00:00
msan_origin.h [msan] Fix comment of __msan::Origin::isHeapOrigin 2020-06-14 23:58:49 -07:00
msan_poisoning.cpp [msan] Use non-transparent-huge-page at SetShadow 2021-02-27 00:28:57 +00:00
msan_poisoning.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
msan_report.cpp compiler-rt: Rename .cc file in lib/msan to .cpp 2019-08-01 14:08:18 +00:00
msan_report.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
msan_thread.cpp [NFC] Extract ForEachDVT 2020-12-01 16:15:32 -08:00
msan_thread.h [MSAN] Add fiber switching APIs 2020-08-27 19:30:40 -07:00