This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Reset current thread pointer on thread exit.
ClosedPublic

Authored by eugenis on May 7 2020, 4:27 PM.

Details

Summary

This is necessary to handle calls to free() after __hwasan_thread_exit,
which is possible in glibc.

Also, add a null check to GetCurrentThread, otherwise the logic in
GetThreadByBufferAddress turns it into a non-null value. This means that
all of the checks for GetCurrentThread() != nullptr do not have any
effect at all right now!

Diff Detail

Event Timeline

eugenis created this revision.May 7 2020, 4:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2020, 4:27 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
hctim accepted this revision.May 8 2020, 9:38 AM
hctim added inline comments.
compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c
22

nit: return 0;?

This revision is now accepted and ready to land.May 8 2020, 9:38 AM
eugenis updated this revision to Diff 262894.May 8 2020, 10:28 AM

fix the test

eugenis marked an inline comment as done.May 8 2020, 10:29 AM
eugenis added inline comments.
compiler-rt/test/hwasan/TestCases/libc_thread_freeres.c
22

not a nit - it's actually UB in C (but not in C++).
Fixed.

This revision was automatically updated to reflect the committed changes.