[all-commits] [llvm/llvm-project] acf0a6: [sanitizer] Fix __sanitizer_kernel_sigset_t endian...

Ilya Leoshkevich via All-commits all-commits at lists.llvm.org
Thu Jul 15 03:19:19 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: acf0a6428681dccac803984bfbb1e3e54248f090
      https://github.com/llvm/llvm-project/commit/acf0a6428681dccac803984bfbb1e3e54248f090
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h

  Log Message:
  -----------
  [sanitizer] Fix __sanitizer_kernel_sigset_t endianness issue

setuid(0) hangs on SystemZ under TSan because TSan's BackgroundThread
ignores SIGSETXID. This in turn happens because internal_sigdelset()
messes up the mask bits on big-endian system due to how
__sanitizer_kernel_sigset_t is defined.

Commit d9a1a53b8d80 ("[ESan] [MIPS] Fix workingset-signal-posix.cpp on
MIPS") fixed this for MIPS by adjusting the __sanitizer_kernel_sigset_t
definition. Generalize this by defining __SANITIZER_KERNEL_NSIG based
on kernel's _NSIG and using uptr[] for __sanitizer_kernel_sigset_t.sig
on all platforms.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: 54128b73f8336ffe5cfd89cc860e58c3bb38a425
      https://github.com/llvm/llvm-project/commit/54128b73f8336ffe5cfd89cc860e58c3bb38a425
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

  Log Message:
  -----------
  [sanitizer] Force TLS allocation on s390

When running with an old glibc, CollectStaticTlsBlocks() calls
__tls_get_addr() in order to force TLS allocation. This function is not
available on s390 and the code simply does nothing in this case,
so all the resulting static TLS blocks end up being incorrect.

Fix by calling __tls_get_offset() on s390.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: cadbb9241627eefc9f589ae4376fd9ed3e272ecc
      https://github.com/llvm/llvm-project/commit/cadbb9241627eefc9f589ae4376fd9ed3e272ecc
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/rtl/tsan_rtl.cpp

  Log Message:
  -----------
  [TSan] Align thread_registry_placeholder

s390x requires ThreadRegistry.mtx_.opaque_storage_ to be 4-byte
aligned. Since other architectures may have similar requirements, use
the maximum thread_registry_placeholder alignment from other
sanitizers, which is 64 (LSan).

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: 3845f2cd940bd394fc735388ca0cd6652a98b7b9
      https://github.com/llvm/llvm-project/commit/3845f2cd940bd394fc735388ca0cd6652a98b7b9
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

  Log Message:
  -----------
  [TSan] Use zeroext for function parameters

SystemZ ABI requires zero-extending function parameters to 64-bit. The
compiler is free to optimize the code around this assumption, e.g.
failing to zero-extend __tsan_atomic32_load()'s morder may cause
crashes in to_mo() switch table lookup.

Fix by adding zeroext attributes to TSan's FunctionCallees, similar to
how it was done in commit 3bc439bdff8b ("[MSan] Add instrumentation for
SystemZ"). This is a no-op on arches that don't need it.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: d5c34ee5b666e12f92cf5b6e35490e1746fcc5e9
      https://github.com/llvm/llvm-project/commit/d5c34ee5b666e12f92cf5b6e35490e1746fcc5e9
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/test/tsan/ignore_lib0.cpp
    M compiler-rt/test/tsan/ignore_lib1.cpp
    M compiler-rt/test/tsan/ignore_lib5.cpp

  Log Message:
  -----------
  [TSan] Build ignore_lib{0,1,5} tests with -fno-builtin

These tests depend on TSan seeing the intercepted memcpy(), so they
break when the compiler chooses the builtin version.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: fab044045b63d59586caa09aa47892d0f7ce31d0
      https://github.com/llvm/llvm-project/commit/fab044045b63d59586caa09aa47892d0f7ce31d0
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

  Log Message:
  -----------
  [TSan] Define PTHREAD_ABI_BASE for SystemZ

SystemZ's glibc symbols use version 2.3.2.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: 96a29df0b166ed52806dfd01236c604c0eb8b7d1
      https://github.com/llvm/llvm-project/commit/96a29df0b166ed52806dfd01236c604c0eb8b7d1
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/rtl/tsan_platform.h
    M compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp

  Log Message:
  -----------
  [TSan] Define C/C++ address ranges for SystemZ

The kernel supports a full 64-bit VMA, but we can use only 48 bits due
to the limitation imposed by SyncVar::GetId(). So define the address
ranges similar to the other architectures, except that the address
space "tail" needs to be made inaccessible in CheckAndProtect(). Since
it's for only one architecture, don't make an abstraction for this.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: 402fc790eb484161866941cc840e20bdf5ae80e6
      https://github.com/llvm/llvm-project/commit/402fc790eb484161866941cc840e20bdf5ae80e6
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/CMakeLists.txt
    M compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
    A compiler-rt/lib/tsan/rtl/tsan_rtl_s390x.S
    M llvm/utils/gn/secondary/compiler-rt/lib/tsan/BUILD.gn

  Log Message:
  -----------
  [TSan] Add SystemZ longjmp support

Implement the interceptor and stack pointer demangling.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: b17673816d7f65e07015489993b22049e36b04db
      https://github.com/llvm/llvm-project/commit/b17673816d7f65e07015489993b22049e36b04db
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/rtl/tsan_interface.h

  Log Message:
  -----------
  [TSan] Disable __TSAN_HAS_INT128 on SystemZ

SystemZ does not have 128-bit atomics.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: bd77f742d656afa20faf9ce79b552e1ded4af5e5
      https://github.com/llvm/llvm-project/commit/bd77f742d656afa20faf9ce79b552e1ded4af5e5
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
    M compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

  Log Message:
  -----------
  [TSan] Intercept __tls_get_addr_internal and __tls_get_offset on SystemZ

Reuse the assembly glue code from sanitizer_common_interceptors.inc and
the handling logic from the __tls_get_addr interceptor.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: 937242cecc13f60c8e31ce8f936bfe218af42a90
      https://github.com/llvm/llvm-project/commit/937242cecc13f60c8e31ce8f936bfe218af42a90
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/test/tsan/map32bit.cpp
    M compiler-rt/test/tsan/mmap_large.cpp

  Log Message:
  -----------
  [TSan] Adjust tests for SystemZ

XFAIL map32bit, define the maximum possible allocation size in
mmap_large.cpp.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: e34078f121a58b503d225cf715d1494117e7948b
      https://github.com/llvm/llvm-project/commit/e34078f121a58b503d225cf715d1494117e7948b
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M clang/lib/Driver/ToolChains/Linux.cpp
    M compiler-rt/cmake/config-ix.cmake

  Log Message:
  -----------
  [TSan] Enable SystemZ support

Enable building the runtime and enable -fsanitize=thread in clang.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


  Commit: 9bf2e7eeebbd7524cfa3c448b40196fcd0a1a4cb
      https://github.com/llvm/llvm-project/commit/9bf2e7eeebbd7524cfa3c448b40196fcd0a1a4cb
  Author: Ilya Leoshkevich <iii at linux.ibm.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M compiler-rt/lib/tsan/CMakeLists.txt
    M compiler-rt/lib/tsan/go/buildgo.sh
    M compiler-rt/lib/tsan/rtl/tsan_platform.h
    M compiler-rt/test/tsan/CMakeLists.txt

  Log Message:
  -----------
  [TSan] Add SystemZ SANITIZER_GO support

Define the address ranges (similar to the C/C++ ones, but with the heap
range merged into the app range) and enable the sanity check.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629


Compare: https://github.com/llvm/llvm-project/compare/69a3acffdf1b...9bf2e7eeebbd


More information about the All-commits mailing list