summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/hwasan/hwasan_thread.cc
Commit message (Collapse)AuthorAgeFilesLines
* hwasan: Rename source files from cc to cppNico Weber2019-02-271-122/+0
| | | | | | | | | | | | | | | | | | | As discussed elsewhere: LLVM uses cpp as its C++ source extension; the sanitizers should too. This updates files in hwasan. Patch generated by for f in lib/hwasan/*.cc ; do svn mv $f ${f%.cc}.cpp; done followed by for f in lib/hwasan/*.cpp ; do sed -i '' -e '1s/\.cc -/.cpp /' $f; done CMakeLists.txt updated manually. Differential Revision: https://reviews.llvm.org/D58620 llvm-svn: 354989
* hwasan: Add __hwasan_init_static() function.Peter Collingbourne2019-01-311-1/+4
| | | | | | | | | | | This function initializes enough of the runtime to be able to run instrumented code in a statically linked executable. It replaces __hwasan_shadow_init() which wasn't doing enough initialization for instrumented code that uses either TLS or IFUNC to work. Differential Revision: https://reviews.llvm.org/D57490 llvm-svn: 352816
* [asan] Support running without /procEvgeniy Stepanov2019-01-081-17/+8
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: vitalybuka, pcc, krytarowski Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56141 llvm-svn: 350590
* Revert "[asan] Support running without /proc.", +1Evgeniy Stepanov2018-12-281-1/+1
| | | | | | | | | Revert r350104 "[asan] Fix build on windows." Revert r350101 "[asan] Support running without /proc." These changes break Mac build, too. llvm-svn: 350112
* [asan] Support running without /proc.Evgeniy Stepanov2018-12-271-1/+1
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55874 llvm-svn: 350101
* [hwasan] Record and display stack history in stack-based reports.Evgeniy Stepanov2018-09-241-84/+32
| | | | | | | | | | | | | | | | | | | | | Summary: Display a list of recent stack frames (not a stack trace!) when tag-mismatch is detected on a stack address. The implementation uses alignment tricks to get both the address of the history buffer, and the base address of the shadow with a single 8-byte load. See the comment in hwasan_thread_list.h for more details. Developed in collaboration with Kostya Serebryany. Reviewers: kcc Subscribers: srhines, kubamracek, mgorny, hiraditya, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D52249 llvm-svn: 342923
* Revert "[hwasan] Record and display stack history in stack-based reports."Evgeniy Stepanov2018-09-241-32/+84
| | | | | | This reverts commit r342921: test failures on clang-cmake-arm* bots. llvm-svn: 342922
* [hwasan] Record and display stack history in stack-based reports.Evgeniy Stepanov2018-09-241-84/+32
| | | | | | | | | | | | | | | | | | | | | Summary: Display a list of recent stack frames (not a stack trace!) when tag-mismatch is detected on a stack address. The implementation uses alignment tricks to get both the address of the history buffer, and the base address of the shadow with a single 8-byte load. See the comment in hwasan_thread_list.h for more details. Developed in collaboration with Kostya Serebryany. Reviewers: kcc Subscribers: srhines, kubamracek, mgorny, hiraditya, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D52249 llvm-svn: 342921
* [hwasan] change the thread list so that main_thread can also be removedKostya Serebryany2018-09-071-6/+10
| | | | llvm-svn: 341610
* [hwasan] fix pthread_exitKostya Serebryany2018-09-061-1/+1
| | | | llvm-svn: 341594
* [hwasan] introduce __hwasan_print_memory_usageKostya Serebryany2018-09-061-3/+15
| | | | llvm-svn: 341592
* [hwasan] when verbose_threads==1, print the memory usage per threadKostya Serebryany2018-09-051-1/+6
| | | | llvm-svn: 341507
* [hwasan] simplify the code, NFCKostya Serebryany2018-09-051-1/+1
| | | | llvm-svn: 341501
* [hwasan] print thread IDs when reporting a bug (also had to fix ↵Kostya Serebryany2018-09-051-6/+7
| | | | | | pthread_create on Linux) llvm-svn: 341438
* [hwasan] simplify the code, NFCKostya Serebryany2018-09-051-6/+4
| | | | llvm-svn: 341432
* [hwasan] remove stale Thread:: data members. While doing so noticed that ↵Kostya Serebryany2018-09-041-6/+9
| | | | | | GetThreadStackAndTls was always called with 'at_initialization=true', fixed that. llvm-svn: 341431
* [hwasan] add a unique id to a thread and add debug prints for thread ↵Kostya Serebryany2018-09-041-0/+11
| | | | | | creation/destruction llvm-svn: 341428
* [hwasan] use thread-local ring buffers to properly report heap-use-after-freeKostya Serebryany2018-08-301-2/+2
| | | | llvm-svn: 341133
* [hwasan] simplify the thread hangling: instead of the ThreadRegistry (too ↵Kostya Serebryany2018-08-301-35/+35
| | | | | | heavy) simply maintain a linked list of Threads llvm-svn: 341111
* [hwasan] add basic ThreadRegistry plumbing, also rename HwasanThread to ThreadKostya Serebryany2018-08-301-10/+42
| | | | llvm-svn: 341005
* [hwasan] get rid of some macros, remove the fixed shadow mappingKostya Serebryany2018-08-291-4/+4
| | | | llvm-svn: 340983
* Add a thread-local ring buffer of heap allocationsKostya Serebryany2018-08-291-1/+4
| | | | | | | | | | | | | | | | | | Summary: We need this in order to properly report heap-use-after-free, since we don't have a quarantine. This is a first part of the code, more like a proof of concept. But I'd like to commit at as is and proceed with refactoring, adding a ThreadRegistry, and extending the functionality. Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D51394 llvm-svn: 340971
* [hwasan] Add a (almost) no-interceptor mode.Evgeniy Stepanov2018-08-201-17/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The idea behind this change is to allow sanitization of libc. We are prototyping on Bionic, but the tool interface will be general enough (or at least generalizable) to support any other libc. When libc depends on libclang_rt.hwasan, the latter can not interpose libc functions. In fact, majority of interceptors become unnecessary when libc code is instrumented. This change gets rid of most hwasan interceptors and provides interface for libc to notify hwasan about thread creation and destruction events. Some interceptors (pthread_create) are kept under #ifdef to enable testing with uninstrumented libc. They are expressed in terms of the new libc interface. The new cmake switch, COMPILER_RT_HWASAN_WITH_INTERCEPTORS, ON by default, builds testing version of the library with the aforementioned pthread_create interceptor. With the OFF setting, the library becomes more of a libc plugin. Reviewers: vitalybuka, kcc, jfb Subscribers: srhines, kubamracek, mgorny, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D50922 llvm-svn: 340216
* [hwasan] Handle missing /proc/self/maps.Evgeniy Stepanov2018-08-131-7/+20
| | | | | | | | | | | | | | Summary: Don't crash when /proc/self/maps is inaccessible from main thread. It's not a big deal, really. Reviewers: vitalybuka, kcc Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D50574 llvm-svn: 339607
* [HWASan] Introduce non-zero based and dynamic shadow memory (compiler-rt).Alex Shlyapnikov2018-04-231-0/+1
| | | | | | | | | | | | | | | Retire the fixed shadow memory mapping to avoid conflicts with default process memory mapping (currently manifests on Android). Tests on AArch64 show <1% performance loss and code size increase, making it possible to use dynamic shadow memory by default. Keep the fixed shadow memory mapping around to be able to run performance comparison tests later. Re-commiting D45847 with fixed shadow for x86-64. llvm-svn: 330624
* Revert r330474 - "[HWASan] Introduce non-zero based and dynamic shadow ↵Reid Kleckner2018-04-231-1/+0
| | | | | | | | | | | | | | | memory (compiler-rt)." This commit causes internal errors with ld.bfd 2.24. My guess is that the ifunc usage in this commit is causing problems. This is the default system linker on Trusty Tahr, which is from 2014. I claim it's still in our support window. Maybe we will decide to drop support for it, but let's get the bots green while we do the investigation and have that discussion. Discovered here: https://crbug.com/835864 llvm-svn: 330619
* [HWASan] Introduce non-zero based and dynamic shadow memory (compiler-rt).Alex Shlyapnikov2018-04-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Retire the fixed shadow memory mapping to avoid conflicts with default process memory mapping (currently manifests on Android). Tests on AArch64 show <1% performance loss and code size increase, making it possible to use dynamic shadow memory by default. For the simplicity and unifirmity sake, use dynamic shadow memory mapping with base address accessed via ifunc resolver on all supported platforms. Keep the fixed shadow memory mapping around to be able to run performance comparison tests later. Complementing D45840. Reviewers: eugenis Subscribers: srhines, kubamracek, dberris, mgorny, kristof.beyls, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45847 llvm-svn: 330474
* [hwasan] An option to disable tag randomization.Evgeniy Stepanov2018-01-101-6/+10
| | | | | | | | | | | | | | | | | | Summary: Avoid flaky test failures by by using a monotonic number sequence of heap tags. Does not affect stack tags: the way we generate those guarantees uniqueness for at least 30-something first allocas in any function, as well as the UAR tag. Reviewers: alekseyshl, kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D41882 llvm-svn: 322214
* [hwasan] Add heap tag randomization.Evgeniy Stepanov2018-01-031-0/+34
| | | | | | | | | | | | | | Summary: Generate tags for heap allocations from a pseudo-random sequence seeded with getrandom(), where available. Reviewers: kcc, alekseyshl Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D41616 llvm-svn: 321761
* Hardware-assisted AddressSanitizer (compiler-rt)Evgeniy Stepanov2017-12-091-0/+75
Summary: Runtime library for HWASan, initial commit. Does not randomize tags yet, does not handle stack or globals. Reviewers: kcc, pcc, alekseyshl Subscribers: srhines, kubamracek, dberris, mgorny, llvm-commits, krytarowski Differential Revision: https://reviews.llvm.org/D40935 llvm-svn: 320231
OpenPOWER on IntegriCloud