[all-commits] [llvm/llvm-project] 249db5: [nsan] Add NsanThread and clear static TLS shadow

Fangrui Song via All-commits all-commits at lists.llvm.org
Sun Aug 11 10:53:39 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 249db518e324f8658bf5b2c0e3c0a1ee789d784b
      https://github.com/llvm/llvm-project/commit/249db518e324f8658bf5b2c0e3c0a1ee789d784b
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-08-11 (Sun, 11 Aug 2024)

  Changed paths:
    M compiler-rt/lib/nsan/CMakeLists.txt
    M compiler-rt/lib/nsan/nsan.cpp
    M compiler-rt/lib/nsan/nsan_interceptors.cpp
    A compiler-rt/lib/nsan/nsan_thread.cpp
    A compiler-rt/lib/nsan/nsan_thread.h
    A compiler-rt/test/nsan/Posix/tls_reuse.c

  Log Message:
  -----------
  [nsan] Add NsanThread and clear static TLS shadow

On thread creation, asan/hwasan/msan/tsan unpoison the thread stack and
static TLS blocks in case the blocks reuse previously freed memory that
is possibly poisoned. glibc nptl/allocatestack.c allocates thread stack
using a hidden, non-interceptable function.

nsan is similar: the shadow types for the thread stack and static TLS
blocks should be set to unknown, otherwise if the static TLS blocks
reuse previous shadow memory, and `*p += x` instead of `*p = x` is used
for the first assignment, the mismatching user and shadow memory could
lead to false positives.

NsanThread is also needed by the next patch to use the sanitizer
allocator.

Pull Request: https://github.com/llvm/llvm-project/pull/102718



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list