summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
Commit message (Collapse)AuthorAgeFilesLines
...
* [sanitizer] Add memset, memmove, and memcpy to the common interceptorsDerek Bruening2016-03-253-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently, sanitizer_common_interceptors.inc has an implicit, undocumented assumption that the sanitizer including it has previously declared interceptors for memset and memmove. Since the memset, memmove, and memcpy routines require interception by many sanitizers, we add them to the set of common interceptions, both to address the undocumented assumption and to speed future tool development. They are intercepted under a new flag intercept_intrin. The tsan interceptors are removed in favor of the new common versions. The asan and msan interceptors for these are more complex (they incur extra interception steps and their function bodies are exposed to the compiler) so they opt out of the common versions and keep their own. Reviewers: vitalybuka Subscribers: zhaoqin, llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D18465 llvm-svn: 264451
* [tsan] Use direct syscalls for internal_mmap and internal_munmap on OS XKuba Brecka2016-03-241-2/+7
| | | | | | | | On OS X, internal_mmap just uses mmap, which can invoke callbacks into libmalloc (e.g. when MallocStackLogging is enabled). This can subsequently call other intercepted functions, and this breaks our Darwin-specific ThreadState initialization. Let's use direct syscalls in internal_mmap and internal_munmap. Added a testcase. Differential Revision: http://reviews.llvm.org/D18431 llvm-svn: 264259
* [sanitizer] Add strnlen to the common interceptorsDerek Bruening2016-03-233-1/+19
| | | | | | | | | | | | | | | | | | | Summary: Adds strnlen to the common interceptors, under the existing flag intercept_strlen. Removes the now-duplicate strnlen interceptor from asan and msan. This adds strnlen to tsan, which previously did not intercept it. Adds a new test of strnlen to the sanitizer_common test cases. Reviewers: samsonov Subscribers: zhaoqin, llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D18397 llvm-svn: 264195
* [sanitizer] Add strchr* to the common interceptorsEvgeniy Stepanov2016-03-213-0/+60
| | | | | | | | | | | | | | | | Adds strchr, strchrnul, and strrchr to the common interceptors, under a new common flag intercept_strchr. Removes the now-duplicate strchr interceptor from asan and all 3 interceptors from tsan. Previously, asan did not intercept strchrnul, but does now; previously, msan did not intercept strchr, strchrnul, or strrchr, but does now. http://reviews.llvm.org/D18329 Patch by Derek Bruening! llvm-svn: 263992
* [sancov] common flags initialization.Mike Aizatsky2016-03-182-0/+11
| | | | | | | | | | | | Summary: Introducing InitializeCommonFlags accross all sanitizers to simplify common flags management. Setting coverage=1 when html_cov_report is requested. Differential Revision: http://reviews.llvm.org/D18273 llvm-svn: 263820
* Removing a non-intentional debug output that got committed in r263695.Kuba Brecka2016-03-171-3/+0
| | | | llvm-svn: 263698
* [sanitizer] On OS X, verify that interceptors work and abort if not, take 2Kuba Brecka2016-03-174-14/+22
| | | | | | | | | | On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES. TSan unit tests run with a statically linked runtime, where interceptors don't work. To avoid aborting the process in this case, the patch replaces `DisableReexec()` with a weak `ReexecDisabled()` function which is defined to return true in unit tests. Differential Revision: http://reviews.llvm.org/D18212 llvm-svn: 263695
* [tsan] Detect uses of uninitialized, destroyed and invalid mutexesKuba Brecka2016-03-161-1/+10
| | | | | | | | This patch adds a new TSan report type, ReportTypeMutexInvalidAccess, which is triggered when pthread_mutex_lock or pthread_mutex_unlock returns EINVAL (this means the mutex is invalid, uninitialized or already destroyed). Differential Revision: http://reviews.llvm.org/D18132 llvm-svn: 263641
* [ASAN] Add support for mips/mips64 androidMohit K. Bhakkad2016-03-165-28/+50
| | | | | | | | | | | | Patch by Duane Sand Reviewers: samsonov Subscribers: duanesand, jaydeep, sagar, llvm-commits, filcab. Differential Revision: http://reviews.llvm.org/D17883 llvm-svn: 263621
* Revert r263551 due to a test failure.Kuba Brecka2016-03-151-15/+0
| | | | llvm-svn: 263553
* [sanitizer] On OS X, verify that interceptors work and abort if notKuba Brecka2016-03-151-0/+15
| | | | | | | | On OS X 10.11+, we have "automatic interceptors", so we don't need to use DYLD_INSERT_LIBRARIES when launching instrumented programs. However, non-instrumented programs that load TSan late (e.g. via dlopen) are currently broken, as TSan will still try to initialize, but the program will crash/hang at random places (because the interceptors don't work). This patch adds an explicit check that interceptors are working, and if not, it aborts and prints out an error message suggesting to explicitly use DYLD_INSERT_LIBRARIES. Differential Revision: http://reviews.llvm.org/D18121 llvm-svn: 263551
* [Sanitizer][MIPS] internal lstat and fstat for mips64Mohit K. Bhakkad2016-03-111-0/+16
| | | | | | | | | | Reviewers: dvyukov Subscribers: jaydeep, sagar, llvm-commits Differential Revision: http://reviews.llvm.org/D18078 llvm-svn: 263218
* [Compiler-rt] Fix ioctl codes for MIPS in sanitizer_ioctl_testMohit K. Bhakkad2016-03-111-2/+4
| | | | | | | | | | Reviewers: samsonov Subscribers: jaydeep, sagar, llvm-commits Differential Revision: http://reviews.llvm.org/D17985 llvm-svn: 263199
* [sanitizer] Add strlen to the common interceptorsAlexey Samsonov2016-03-113-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds strlen to the common interceptors, under a new common flag intercept_strlen. This provides better sharing of interception code among sanitizers and cleans up the inconsistent type declarations of the previously duplicated interceptors. Removes the now-duplicate strlen interceptor from asan, msan, and tsan. The entry check semantics are normalized now for msan and asan, whose private strlen interceptors contained multiple layers of checks that included impossible-to-reach code. The new semantics are identical to the old: bypass interception if in the middle of init or if both on Mac and not initialized; else, call the init routine and proceed. Patch by Derek Bruening! Reviewers: samsonov, vitalybuka Subscribers: llvm-commits, kcc, zhaoqin Differential Revision: http://reviews.llvm.org/D18020 llvm-svn: 263177
* [Windows] Fix UnmapOrDie and MmapAlignedOrDieReid Kleckner2016-03-103-23/+95
| | | | | | | | | | | | | | | | | | | | | | | | | Now ASan can return virtual memory to the underlying OS. Portable sanitizer runtime code needs to be aware that UnmapOrDie cannot unmap part of previous mapping. In particular, this required changing how we implement MmapAlignedOrDie on Windows, which is what Allocator32 uses. The new code first attempts to allocate memory of the given size, and if it is appropriately aligned, returns early. If not, it frees the memory and attempts to reserve size + alignment bytes. In this region there must be an aligned address. We then free the oversized mapping and request a new mapping at the aligned address immediately after. However, a thread could allocate that virtual address in between our free and allocation, so we have to retry if that allocation fails. The existing thread creation stress test managed to trigger this condition, so the code isn't totally untested. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D17431 llvm-svn: 263160
* Retrieve command line arguments and environment correctly on FreeBSDDimitry Andric2016-03-101-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Recently I saw the test `TestCases/Posix/print_cmdline.cc` failing on FreeBSD, with "expected string not found in input". This is because asan could not retrieve the command line arguments properly. In `lib/sanitizer_common/sanitizer_linux.cc`, this is taken care of by the `GetArgsAndEnv()` function, but it uses `__libc_stack_end` to get at the required data. This variable does not exist on BSDs; the regular way to retrieve the arguments and environment information is via the `kern.ps_strings` sysctl. I added this functionality in sanitizer_linux.cc, as a separate #ifdef block in `GetArgsAndEnv()`. Also, `ReadNullSepFileToArray()` becomes unused due to this change. (It won't work on FreeBSD anyway, since `/proc` is not mounted by default.) Reviewers: kcc, emaste, joerg, davide Subscribers: llvm-commits, emaste Differential Revision: http://reviews.llvm.org/D17832 llvm-svn: 263157
* sanitizer: Fix endianness checks for gccAlexey Samsonov2016-03-091-2/+2
| | | | | | | | | | | | | | | | | Summary: __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are not supported by gcc, which eg. for ubsan Value::getFloatValue will silently fall through to the little endian branch, breaking display of float values by ubsan. Use __BYTE_ORDER__ == __ORDER_BIG/LITTLE_ENDIAN__ as the condition instead, which is supported by both clang and gcc. Noticed while porting ubsan to s390x. Patch by Marcin Kościelnicki! Differential Revision: http://reviews.llvm.org/D17660 llvm-svn: 263077
* [Compiler-rt][MIPS] Defining macros for MIPS archsMohit K. Bhakkad2016-03-091-0/+15
| | | | | | | | | | Reviewers: samsonov Subscribers: filcab, jaydeep, sagar, llvm-commits Differential Revision: http://reviews.llvm.org/D17881 llvm-svn: 263000
* [cmake] Address Samsonov's post-commit review of r262723Filipe Cabecinhas2016-03-051-1/+1
| | | | | | | | | | Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17896 llvm-svn: 262770
* tsan: describe heap/data locations in GoDmitry Vyukov2016-03-012-0/+3
| | | | llvm-svn: 262343
* sanitizer_common: silence compiler warningDmitry Vyukov2016-03-011-0/+1
| | | | llvm-svn: 262342
* [Compiler-rt][MIPS] Correct Dynamic Thread Vector offset for MIPSMohit K. Bhakkad2016-03-011-1/+1
| | | | | | | | | | Reviewers: samsonov Subscribers: dsanders, jaydeep, sagar, llvm-commits Differential Revision: http://reviews.llvm.org/D17703 llvm-svn: 262303
* [UBSan] Fix isDerivedFromAtOffset on iOS ARM64Filipe Cabecinhas2016-02-271-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: iOS on ARM64 doesn't unique RTTI. Ref: clang's iOS64CXXABI::shouldRTTIBeUnique() Due to this, pointer-equality will not necessarily work in this architecture, across dylib boundaries. dynamic_cast<>() will (as expected) still work, since Apple ships with one prepared for this, but we can't rely on the type names being pointer-equal. I've limited the expensive strcmp check to the specific architecture which needs it. Example which triggers this bug: lib.h: struct X { virtual ~X() {} }; X *libCall(); lib.mm: X *libCall() { return new X; } prog.mm: int main() { X *px = libCall(); delete px; } Expected output: Nothing Actual output: <unknown>: runtime error: member call on address 0x00017001ef50 which does not point to an object of type 'X' 0x00017001ef50: note: object is of type 'X' 00 00 00 00 60 00 0f 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for ‘X’ Reviewers: kubabrecka, samsonov, eugenis, rsmith Subscribers: aemerson, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D11502 llvm-svn: 262147
* [Sanitizer] Protect against compiler-inserted memcpy() in ↵Alexey Samsonov2016-02-251-1/+1
| | | | | | InternalMmapVector::push_back(). llvm-svn: 261909
* [sanitizer] Fix third parameter in COMMON_INTERCEPTOR_WRITE_RANGE in recv ↵Maxim Ostapenko2016-02-251-2/+2
| | | | | | | | | | | and recvfrom interceptors. Pass res instead of len as third parameter to COMMON_INTERCEPTOR_WRITE_RANGE, because otherwise we can write to unrelated memory (in MSan) or get wrong report (in ASan). Differential Revision: http://reviews.llvm.org/D17608 llvm-svn: 261898
* [sanitizer] Disable recv and recvfrom interceptors on Windows.Maxim Ostapenko2016-02-251-1/+1
| | | | | | Trying to fix sanitizer-windows buildbot by disabling new interceptors on Windows. llvm-svn: 261844
* [sanitizer] Move recvmsg and recv interceptors to sanitizer_common.Maxim Ostapenko2016-02-252-0/+39
| | | | | | | | | This patch moves recv and recvfrom interceptors from MSan and TSan to sanitizer_common to enable them in ASan. Differential Revision: http://reviews.llvm.org/D17479 llvm-svn: 261841
* [Sanitizer] Introduce ListOfModules object and use it to replace ↵Alexey Samsonov2016-02-2213-114/+95
| | | | | | | | | | | | | | | | | | | | GetListOfModules(). Summary: This removes the hard limit on the number of loaded modules (used to be 16K), and makes it easier to use LoadedModules w/o causing a memory leak: ListOfModules owns the modules, and makes sure to properly clean them in destructor. Remove filtering functionality that is only needed in one place (LSan). Reviewers: aizatsky Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D17470 llvm-svn: 261554
* [sancov] use GetLoadedModules for list of modules rather than sanitizer's list.Mike Aizatsky2016-02-191-12/+33
| | | | llvm-svn: 261376
* [WinASan] Fix page size and mmap granularity confusionReid Kleckner2016-02-181-4/+6
| | | | | | | | | | | We were erroneously reporting 16K as the page size on Windows because the code that does the shadow mapping was using page size instead of allocation granularity. After fixing that, we can resolve the FIXMEs in the Windows implementations of GetPageSize and GetMmapGranularity by calling GetSystemInfo instead of returning hard-coded, incorrect answers. llvm-svn: 261233
* [compiler-rt] Return correct size of struct pthread for glibc-2.12.2Jonas Hahnfeld2016-02-181-2/+7
| | | | | | | | | There seems to be a difference between 2.12.1 and 2.12.2 in 64-bit build. Tested on Scientific Linux 6.6, based on RHEL. Differential Revision: http://reviews.llvm.org/D17190 llvm-svn: 261193
* Fixed non-NULL terminating array bug in SanitizerCommon.StartSubprocessTest ↵Zia Ansari2016-02-151-1/+1
| | | | | | | | that caused them to fail sometimes and act flaky. Differential Revision: http://reviews.llvm.org/D17228 llvm-svn: 260876
* [LSan] Print more helpful error message if LSan crashes during leak detection.Alexey Samsonov2016-02-121-2/+2
| | | | llvm-svn: 260717
* [sancov] improved object files handling.Mike Aizatsky2016-02-121-10/+4
| | | | | | | | | | Updating sancov invocation on html_cov_dump. sancov change: http://reviews.llvm.org/D17169 Differential Revision: http://reviews.llvm.org/D17171 llvm-svn: 260629
* [Windows] Fill in read/write information in SignalContextReid Kleckner2016-02-111-2/+11
| | | | | | Implements https://github.com/google/sanitizers/issues/653 llvm-svn: 260539
* [asan] Fix build on Windows and PowerPC.Evgeniy Stepanov2016-02-092-4/+5
| | | | llvm-svn: 260175
* [asan] Fix Windows build.Evgeniy Stepanov2016-02-081-3/+3
| | | | llvm-svn: 260167
* [asan] Remove leftover debug print statement.Evgeniy Stepanov2016-02-081-1/+0
| | | | llvm-svn: 260165
* [asan] Implement SEGV read vs write detection for ARM and AArch64.Evgeniy Stepanov2016-02-084-16/+62
| | | | llvm-svn: 260163
* Fix build on FreeBSD after r259741.Dimitry Andric2016-02-071-0/+4
| | | | | | | | | On FreeBSD, the uc_mcontext member of ucontext_t has a member called mc_err, which corresponds to the Linux member gregs[REG_ERR]. Reviewed by: rdivacky@FreeBSD.org llvm-svn: 260046
* [asan] fix the non-x86 buildKostya Serebryany2016-02-041-0/+4
| | | | llvm-svn: 259745
* [asan] When catching a signal caused by a memory access, print if it's a ↵Kostya Serebryany2016-02-045-6/+26
| | | | | | READ or a WRITE. This touches win/mac files which I have not tested, if a win/mac bot fails I'll try to quick-fix llvm-svn: 259741
* [asan] Add iOS support.Anna Zaks2016-02-029-22/+54
| | | | llvm-svn: 259451
* GetArgv returns null on widnows, do not crashMike Aizatsky2016-01-281-2/+4
| | | | llvm-svn: 259005
* using /system/bin/sh on android in tests.Mike Aizatsky2016-01-271-3/+8
| | | | | | | | Subscribers: tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D16654 llvm-svn: 259001
* [sanitizers] generating html report on coverage dumpMike Aizatsky2016-01-275-0/+53
| | | | | | | | Subscribers: tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D16374 llvm-svn: 258999
* [sanitizers] using execv instead of execve with null env.Mike Aizatsky2016-01-271-1/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D16646 llvm-svn: 258983
* [sanitizers] execve & waitpid on mac.Mike Aizatsky2016-01-261-0/+10
| | | | llvm-svn: 258874
* Remove autoconf support for building runtime libraries.Chris Bieneman2016-01-261-24/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I am the punishment of God... If [autoconf] had not committed great sins, God would not have sent a punishment like me upon [it]." -Genghis Khan Reviewers: chandlerc, grosbach, bob.wilson, zaks.anna, kubabrecka, samsonov, echristo Subscribers: iains, llvm-commits Differential Revision: http://reviews.llvm.org/D16473 llvm-svn: 258863
* [cfi] Support for dlopen and dlclose.Evgeniy Stepanov2016-01-262-0/+5
| | | | | | Add dlopen/dlclose interceptors to update CFI shadow for loaded/unloaded libraries. llvm-svn: 258857
OpenPOWER on IntegriCloud