summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl
Commit message (Collapse)AuthorAgeFilesLines
* [TSan] Ensure we can compile the runtime with older SDKsJulian Lettner2020-02-051-1/+8
| | | | | | | | | | | | | | | | | | | | | One of my changes [1] included in this release silently bumped the minimal macOS SDK required for building the TSan runtime to SDK 10.12. Let's ensure release 10 does not unexpectedly break builders with old SDKs and add proper minimal SDK checking in CMake for subsequent releases. This fix `#ifdef`s out interceptors for newer APIs. Note that the resulting TSan runtime is less complete: when these newer APIs are used TSan will report false positives. Fixes llvm 10 release blocker: #44682 https://bugs.llvm.org/show_bug.cgi?id=44682 [1] 894abb46f891cba2e0ef581650f27f512a7824b4 Reviewed By: dmajor Differential Revision: https://reviews.llvm.org/D74059
* [TSan][Darwin] Avoid calling pthread_self() before libpthread is initializedJulian Lettner2019-12-161-1/+6
| | | | | | | | | | | | | | This skips calling `pthread_self` when `main_thread_identity` hasn't been initialized yet. `main_thread_identity` is only ever assigned in `__tsan::InitializePlatform`. This change should be relatively safe; we are not changing behavior other than skipping the call to `pthread_self` when `main_thread_identity == 0`. rdar://57822138 Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D71559
* [sanitizer_common] Create max_allocation_size_mb flag.Matt Morehouse2019-10-301-3/+12
| | | | | | | | | | | | | | | | | Summary: The flag allows the user to specify a maximum allocation size that the sanitizers will honor. Any larger allocations will return nullptr or crash depending on allocator_may_return_null. Reviewers: kcc, eugenis Reviewed By: kcc, eugenis Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D69576
* tsan: fix Go ppc64le buildDmitry Vyukov2019-10-151-0/+2
| | | | | | | | This #define is in the non-Go ppc64le build but not in the Go build. Reviewed-in: https://reviews.llvm.org/D68046 Author: randall77 (Keith Randall) llvm-svn: 374868
* [tsan] Don't delay SIGTRAP handlerVitaly Buka2019-10-071-4/+5
| | | | | | | | | | | | Reviewers: eugenis, jfb Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68604 llvm-svn: 373978
* [compiler-rt] Use GetNextInstructionPc in signal handlersVitaly Buka2019-10-021-1/+1
| | | | | | | | | | | | | | | | | | Summary: All other stack trace callers assume that PC contains return address. HWAsan already use GetNextInstructionPc in similar code. PR43339 Reviewers: eugenis, kcc, jfb Subscribers: dexonsmith, dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68313 llvm-svn: 373529
* Rename tsan_interceptors.cpp into tsan_interceptors_posix.cppVitaly Buka2019-10-012-2/+2
| | | | | | | | | | | | | | | | | | | | | Summary: It's needed to use __GLIBC_PREREQ from <features.h> tsan didn't let us to include <features.h> by using --sysroot=. to disable system includes on anything that is not named as "tsan*posix*", "tsan*mac*", "tsan*linux*". See compiler-rt/lib/tsan/CMakeLists.txt Reviewers: eugenis, dvyukov, kcc Reviewed By: kcc Subscribers: mgorny, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68176 llvm-svn: 373282
* [TSAN] Add read/write range interface functions with PCJoachim Protze2019-09-242-0/+13
| | | | | | | | | | Adding annotation function variants __tsan_write_range_pc and __tsan_read_range_pc to annotate ranged access to memory while providing a program counter for the access. Differential Revision: https://reviews.llvm.org/D66885 llvm-svn: 372730
* Remove NOLINTs from compiler-rtVitaly Buka2019-09-1118-39/+40
| | | | llvm-svn: 371687
* Update compiler-rt cpplint.pyVitaly Buka2019-09-111-2/+2
| | | | | | https://github.com/cpplint/cpplint/commit/adb3500107f409ac5491188ae652ac3f4d03d9d3 llvm-svn: 371675
* [TSan] Add interceptors for mach_vm_[de]allocateJulian Lettner2019-09-094-10/+76
| | | | | | | | | | | | I verified that the test is red without the interceptors. rdar://40334350 Reviewed By: kubamracek, vitalybuka Differential Revision: https://reviews.llvm.org/D66616 llvm-svn: 371439
* [TSan] #include header instead of forward declaring intercepteesJulian Lettner2019-08-211-18/+5
| | | | llvm-svn: 369601
* [TSan] Rename file with libdispatch interceptorsJulian Lettner2019-08-201-1/+1
| | | | llvm-svn: 369314
* [TSan] Rename file to make it clear that it defines interceptorsJulian Lettner2019-08-191-1/+1
| | | | | | | Rename file `tsan_libdispatch.cpp -> tsan_libdispatch_interceptors.cpp` to make it clear that it's main purpose is defining interceptors. llvm-svn: 369289
* Revert "[TSan] Don't guard #include <xpc/xpc.h>"Julian Lettner2019-08-161-0/+7
| | | | | | This reverts commit 8191585b36eb4963002cce43fb2e79e7fb05c3d6. llvm-svn: 369165
* [TSan] Add interceptors for os_unfair_lockJulian Lettner2019-08-161-0/+53
| | | | llvm-svn: 369164
* [TSan] Don't guard #include <xpc/xpc.h>Julian Lettner2019-08-161-7/+0
| | | | | | | | The xpc_connection_* APIs that we are intercepting are available starting at macOS 10.7. This is old enough so that we don't need to guard them. llvm-svn: 369150
* [TSAN] Fix tsan on FreeBSD after D54889Alexander Richardson2019-08-061-0/+1
| | | | | | | | | | | | | | | | | | Summary: It appears that since https://reviews.llvm.org/D54889, BackgroundThread() crashes immediately because cur_thread()-> will return a null pointer which is then dereferenced. I'm not sure why I only see this issue on FreeBSD and not Linux since it should also be unintialized on other platforms. Reviewers: yuri, dvyukov, dim, emaste Subscribers: kubamracek, krytarowski, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D65705 llvm-svn: 368103
* [Sanitizer] Linux explicitally migrate shadow mapping to Transparent Huge PageDavid Carlier2019-08-061-7/+1
| | | | | | | | | | | | in madvise mode, the shadow pages will be migrated only via madvise explicit calls. Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D65775 llvm-svn: 368090
* [Sanitizer] Linux refactor shadow huge page mode handlingDavid Carlier2019-08-051-8/+7
| | | | | | | | | | | | Disabling Transparent huge page mode refactored in one function. Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D65771 llvm-svn: 367925
* Follow-up for r367863 and r367656Nico Weber2019-08-052-2/+2
| | | | llvm-svn: 367888
* Remove a few straggler ".cc"s in compiler-rt/libNico Weber2019-08-011-1/+1
| | | | llvm-svn: 367589
* compiler-rt: Rename .cc file in lib/tsan/tests/{rtl,unit} to .cppNico Weber2019-08-011-1/+1
| | | | | | Like r367463, but for tsan/tests/{rtl,unit}. llvm-svn: 367566
* compiler-rt: Rename .cc file in lib/tsan/rtl to .cppNico Weber2019-08-0135-37/+37
| | | | | | Like r367463, but for tsan/rtl. llvm-svn: 367564
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.6Julian Lettner2019-07-161-45/+44
| | | | | | | Cleanup ARM64 assembly after removing unnecessary computation of mangled stack pointer in previous commit. llvm-svn: 366258
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.10Julian Lettner2019-07-162-64/+0
| | | | | | | Remove now-unused assembly code for determining xor key on Linux/AArch64. This is the final commit of this refactoring. llvm-svn: 366225
* [TSan] Fix asm token error (again)Julian Lettner2019-07-151-1/+1
| | | | llvm-svn: 366150
* [TSan] Fix asm token errorJulian Lettner2019-07-151-1/+1
| | | | llvm-svn: 366131
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.9Julian Lettner2019-07-151-22/+5
| | | | | | | Switch over to computing the xor key in C, instead of assembly for Linux/AArch64. llvm-svn: 366126
* [TSan] Tiny cleanup of UnmangleLongJmpSp for Linux/x86_64Julian Lettner2019-07-131-8/+8
| | | | | | NFC. llvm-svn: 365982
* [TSan] Move DECLARE_REAL macro outside of namespaceJulian Lettner2019-07-111-5/+15
| | | | | | | This should fix the "undefined reference to tsan::interception::real_setjmp" linker errors. llvm-svn: 365806
* [TSan] Fix linker error on Linux/AArch64Julian Lettner2019-07-101-4/+4
| | | | llvm-svn: 365707
* [TSan] Fix compiler error on Linux/AArch64Julian Lettner2019-07-101-1/+1
| | | | llvm-svn: 365693
* [TSan] Attempt to fix linker error on Linux/AArch64Julian Lettner2019-07-101-1/+1
| | | | llvm-svn: 365681
* Reland "[TSan] Improve handling of stack pointer mangling in {set,long}jmp, ↵Julian Lettner2019-07-091-9/+51
| | | | | | | | | | | | | | | | | | pt.8" Fix compilation errors related to `SANITIZER_GO` `#ifdef`s. Refine longjmp key management. For Linux, re-implement key retrieval in C (instead of assembly). Removal of `InitializeGuardPtr` and a final round of cleanups will be done in the next commit. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D64092 > llvm-svn: 365513 llvm-svn: 365560
* [TSan] Refine longjmp key management on DarwinJulian Lettner2019-07-091-5/+6
| | | | | | NFC. llvm-svn: 365554
* Revert "[TSan] Improve handling of stack pointer mangling in {set,long}jmp, ↵Julian Lettner2019-07-092-51/+10
| | | | | | | | pt.8" This reverts commit 521f77e6351fd921f5a81027c7c72addca378989. llvm-svn: 365534
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.8Julian Lettner2019-07-092-10/+51
| | | | | | | | | | | | Refine longjmp key management. For Linux, re-implement key retrieval in C (instead of assembly). Removal of `InitializeGuardPtr` and a final round of cleanups will be done in the next commit. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D64092 llvm-svn: 365513
* [TSan] Fix linker error for Linux/AArch64Julian Lettner2019-07-091-1/+3
| | | | llvm-svn: 365415
* Revert "[TSan] Attempt to fix linker error for Linux on AArch64"Julian Lettner2019-07-082-1/+9
| | | | | | This reverts commit be4148062b155f3be52e0f6ebcb228f2dc137dcf. llvm-svn: 365367
* Revert "[TSan] Improve handling of stack pointer mangling in {set,long}jmp, ↵Julian Lettner2019-07-051-4/+32
| | | | | | | | pt.4" This reverts commit 6bb13da7c16f2a677cc285bb6ffeb79dfb0cfe64. llvm-svn: 365244
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.5Julian Lettner2019-07-051-39/+4
| | | | | | | | | | Remove unnecessary computation of mangled SP for ARM64 architecture. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D64022 llvm-svn: 365230
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.4Julian Lettner2019-07-051-32/+4
| | | | | | | | | | | For x86_64, since we don't clobber %rsi (2nd argument) anymore, we don't have to save/restore it. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D63946 llvm-svn: 365229
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.7Julian Lettner2019-07-024-29/+36
| | | | | | | | | | | Factor out `ExtractLongJmpSp` helper function and move platform-specific code to tsan_platform_{linux,mac}.cc. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D64050 llvm-svn: 364947
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.3Julian Lettner2019-07-012-36/+8
| | | | | | | | | | Remove unnecessary computation of mangled SP for x86_64 architecture. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D63944 llvm-svn: 364874
* [TSan] Fix initialized and declared ‘extern’ warningJulian Lettner2019-07-011-2/+5
| | | | | | | | | | | | Avoid the following warning which fails a bot (via -Werror). ``` /tmp/gotsan.JfrpVPu7pG/gotsan.cc:10456:25: error: ‘_tsan_pointer_chk_guard’ initialized and declared ‘extern’ [-Werror] extern "C" __tsan::uptr _tsan_pointer_chk_guard = 0; ^~~~~~~~~~~~~~~~~~~~~~~ ``` llvm-svn: 364823
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.2Julian Lettner2019-07-012-8/+4
| | | | | | | | | | | | Switch `LongJmp` over to lookup JmpBuf via plain old (unmangled) SP. This makes the computation of mangled SPs in the TSan assembly files unnecessary, which will be cleaned up in follow-up revisions. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D63942 llvm-svn: 364818
* [TSan] Attempt to fix linker error for Linux on AArch64Julian Lettner2019-06-292-9/+2
| | | | | | Introduced in 5be69ebe121d5b6ea284c3dc6d1cd5098c94f353. llvm-svn: 364700
* [TSan] Fix build build breakage on AndroidJulian Lettner2019-06-281-1/+1
| | | | | | Introduced in 5be69ebe121d5b6ea284c3dc6d1cd5098c94f353. llvm-svn: 364676
* [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.1Julian Lettner2019-06-284-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TSan needs to infer which calls to setjmp/longjmp are corresponding pairs. My understanding is, that we can't simply use the jmp_buf address, since this buffer is just a plain data structure storing the environment (registers) with no additional semantics, i.e., it can be copied around and is still expected to work. So we use the stack pointer (SP) instead. The setjmp interceptor stores some metadata, which is then consumed in the corresponding call to longjmp. We use the SP as an "index" (stable identifier) into the metadata table. So far so good. However, when mangling is used, the setjmp interceptor observes the UNmangled SP, but the longjmp interceptor only knows the mangled value for SP. To still correlate corresponding pairs of calls, TSan currently derives the mangled representation in setjmp and uses it as the stable identifer, so that longjmp can do it's lookup. Currently, this works since "mangling" simply means XOR with a secret value. However, in the future we want to use operations that do not allow us to easily go from unmangled -> mangled (pointer authentication). Going from mangled -> unmangled should still be possible (for pointer authentication it means zeroing a few bits). This patch is part 1 of changing set/longjmp interceptors to use the unmangled SP for metadata lookup. Instead of deriving the mangled SP in setjmp, we will derive the unmangled SP in longjmp. Since this change involves difficult-to-test code, it will be done in (at least) 2 parts: This patch only replicates the existing behavior and checks that the newly computed value for SP matches with what we have been doing so far. This should help me to fix issues on architectures I cannot test directly. I tested this patch on x86-64 (Linux/Darwin) and arm64 (Darwin). This patch will also address an orthogonal issue: there is a lot of code duplication in the assembly files, because the `void __tsan_setjmp(uptr sp, uptr mangled_sp)` already demands the mangled SP. This means that the code for computing the mangled SP is duplicated at every call site (in assembly). Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D60981 llvm-svn: 364662
OpenPOWER on IntegriCloud