[PATCH] D104085: [compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 10 18:27:12 PDT 2021


leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr.
leonardchan added a project: Sanitizers.
Herald added subscribers: jfb, mgorny, dberris.
leonardchan requested review of this revision.
Herald added a subscriber: Sanitizers.

This patch splits up hwasan thread creation between `__sanitizer_before_thread_create_hook`, `__sanitizer_thread_create_hook`, and `__sanitizer_thread_start_hook`. The linux implementation creates the hwasan thread object inside the new thread. On Fuchsia, we know the stack bounds before thread creation, so we can initialize part of the thread object in `__sanitizer_before_thread_create_hook`, then initialize the stack ring buffer in `__sanitizer_thread_start_hook` once we enter the thread.

Some refactoring:

- Move `Thread::Init` from `hwasan_thread.cpp` into `hwasan_linux.cpp` and `hwasan_fuchsia.cpp` so they can have separate implementations. The linux implementation uses the same logic of making hwasan thread object while in the thread itself. The fuchsia implementation separates this into two functions: one for initializing tls, stack, and heap_allocation members; and one for initializing the stack ring buffer once we enter the thread.
- `Thread::Init` accepts an optional `InitOptions` struct pointer which will initialize a hwasan thread from miscellaneous parameters. In the fuchsia implementation, this is just the stack bounds.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104085

Files:
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan.cpp
  compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
  compiler-rt/lib/hwasan/hwasan_linux.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp
  compiler-rt/lib/hwasan/hwasan_thread.h
  compiler-rt/lib/hwasan/hwasan_thread_list.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104085.351313.patch
Type: text/x-patch
Size: 15842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210611/c66e92b4/attachment-0001.bin>


More information about the cfe-commits mailing list