diff options
author | Alex Richardson <alexrichardson@google.com> | 2024-03-07 23:36:30 -0800 |
---|---|---|
committer | Alex Richardson <alexrichardson@google.com> | 2024-03-07 23:36:30 -0800 |
commit | 005b726b8fc4a73821c5725cb83dfd0d289c82ca (patch) | |
tree | b16b2cc0323c71d22db3df7be40cbfb0a6fcfb8c | |
parent | bfa6444a332f82843f9fa44821d68fcc772e0272 (diff) |
[𝘀𝗽𝗿] initial versionupstream/users/arichardson/spr/compiler-rt-map-internal_sigaction-to-__sys_sigaction-on-freebsd
Created using spr 1.3.6-beta.1
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp index cccbb4d256df..6d05411222d9 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp @@ -54,6 +54,8 @@ # undef MAP_NORESERVE # define MAP_NORESERVE 0 extern const Elf_Auxinfo *__elf_aux_vector; +extern "C" int __sys_sigaction(int signum, const struct sigaction *act, + struct sigaction *oldact); # endif # if SANITIZER_NETBSD @@ -93,12 +95,22 @@ SANITIZER_WEAK_ATTRIBUTE int real_sigaction(int signum, const void *act, void *oldact); int internal_sigaction(int signum, const void *act, void *oldact) { -# if !SANITIZER_GO +# if SANITIZER_FREEBSD + // On FreeBSD, call the sigaction syscall directly (part of libsys in FreeBSD + // 15) since the libc version goes via a global interposing table. Due to + // library initialization order the table can be relocated after the call to + // InitializeDeadlySignals() which then crashes when dereferencing the + // uninitialized pointer in libc. + return __sys_sigaction(signum, (const struct sigaction *)act, + (struct sigaction *)oldact); +# else +# if !SANITIZER_GO if (&real_sigaction) return real_sigaction(signum, act, oldact); -# endif +# endif return sigaction(signum, (const struct sigaction *)act, (struct sigaction *)oldact); +# endif } void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, |