[all-commits] [llvm/llvm-project] 5c205b: [safestack] Various Solaris fixes (#98469)

Rainer Orth via All-commits all-commits at lists.llvm.org
Thu Jul 11 05:06:06 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5c205b6f7d82ee88ee5a869d6102c5a6388fb3f0
      https://github.com/llvm/llvm-project/commit/5c205b6f7d82ee88ee5a869d6102c5a6388fb3f0
  Author: Rainer Orth <ro at gcc.gnu.org>
  Date:   2024-07-11 (Thu, 11 Jul 2024)

  Changed paths:
    M compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
    M compiler-rt/lib/safestack/CMakeLists.txt
    M compiler-rt/lib/safestack/safestack.cpp
    M compiler-rt/lib/safestack/safestack_platform.h
    M compiler-rt/test/safestack/lit.cfg.py

  Log Message:
  -----------
  [safestack] Various Solaris fixes (#98469)

Even with the `-u __safestack_init` link order fixed on Solaris, there
are still several safestack test issues left:

* While 540fd42c755f20f7b79c6c79493ec36d8cb9b3d3 enabled safestack on
Solaris in the driver unconditionally, it ignored that Solaris also
exists on SPARC and forgot to enable SPARC support for the runtime lib.
This patch fixes that.

- The tests fail to link with undefined references to
`__sanitizer_internal_memset` etc. These are from
`sanitizer_redefine_builtins.h`. Definitions live in
`sanitizer_libc.cpp.o`. This patch adds them to the safestack runtime
lib as is already the case e.g. for asan and ubsan. Why GNU ld allows
the link to complete with those references undefined is beyond me.

- The `pthread*.c` tests `FAIL` with

``` safestack CHECK failed:
/vol/llvm/src/llvm-project/local/compiler-rt/lib/safestack/safestack.cpp:227
size ```

The problem is that `pthread_attr_init` initializes the `stacksize`
attribute to 0, signifying the default. Unless explicitly overridded, it
stays that way. I think this is allowed by XPG7. Since safestack cannot
deal with this, I set `size` to the defaults documented in
`pthread_create(3C)`. Unfortunately, there's no macro for those values
outside of private `libc` headers.

- The Solaris `syscall` interface isn't stable. This is not just a
theoretical concern, but the syscalls have changed incompatibly several
times in the past. Therefore this patch switches the implementations of
`TgKill` (where `SYS_lwp_kill` doesn't exist on Solaris 11.4 anyway),
`Mmap`, `Munmap`, and `Mprotect` to the same `_REAL*` solution already
used in `sanitizer_solaris.cpp`. Instead of duplicating what's already
in `sanitizer_common`, it seems way better to me to just reuse those
implementations, though. A subsequent patch does just that.

With those changes, safestack compiles and all tests `PASS`, so the
tests are re-enabled for good.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`,
`x86_64-pc-linux-gnu`, and `sparc64-unknown-linux-gnu`.



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