[hwasan] Fix Thread reuse (try 2).
authorEvgenii Stepanov <eugenis@google.com>
Thu, 12 Nov 2020 23:14:48 +0000 (15:14 -0800)
committerEvgenii Stepanov <eugenis@google.com>
Thu, 19 Nov 2020 00:04:08 +0000 (16:04 -0800)
commit523cc097fdafa1bb60373dcc70df7dfd31551f56
tree88bed414ce95991d31ea381b08aa7b4c797d9fa2
parent67f16e9e91f2f07cdb9813b60c195f5a1cd1f57d
[hwasan] Fix Thread reuse (try 2).

HwasanThreadList::DontNeedThread clobbers Thread::next_,
Breaking the freelist. As a result, only the top of the freelist ever
gets reused, and the rest of it is lost.

Since the Thread object with its associated ring buffer is only 8Kb, this is
typically only noticable in long running processes, such as fuzzers.

Fix the problem by switching from an intrusive linked list to a vector.

Differential Revision: https://reviews.llvm.org/D91392
compiler-rt/lib/hwasan/hwasan_thread.h
compiler-rt/lib/hwasan/hwasan_thread_list.h
compiler-rt/test/hwasan/TestCases/Linux/reuse-threads.cpp [new file with mode: 0644]
compiler-rt/test/hwasan/TestCases/thread-uaf.c