[PATCH] D40159: Correct handling of the TLS/NetBSD block of the main program

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 1 20:28:25 PST 2021


MaskRay added a comment.
Herald added subscribers: delcypher, arichardson.

@krytarowski I think this patch may be incorrect.

On TLS Variant I (i386, x86-64), `static TLS blocks ... tp tcb`

Notable users of GetTls:

- asan calls `ClearShadowForThreadStackAndTLS` to mark the TLS block addressable.
- lsan calls `ScanRangeForPointers` on the TLS block to find reachable chunks.
- msan and tsan's `__tls_get_addr` interceptors unpoison/reset dtv ranges to avoid false positives
- A glibc workaround (D93866 <https://reviews.llvm.org/D93866>): I suspect it is no longer needed, but I'll confirm with glibc dev.

The size should be the total size of static TLS blocks (including the sizeof of TCB, (`struct pthread` on musl), (including `tcbhead_t` on glibc))), not just p_memsz of the executable PT_TLS.

The FreeBSD definition is quite correct, though it does not include the sizeof of TCB. For the users of GetTls, not including the sizeof of TCB probably does not matter (writes of the TCB members are not instrumented by asan/lsan/msan/tsan).


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D40159/new/

https://reviews.llvm.org/D40159



More information about the llvm-commits mailing list