summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan
Commit message (Collapse)AuthorAgeFilesLines
...
* [asan] Bail out on stack overflow in recovery mode.Maxim Ostapenko2016-05-061-1/+1
| | | | | | | | | | In recovery mode, when ASan detects stack overflow (say, when infinite recursion detected), it tries to continue program execution and hangs on repetitive error reports. There isn't any sense to do it, we can just bail out on stack overflow error, because the program would crash soon anyway. Differential Revision: http://reviews.llvm.org/D19958 llvm-svn: 268713
* [scan-build] fix logic error warning emitted on compiler-rt code baseKostya Serebryany2016-05-021-0/+1
| | | | | | | | | | | | | | | | | Summary: Fix a "called c++ object pointer is null" warning emitted by Clang Static Analyzer on the following file: - lib/asan/asan_suppressions.cc. Signed-off-by: Apelete Seketeli <apelete@seketeli.net> Reviewers: kcc Subscribers: Eugene.Zelenko, kubabrecka, llvm-commits Differential Revision: http://reviews.llvm.org/D19627 llvm-svn: 268282
* [ASan] Add shadow offset for SystemZ.Marcin Koscielnicki2016-04-302-0/+19
| | | | | | | | This is the compiler-rt counterpart to D19650. Differential Revision: http://reviews.llvm.org/D19652 llvm-svn: 268162
* [asan] Assert in __sanitizer_ptr_{sub,cmp} if one of the pointers was freed.Filipe Cabecinhas2016-04-293-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This (partially) implements the check mentioned at http://kristerw.blogspot.co.uk/2016/04/dangling-pointers-and-undefined-behavior.html (via John Regehr) Quoting: "That the behavior is undefined follows from C11 6.2.4 "Storage durations of objects" The lifetime of an object is the portion of program execution during which storage is guaranteed to be reserved for it. An object exists, has a constant address, and retains its last-stored value throughout its lifetime. If an object is referred to outside of its lifetime, the behavior is undefined. The value of a pointer becomes indeterminate when the object it points to (or just past) reaches the end of its lifetime. and 7.22.3 "Memory management functions" that says that free ends the lifetime of objects The lifetime of an allocated object extends from the allocation until the deallocation. " We can probably implement this for stack variables too, but I think this is a good start to see if there's interest in this check. We can also hide this behind a flag, too. Reviewers: samsonov, kcc, rsmith, regehr Subscribers: kubabrecka, llvm-commits Differential Revision: http://reviews.llvm.org/D19691 llvm-svn: 268097
* [ASan] Reenable __builtin_setjmp test on PowerPC, disable on SystemZ.Marcin Koscielnicki2016-04-281-6/+5
| | | | | | | | | | | | Since __builtin_setjmp has been fixed by rL267943, the test now works on PowerPC. Enable it. On the other hand, the SystemZ backend doesn't currently support __builtin_setjmp. Disable it. Differential Revision: http://reviews.llvm.org/D19657 llvm-svn: 267946
* [sanitizers] Get the proper symbol version when long double transition is ↵Marcin Koscielnicki2016-04-271-0/+2
| | | | | | | | | | | | | | | | | 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 llvm-svn: 267794
* [sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.Marcin Koscielnicki2016-04-271-0/+1
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 267747
* [sanitizers] [NFC] Add defines for the various PowerPC ABIs.Marcin Koscielnicki2016-04-261-1/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D19542 llvm-svn: 267586
* [sanitizer] rename MmapNoAccess to MmapFixedNoAccess; NFCKostya Serebryany2016-04-221-2/+2
| | | | llvm-svn: 267253
* Revert "[LSAN] Fix test swapcontext.cc on MIPS"Renato Golin2016-04-221-4/+1
| | | | | | This reverts commit r266716, as it breaks the self-hosting on Thumb2 buildbot. llvm-svn: 267158
* [asan] Add __strdup interceptor.Evgeniy Stepanov2016-04-202-0/+26
| | | | | | This happens on Linux when building as C (not C++) with optimization. llvm-svn: 266931
* [LSAN] Fix test swapcontext.cc on MIPSSagar Thakur2016-04-191-1/+4
| | | | | | | | | 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 llvm-svn: 266716
* [asan] [SystemZ] Add slop for stack address detection.Marcin Koscielnicki2016-04-181-0/+8
| | | | | | | | | On s390, siginfo reports the faulting address with page granularity - we need to mask off the low bits of sp before comparison. Differential Revision: http://reviews.llvm.org/D19112 llvm-svn: 266593
* Revert "[sanitizer] [SystemZ] Abort if the kernel might be vulnerable to ↵Marcin Koscielnicki2016-04-151-7/+0
| | | | | | | | CVE-2016-2143." This reverts commit r266297. llvm-svn: 266470
* [sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.Marcin Koscielnicki2016-04-141-0/+7
| | | | | | | | | | | | | | | | | | 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/D18915 llvm-svn: 266297
* [asan] Prefer alloc-dealloc-mismatch to new-delete-type-mismatch.Evgeniy Stepanov2016-04-133-15/+17
| | | | | | | | With -fsized-deallocation, new[] vs delete mismatch is reported as new-delete-type-mismatch. This is technically true, but alloc-dealloc-mismatch describes it better. llvm-svn: 266246
* Fix warnings uncovered by building with clang-clReid Kleckner2016-04-011-2/+2
| | | | | | | Move ifdefs to avoid unused static helpers. Move alignment attribute so that it is respected in GCC and MSVC. llvm-svn: 265153
* [asan] Add runtime support for __asan_(un)register_image_globalsRyan Govostes2016-03-287-6/+77
| | | | | | | | | | | This change introduces routines that register and unregister all instrumented globals in a loaded executable image. These routines are only implemented on Darwin, where globals metadata is expected to be placed in the __DATA,__asan_globals section. Review: http://reviews.llvm.org/D16841 llvm-svn: 264644
* [asan] bump the scariness score of read-after-frees (based on feedback from ↵Kostya Serebryany2016-03-261-1/+5
| | | | | | the Chrome security team) llvm-svn: 264481
* [sanitizer] Add memset, memmove, and memcpy to the common interceptorsDerek Bruening2016-03-252-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [asan] Intercept all Heap* related imports from ucrtbase.dllReid Kleckner2016-03-243-15/+85
| | | | | | | | | | | | | | | | | | | | | | ucrtbase.dll appears to be built with some kind of cross-module inlining, because there are calls to imported Heap* routines sprinkled throughout the code. This inlining defeats our attempts to hotpatch malloc, _malloc_base, and related functions. Failing to intercept an allocation or deallocation results in a crash when the program attempts to deallocate or reallocate memory with the wrong allocator. This change patches the IAT of ucrtbase.dll to replace the addresses of the imported Heap* functions with implementations provided by ASan. We don't globally intercept the win32 Heap* functions because they are typically used by system DLLs that run before ASan initializes. Eventually, we may want to intercept them, but for now I think this is the minimal change that will keep ASan stable. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D18413 llvm-svn: 264327
* [sanitizer] Add strnlen to the common interceptorsDerek Bruening2016-03-232-23/+1
| | | | | | | | | | | | | | | | | | | 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
* [asan] Export new and delete operators on WindowsReid Kleckner2016-03-232-18/+17
| | | | | | | | | | | | | | | | | | | | | | This is necessary to support the dynamic CRT (/MD) with VS2015. In VS2015, these symbols are no longer imported from a DLL, they provided statically by msvcrt.lib. This means our approach of hotpatching the DLL no longer works. By exporting the symbols, we end up relying on the same mechanism that we use to intercept symbols in the static CRT (/MT) case. The ASan runtime always needs to appear first on the link line, and the linker searches for symbol definitions from left to right. This means we can stop hotpatching operator new and delete in the CRT, which is nice. I think that the only reason we weren't exporting the symbols already is because MSVC doesn't allow you to do it directly with __declspec(dllexport). Instead, we can use `#pragma comment(linker, "/export:foo")`, which is most of what the attribute does under the hood. It does mean we have to write down the mangled names of the operators, but that's not too bad. llvm-svn: 264190
* Test commit to verify repository access and fix a typo.Derek Bruening2016-03-221-1/+1
| | | | llvm-svn: 264112
* Move -fms-compatibility-version=19 into target cflagsReid Kleckner2016-03-221-5/+0
| | | | | | | This reduces cflags duplication and allows us to build sanitizer_common/tests with clang and the VS 2015 STL. llvm-svn: 264017
* Wrap 81 character line to satisfy linterReid Kleckner2016-03-221-1/+2
| | | | llvm-svn: 264014
* [asan] Intercept strdup on WindowsReid Kleckner2016-03-223-6/+1
| | | | | | | | Some unit tests were failing because we didn't intercept strdup. It turns out it works just fine on 2013 and 2015 with a small patch to the interception logic. llvm-svn: 264013
* [asan] Also apply r264006 to asan_win_dynamic_runtime_thunk.ccReid Kleckner2016-03-221-2/+2
| | | | llvm-svn: 264011
* [asan] Set the unhandled exception filter slightly later during startupReid Kleckner2016-03-211-4/+10
| | | | | | | | | | | VS 2015 moved the priority of their exception filter initializer from XIY to XCAA. We now set ours to XCAB, which makes it run after both CRT versions but before user constructors, as it should. Fixes null_deref.cc and a variety of related tests with VS 2015. Only 4 failures remain. llvm-svn: 264006
* [asan] Add new _*_base interceptors for VS 2015Reid Kleckner2016-03-212-0/+24
| | | | | | | | | There are some places in the CRT (such as mbctype) that directly call _malloc_base. If you are incrementally linking a binary with ASan from before this change, this change appears to result in a linker error. Retrying the link succeeds for some reason. llvm-svn: 264005
* [asan] Add strrchr to asan_win_dll_thunk.Evgeniy Stepanov2016-03-211-0/+1
| | | | | | "dll_host.cc" test says there is a mismatch. llvm-svn: 263998
* [sanitizer] Add strchr* to the common interceptorsEvgeniy Stepanov2016-03-212-20/+4
| | | | | | | | | | | | | | | | 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
* [sanitizier] initializing common flags.Mike Aizatsky2016-03-211-0/+1
| | | | | | | | Summary: Without SetDefaults() CommonFlags contain garbage. Differential Revision: http://reviews.llvm.org/D18326 llvm-svn: 263985
* [asan] Pass -fms-compatibility-version=19 with VS 2015Reid Kleckner2016-03-211-0/+5
| | | | | | | This resolves errors about char16_t and char32_t when compiling 2015 STL headers with clang. llvm-svn: 263973
* [sancov] common flags initialization.Mike Aizatsky2016-03-182-2/+2
| | | | | | | | | | | | 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
* [sanitizer] On OS X, verify that interceptors work and abort if not, take 2Kuba Brecka2016-03-172-1/+6
| | | | | | | | | | 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
* [ASan] Make sure unittest works if sized-delete is enabled by default.Alexey Samsonov2016-03-151-4/+10
| | | | llvm-svn: 263575
* [sanitizer] Add strlen to the common interceptorsAlexey Samsonov2016-03-112-18/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* sanitizer: Fix endianness checks for gccAlexey Samsonov2016-03-091-1/+1
| | | | | | | | | | | | | | | | | 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
* [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
* [tests] Portability fixup for r261713.Alexey Samsonov2016-02-241-2/+12
| | | | llvm-svn: 261715
* [tests] Resolve old TODOs in ASan unit tests.Alexey Samsonov2016-02-242-15/+32
| | | | llvm-svn: 261713
* [CMake] Assign components and dependencies during add_compiler_rt_resource_fileChris Bieneman2016-02-231-2/+1
| | | | | | This makes it so that component-based installations will include resource files (i.e. blacklists). My next patch will add support for component-based installations. llvm-svn: 261699
* [WinASan] Fix page size and mmap granularity confusionReid Kleckner2016-02-181-5/+5
| | | | | | | | | | | 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
* Don't assume that there is only one strchr overload in the global namespace;Richard Smith2016-02-101-18/+11
| | | | | | | | that's not true in general. Instead, use a preference order to pick the standard C++ signature 'char*(char*, int)' where possible and fall back to the C signature 'char*(const char*, int)' only when it's unavailable. llvm-svn: 260425
* [asan] update the scariness score: tweak a few weights and add testsKostya Serebryany2016-02-091-8/+12
| | | | llvm-svn: 260327
* [asan] Implement SEGV read vs write detection for ARM and AArch64.Evgeniy Stepanov2016-02-081-5/+10
| | | | llvm-svn: 260163
* Fix typo in asan_flags.George Burgess IV2016-02-081-1/+1
| | | | | | Patch by Michael Stapelberg. llvm-svn: 260147
* [asan] fix the Windows build (MSVC says: cannot specify explicit initializer ↵Kostya Serebryany2016-02-081-2/+4
| | | | | | for arrays) llvm-svn: 260132
* [asan] re-commit r259961, this time making the test Linux-OnlyKostya Serebryany2016-02-083-1/+123
| | | | llvm-svn: 260128
OpenPOWER on IntegriCloud