[lsan] Fix stack buffer overwrite in SuspendedThreadsListMac::GetRegistersAndSP
authorKuba Mracek <mracek@apple.com>
Sat, 12 Nov 2022 18:16:34 +0000 (10:16 -0800)
committerKuba Mracek <mracek@apple.com>
Sat, 12 Nov 2022 18:17:52 +0000 (10:17 -0800)
commit32bada2edaf8a6ecb515925dda5e736783f5d8eb
tree256882117dd0f9b17990a2f7ab4cd10da3ef2f9f
parent5b0c21753bdb6dc5612028e92a249097ab509ea8
[lsan] Fix stack buffer overwrite in SuspendedThreadsListMac::GetRegistersAndSP

The call to the thread_get_state syscall (that fetches the register values for a thread) on arm64 is mistakenly claiming that the buffer to receive the register state is larger that its actual size on the stack -- the struct on the stack is arm_thread_state64_t, but the MACHINE_THREAD_STATE + MACHINE_THREAD_STATE_COUNT refer to the "unified arm state" struct (which is larger).

Fixes https://github.com/llvm/llvm-project/issues/58503.

Differential Revision: https://reviews.llvm.org/D137292
compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_mac.cpp