[PATCH] D128387: [hwasan] Add __hwasan_record_frame_record to the hwasan interface
Leonard Chan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 22 15:27:32 PDT 2022
leonardchan created this revision.
leonardchan added reviewers: mcgrathr, vitalybuka, eugenis.
leonardchan added a project: Sanitizers.
Herald added subscribers: Enna1, hiraditya.
Herald added a project: All.
leonardchan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Hwasan includes instructions in the prologue that mix the PC and SP and store it into the stack ring buffer stored at `__hwasan_tls`. This is a thread_local global exposed from the hwasan runtime. However, if TLS-mechanisms or the hwasan runtime haven't been setup yet, it will be invalid to access `__hwasan_tls`. This is the case for Fuchsia where we instrument libc, so some functions that are instrumented but can run before hwasan initialization will incorrectly access this global. Additionally, libc cannot have any TLS variables, so we cannot weakly define `__hwasan_tls` until the runtime is loaded.
A way we can work around this is by moving the instructions into a hwasan function that does the store into the ring buffer and creating a weak definition of that function locally in libc. This way `__hwasan_tls` will not actually be referenced. This is not our long-term solution, but this will allow us to roll out hwasan in the meantime.
This patch includes:
- Some refactoring to the hwasan pass
- A new llvm flag for choosing to emit a libcall rather than instructions in the prologue (off by default)
- The libcall for storing into the ringbuffer (`__hwasan_record_frame_record`)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128387
Files:
compiler-rt/lib/hwasan/hwasan.cpp
compiler-rt/lib/hwasan/hwasan_interface_internal.h
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128387.439172.patch
Type: text/x-patch
Size: 8279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220622/2b1ffe4b/attachment.bin>
More information about the llvm-commits
mailing list