Commit Graph

6 Commits

Author SHA1 Message Date
Evgenii Stepanov 8a570a873b [hwasan] Support malloc in atfork.
Before this change we were locking the StackDepot in the fork()
interceptor. This results in a deadlock when allocator functions are
used in a pthread_atfork() callback.

Instead, set up a pthread_atfork() callback at init that locks/unlocks
both StackDepot and the allocator. Since our callback is set up very
early, the pre-fork callback is executed late, and both post-fork ones
are executed early, which works perfect for us.

Differential Revision: https://reviews.llvm.org/D108063
2021-08-17 15:29:49 -07:00
Leonard Chan b49a3bf7c0 [compiler-rt][hwasan][fuchsia] Implement TagMemoryAligned for fuchsia
This will just be a call into __sanitizer_fill_shadow defined in the fuchsia source tree. This depends on D105663.

Differential Revision: https://reviews.llvm.org/D105664
2021-07-26 16:28:08 -07:00
Leonard Chan 71af002d15 [compiler-rt][hwasan][fuchsia] Implement InitializeOsSupport
This is empty for now, but we will add a check that TBI is enabled once the
tagged pointer ABI for zircon is finalized. This depends on D105667.

Differential Revision: https://reviews.llvm.org/D105668
2021-07-26 16:04:59 -07:00
Leonard Chan b50fb58695 [compiler-rt][hwasan][fuchsia] Define shadow bound globals
These are required by MemIsShadow for checking if an address actually is shadow memory.

Differential Revision: https://reviews.llvm.org/D105745
2021-07-26 15:40:45 -07:00
Leonard Chan a11aea68a4 [compiler-rt][hwasan] Define fuchsia implementations of required hwasan functions
This contains all the definitions required by hwasan for the fuchsia
implementation and can be landed independently from the remaining parts of D91466.

Differential Revision: https://reviews.llvm.org/D103936
2021-07-08 10:24:27 -07:00
Leonard Chan 966386514b [compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia
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.

Differential Revision: https://reviews.llvm.org/D104085
2021-07-07 15:05:28 -07:00