summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2016-04-28[tsan] Fix Darwin GCD support after separation of Processor and ThreadStateKuba Brecka
Recent TSan changes (r267678) which factor out parts of ThreadState into a Processor structure broke worker threads on OS X. This fixes it by properly calling ProcCreate for GCD worker threads and by replacing some CHECKs with RAW_CHECK in early process initialization. CHECK() in TSan calls the allocator, which requires a valid Processor. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267864 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[MSan] [PowerPC] Dereference function descriptors when recording stack origins.Marcin Koscielnicki
Differential Revision: http://reviews.llvm.org/D19543 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267795 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizers] Get the proper symbol version when long double transition is ↵Marcin Koscielnicki
involved. On linux, some architectures had an ABI transition from 64-bit long double (ie. same as double) to 128-bit long double. On those, glibc symbols involving long doubles come in two versions, and we need to pass the correct one to dlvsym when intercepting them. A few more functions we intercept are also versioned (all printf, scanf, strtold variants), but there's no need to fix these, as the REAL() versions are never called. Differential Revision: http://reviews.llvm.org/D19555 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267794 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizer] Add early call handling to strchr + strrchr interceptorsDerek Bruening
Summary: The strchr and strrchr interceptors are sometimes invoked too early for their REAL() counterparts to be initialized. We have seen this in hooks invoked from tcmalloc on the dlsym() used in initializing interceptors. A special check is added to use internal_ routines for this situation. Reviewers: vitalybuka, aizatsky, filcab Subscribers: filcab, llvm-commits, eugenis, kcc, zhaoqin, aizatsky, kubabrecka Differential Revision: http://reviews.llvm.org/D19607 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267793 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizers] read/write page fault detection on mac.Mike Aizatsky
Summary: Resubmit of http://reviews.llvm.org/D19495 enabled only on intel. Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19561 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267750 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27[sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.Marcin Koscielnicki
In short, CVE-2016-2143 will crash the machine if a process uses both >4TB virtual addresses and fork(). ASan, TSan, and MSan will, by necessity, map a sizable chunk of virtual address space, which is much larger than 4TB. Even worse, sanitizers will always use fork() for llvm-symbolizer when a bug is detected. Disable all three by aborting on process initialization if the running kernel version is not known to contain a fix. Unfortunately, there's no reliable way to detect the fix without crashing the kernel. So, we rely on whitelisting - I've included a list of upstream kernel versions that will work. In case someone uses a distribution kernel or applied the fix themselves, an override switch is also included. Differential Revision: http://reviews.llvm.org/D19576 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix windows supportDmitry Vyukov
UnmapOrDie used to do MEM_DECOMMIT and so worked on partial regions. But r263160 changed it to use MEM_RELEASE and MEM_RELEASE can only work with whole regions mapped by VirtualAlloc. This broke windows as: FATAL: ThreadSanitizer CHECK failed: gotsan.cc:8296 "((mbi.AllocationBase == addr && "Windows cannot unmap part of a previous mapping")) != (0)" (0x0, 0x0) Restore the previous behavior. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267730 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix darwin Go supportDmitry Vyukov
os_trace turns out to be a macro that creates static object. Function-static objects use __cxa_atexit and __dso_handle which are not present in Go runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267720 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix windows Go supportDmitry Vyukov
Unmap can't unmap arbitrary regions on windows. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267716 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix darwin Go buildDmitry Vyukov
syslog_lock is not defined in Go build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267714 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: make windows shadow mapping a bijectionDmitry Vyukov
CheckShadowMapping function started catching that mem->shadow->mem mapping is not bijection. Make it bijection. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267713 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix build Dmitry Vyukov
error: implicit declaration of function 'abort' is invalid in C99 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267710 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix darwin Go buildDmitry Vyukov
Ifdef out global variables with destructors. This requires runtime support that is not provided by Go runtime (in particular _dso_handle symbol). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267709 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: change tsan/Go interface for obtaining the current ProcessorDmitry Vyukov
Current interface assumes that Go calls ProcWire/ProcUnwire to establish the association between thread and proc. With the wisdom of hindsight, this interface does not work very well. I had to sprinkle Go scheduler with wire/unwire calls, and any mistake leads to hard to debug crashes. This is not something one wants to maintian. Fortunately, there is a simpler solution. We can ask Go runtime as to what is the current Processor, and that question is very easy to answer on Go side. Switch to such interface. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267703 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix windows buildDmitry Vyukov
warning: '__sanitizer::uptr __sanitizer::GetPreferredBase(const char*)' defined but not used git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267682 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix windows buildDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267681 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: add missing fileDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267680 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: fix compiler warningDmitry Vyukov
tsan_debugging.cc: In function ‘void* __tsan_get_current_report()’: tsan_debugging.cc:61:18: warning: cast from type ‘const __tsan::ReportDesc*’ to type ‘void*’ casts away qualifiers [-Wcast-qual] return (void *)rep; git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267679 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27tsan: split thread into logical and physical stateDmitry Vyukov
This is reincarnation of http://reviews.llvm.org/D17648 with the bug fix pointed out by Adhemerval (zatrazz). Currently ThreadState holds both logical state (required for race-detection algorithm, user-visible) and physical state (various caches, most notably malloc cache). Move physical state in a new Process entity. Besides just being the right thing from abstraction point of view, this solves several problems: Cache everything on P level in Go. Currently we cache on a mix of goroutine and OS thread levels. This unnecessary increases memory consumption. Properly handle free operations in Go. Frees are issue by GC which don't have goroutine context. As the result we could not do anything more than just clearing shadow. For example, we leaked sync objects and heap block descriptors. This will allow to get rid of libc malloc in Go (now we have Processor context for internal allocator cache). This in turn will allow to get rid of dependency on libc entirely. Potentially we can make Processor per-CPU in C++ mode instead of per-thread, which will reduce resource consumption. The distinction between Thread and Processor is currently used only by Go, C++ creates Processor per OS thread, which is equivalent to the current scheme. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267678 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26[sanitizers] [NFC] Add defines for the various PowerPC ABIs.Marcin Koscielnicki
Differential Revision: http://reviews.llvm.org/D19542 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267586 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26[sanitizer] [SystemZ] Add ptrace support bits.Marcin Koscielnicki
Differential Revision: http://reviews.llvm.org/D19134 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267548 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26[sanitizer] [SystemZ] Implement internal_clone.Marcin Koscielnicki
Differential Revision: http://reviews.llvm.org/D19159 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267547 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26Revert "[sanitizers] read/write page fault detection on mac."Mehdi Amini
This reverts commit r267477. It broke our bots that enables the AArch64 backends, it seems that this code is using a Darwin *X86 specific* field. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267526 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25[MSan] Use COMMON_INTERCEPTOR_ENTER in libdl interceptors.Marcin Koscielnicki
This fixes fails in test/msan/dlerror.cc - when real dlerror calls strcmp, our strcmp interceptor now skips poison checking, since it's called in interceptor context. Strictly speaking, only the dlerror change is necessary to fix the fail, but let's also change the other two just in case. Differential Revision: http://reviews.llvm.org/D19499 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267486 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25[sanitizers] read/write page fault detection on mac.Mike Aizatsky
Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19495 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267477 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25[esan] Fix uninitialized warning from interception contextDerek Bruening
The interception context is not used by esan, but the compiler complains about it being uninitialized all the same. We set it to null to avoid the warning. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267376 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-23[esan] EfficiencySanitizer libc interceptorsDerek Bruening
Summary: Adds libc interceptors to the runtime library for the new EfficiencySanitizer ("esan") family of tools. The interceptors cover the memory operations in most common library calls and will be shared among all esan tools. Reviewers: aizatsky Subscribers: zhaoqin, tberghammer, danalbert, srhines, llvm-commits, vitalybuka, eugenis, kcc Differential Revision: http://reviews.llvm.org/D19411 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267293 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-23[sanitizer] add a function MmapNoAccess that mmaps a protected region ↵Kostya Serebryany
*somewhere*; use MmapNoAccess in the Allocator when SpaceBeg is not a constant. In this mode the allocator will be a bit more hardened git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267256 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22[sanitizer] rename MmapNoAccess to MmapFixedNoAccess; NFCKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267253 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22[sanitizer] partially un-revert r267094: Allow the sanitizer allocator to ↵Kostya Serebryany
use a non-fixed address range. An allocator with a non-fixed address range will be attack-resistan. NFC for the sanitizers at this point. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267252 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22[sanitizer] revert r267203 as it breaks aarch64 botsKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267251 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22[sanitizer] allow zero first parameter in MmapNoAccess; This is a part of ↵Kostya Serebryany
r267094 that has been reverted git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267203 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22Revert "[LSAN] Fix test swapcontext.cc on MIPS"Renato Golin
This reverts commit r266716, as it breaks the self-hosting on Thumb2 buildbot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267158 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22Revert "[sanitizer] Allow the sanitizer allocator to use a non-fixed address ↵Renato Golin
range. An allocator with a non-fixed address range will be attack-resistan. NFC for the sanitizers at this point." This reverts commit r267094, because it broke a lot of MSAN tests in AArch64. Being NFC and all, this needs some deeper investigation before it goes in again. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267136 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22[ASAN] Use struct instead of array in sancov.pySagar Thakur
Summary: When using 32-bit python with 64-bit asan the pc array in sancov.py cannot fit in 64-bit pc's because the type-code 'L' for arrays in python corresponds to the C type long which is only of 4 bytes. Because of this some of the coverage tool tests fail on mips. To fix these test possible solutions are to use 64-bit python or use struct.unpack with the 'Q' type-code. We have used struct.unpack with 'Q' type code since it is not appropriate to have a 64-bit python on all hosts. Reviewed by kcc, aizatsky Differential: http://reviews.llvm.org/D18817 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267126 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22[sanitizer] Allow the sanitizer allocator to use a non-fixed address range. ↵Kostya Serebryany
An allocator with a non-fixed address range will be attack-resistan. NFC for the sanitizers at this point. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267094 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21[esan] EfficiencySanitizer base runtime libraryDerek Bruening
Summary: Adds the initial version of a runtime library for the new EfficiencySanitizer ("esan") family of tools. The library includes: + Slowpath code via callouts from the compiler instrumentation for each memory access. + Registration of atexit() to call finalization code. + Runtime option flags controlled by the environment variable ESAN_OPTIONS. The common sanitizer flags are supported such as verbosity and log_path. + An initial simple test. Still TODO: common code for libc interceptors and shadow memory mapping, and tool-specific code for shadow state updating. Reviewers: eugenis, vitalybuka, aizatsky, filcab Subscribers: filcab, vkalintiris, kubabrecka, llvm-commits, zhaoqin, kcc Differential Revision: http://reviews.llvm.org/D19168 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267060 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21[tsan] Rename ReportThread->pid to ReportThread->os_idKuba Brecka
The field "pid" in ReportThread is used to store the OS-provided thread ID (pthread_self or gettid). The name "pid" suggests it's a process ID, which it isn't. Let's rename it. Differential Revision: http://reviews.llvm.org/D19365 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266994 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21[sanitizer] Use pthread_threadid_np as thread ID on OS XKuba Brecka
Let's use pthread_threadid_np which returns a more reasonable ID than pthread_self (which is actually a stack pointer). The numbers from pthread_threadid_np are already used in other tools, e.g. in LLDB, and often appear in logs, so it's much more useful than pthread_self. Differential Revision: http://reviews.llvm.org/D18951 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266991 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20[sanitizer] update the sanitizer_allocator_testlibKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266934 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20[asan] Increase LocatePcInTrace threshold.Evgeniy Stepanov
Not sure what changed, but on my machine this is literally one byte short. Only happens when malloc_context_size <= 2 due to the special case in GET_STACK_TRACE definition (see asan_stack.h): StackTrace::GetCurrentPc() on the right (context size > 2) branch returns the address that is 200-something bytes from the return address it is later matched to, while the same call on the left branch is 321 bytes away from it. This fixes the double-free test on my machine. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266932 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20[asan] Add __strdup interceptor.Evgeniy Stepanov
This happens on Linux when building as C (not C++) with optimization. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266931 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20[msan] Implement GetPageSize in the test.Evgeniy Stepanov
Instead of calling a sanitizer_common function, implement GetPageSize in the test directly. MSan runtime does not export __sanitizer::* symbols, and the current code breaks when the test and the runtime library are in the separate link units (ex. when the test is built as a shared library). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266910 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20builtins: fix -Werror,-Wunused-variable warningSaleem Abdulrasool
This removes the unused variable `flags`. NFC git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266892 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20builtins: remove use of __attribute__((pcs("aapcs"))) on WindowsSaleem Abdulrasool
Windows does not honour the __attribute__((pcs)) on ARM. Although this will result in ABI mismatches, compiler-rt should largely be unneeded for resolving dependencies as we generate MS ABI compliant library calls now for the most part. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266891 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20Always inlining PrintCurrentStackSlow of tsan library to fix tail-call issueChuang-Yu Cheng
The real problem is that sanitizer_print_stack_trace obtains current PC and expects the PC to be in the stack trace after function calls. We don't prevent tail calls in sanitizer runtimes, so this assumption does not necessary hold. We add "always inline" attribute on PrintCurrentStackSlow to address this issue, however this solution is not reliable enough, but unfortunately, we don't see any simple, reliable solution. Reviewers: samsonov hfinkel kbarton tjablin dvyukov kcc http://reviews.llvm.org/D19148 Thanks Hal, dvyukov, and kcc for invaluable discussion, I have even borrowed part of dvyukov's summary as my commit message! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266869 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20[sanitizer] Fix 'dyld: Symbol not found: _dyldVersionNumber' link error on ↵Maxim Ostapenko
old Darwin systems. This patch fixes https://github.com/google/sanitizers/issues/669. On older Darwin systems (in particular, Darwin 10), dyld doesn't export '_dyldVersionNumber' symbol so we would have 'undefined reference' error in sanitzer library. Although sanitizers support was added to LLVM on OS X 10.7+ where '_dyldVersionNumber' symbol is already exported, GCC users still may want use them on older systems. Differential Revision: http://reviews.llvm.org/D19218 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266868 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19[LSAN] Fix test swapcontext.cc on MIPSSagar Thakur
Summary: There is no frame validity check in the slow unwinder like there is in the fast unwinder due to which lsan reports a leak even for heap allocated coroutine in the test swapcontext.cc. Since mips/linux uses slow unwindwer instead of fast unwinder, the test fails for mips/linux. Therefore adding the checks before unwinding fixes the test for mips/linux. Reviewers: samsonov, earthdok, kcc Subscribers: llvm-commits, mohit.bhakkad, jaydeep Differential: http://reviews.llvm.org/D18690 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266716 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18[msan] Don't hardcode 4kiB page size in msan_test.cc.Marcin Koscielnicki
This breaks the valloc test on PowerPC, which has 64kiB pages. Since getting page size portably is nontrivial, and there's already a function for that in __sanitizer, just use it. Unfortunately, sanitizer_common.h conflicts with the interface headers inclucded by msan_test.cc (and a few of its own macros), so we have to declare it manually. Differential Revision: http://reviews.llvm.org/D19227 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266688 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-18[MSan] [PowerPC] Add loadable library name for testing.Marcin Koscielnicki
Differential Revision: http://reviews.llvm.org/D19217 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266646 91177308-0d34-0410-b5e6-96231b3b80d8