[sanitizer] Fix __sanitizer_kernel_sigset_t endianness issue
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 2 Jul 2021 00:42:38 +0000 (02:42 +0200)
committerIlya Leoshkevich <iii@linux.ibm.com>
Thu, 15 Jul 2021 10:18:46 +0000 (12:18 +0200)
commitacf0a6428681dccac803984bfbb1e3e54248f090
treecd23c2695e4f63666b6fe9982dabd013f3e03ead
parent69a3acffdf1b3f5fc040aaeafc1c77588a607d1a
[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
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h