summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/asan/TestCases
Commit message (Collapse)AuthorAgeFilesLines
...
* [ASan] Disable aligned_alloc-alignment.cc on ppc64beAlex Shlyapnikov2018-03-291-4/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D44404 llvm-svn: 328742
* [ASan] Disable aligned_alloc-alignment.cc test on gcc.Alex Shlyapnikov2018-03-281-0/+3
| | | | | | | | | This check "CHECK: {{#0 0x.* in .*aligned_alloc}}" fails on ppc64be, gcc build. Disabling the test for gcc for now. Differential Revision: https://reviews.llvm.org/D44404 llvm-svn: 328741
* [ASan] Disable aligned_alloc-alignment.cc on Android.Alex Shlyapnikov2018-03-281-1/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D44404 llvm-svn: 328734
* [ASan] Add aligned_alloc declaration to aligned_alloc-alignment.cc test.Alex Shlyapnikov2018-03-281-0/+2
| | | | | | | | aligned_alloc is not always defined in headers. Differential Revision: https://reviews.llvm.org/D44404 llvm-svn: 328726
* [ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ingAlex Shlyapnikov2018-03-288-11/+100
| | | | | | | | | | | | | | | | | | Summary: Currently many allocator specific errors (OOM, for example) are reported as a text message and CHECK(0) termination, not stack, no details, not too helpful nor informative. To improve the situation, ASan detailed errors were defined and reported under the appropriate conditions. Issue: https://github.com/google/sanitizers/issues/887 Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44404 llvm-svn: 328722
* Revert "[asan] Replace vfork with fork."Evgeniy Stepanov2018-03-271-30/+0
| | | | | | | | | Replacing vfork with fork results in significant slowdown of certain apps (in particular, memcached). This reverts r327752. llvm-svn: 328600
* [asan] Replace vfork with fork.Evgeniy Stepanov2018-03-161-0/+30
| | | | | | | | | | | | | | | | | | | | Summary: vfork is not ASan-friendly because it modifies stack shadow in the parent process address space. While it is possible to compensate for that with, for example, __asan_handle_no_return before each call to _exit or execve and friends, simply replacing vfork with fork looks like by far the easiest solution. Posix compliant programs can not detect the difference between vfork and fork. Fixes https://github.com/google/sanitizers/issues/925 Reviewers: kcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D44587 llvm-svn: 327752
* [asan] poison_heap=0 should not disable __asan_handle_no_return.Evgeniy Stepanov2018-03-121-0/+13
| | | | | | | | | | Reviewers: kcc, alekseyshl, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D44339 llvm-svn: 327337
* [asan] Clean up the REQUIRES of `asan/TestCases/strcat-overlap.cc`Dan Liew2018-03-091-1/+5
| | | | | | | | | | | | by explicitly listing where we expect this test to work. Because this test invokes undefined behaviour all sorts of things can happen (e.g. crash, or on some bots asan manages to catch something). The test seems to pass okay on Darwin (x86_64/x86_64/i386) and on Linux (x86_64/i386) so explicitly require one of these platforms to run the test. llvm-svn: 327185
* [asan] Try to unbreak arm build bots by only running the test onDan Liew2018-03-091-0/+1
| | | | | | | x86_64 and x86_64H (and not in the iOS simulator) where it seems to work. We need to properly fix the test when time permits. llvm-svn: 327122
* Mark the -overlap tests are "UNSUPPORTED: android". Android test harness ↵Kuba Mracek2018-03-094-0/+7
| | | | | | doesn't know how to handle suppression files. llvm-svn: 327091
* Mark strcat-overlap.cc as "UNSUPPORTED: win32"Kuba Mracek2018-03-091-0/+2
| | | | llvm-svn: 327081
* Move lto-constmerge-odr.cc to Posix (it's failing on Windows).Kuba Mracek2018-03-081-0/+0
| | | | llvm-svn: 327080
* [asan] Fix bug where suppression of overlapping accesses was ignored onDan Liew2018-03-084-0/+184
| | | | | | | | | | `strcpy()`, `strncpy()`, `strcat()`, and `strncat()`. rdar://problem/35576899 Differential Revision: https://reviews.llvm.org/D43702 llvm-svn: 327068
* [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass ↵Kuba Mracek2018-03-082-9/+17
| | | | | | | | | | [compiler-rt part, take 3] This fixes a false positive ODR violation that is reported by ASan when using LTO. In cases, where two constant globals have the same value, LTO will merge them, which breaks ASan's ODR detection. See the included testcase for an example. Differential Revision: https://reviews.llvm.org/D43959 llvm-svn: 327062
* More revert of r327031Kuba Mracek2018-03-081-0/+0
| | | | llvm-svn: 327038
* Revert r327031Kuba Mracek2018-03-082-17/+9
| | | | llvm-svn: 327032
* [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass ↵Kuba Mracek2018-03-082-9/+17
| | | | | | | | | | [compiler-rt part] This fixes a false positive ODR violation that is reported by ASan when using LTO. In cases, where two constant globals have the same value, LTO will merge them, which breaks ASan's ODR detection. Differential Revision: https://reviews.llvm.org/D43959 llvm-svn: 327031
* [asan] Intercept std::rethrow_exception indirectlyVitaly Buka2018-02-261-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fixes Bug 32434 See https://bugs.llvm.org/show_bug.cgi?id=32434 Short summary: std::rethrow_exception does not use __cxa_throw to rethrow the exception, so if it is called from uninstrumented code, it will leave the stack poisoned. This can lead to false positives. Long description: For functions which don't return normally (e.g. via exceptions), asan needs to unpoison the entire stack. It is not known before a call to such a function where execution will continue, some function which don't contain cleanup code like destructors might be skipped. After stack unwinding, execution might continue in uninstrumented code. If the stack has been poisoned before such a function is called, but the stack is unwound during the unconventional return, then zombie redzones (entries) for no longer existing stack variables can remain in the shadow memory. Normally, this is avoided by asan generating a call to asan_handle_no_return before all functions marked as [[noreturn]]. This asan_handle_no_return unpoisons the entire stack. Since these [[noreturn]] functions can be called from uninstrumented code, asan also introduces interceptor functions which call asan_handle_no_return before running the original [[noreturn]] function; for example, cxa_throw is intercepted. If a [[noreturn]] function is called from uninstrumented code (so the stack is left poisoned) and additionally, execution continues in uninstrumented code, new stack variables might be introduced and overlap with the stack variables which have been removed during stack unwinding. Since the redzones are not cleared nor overwritten by uninstrumented code, they remain but now contain invalid data. Now, if the redzones are checked against the new stack variables, false positive reports can occur. This can happen for example by the uninstrumented code calling an intercepted function such as memcpy, or an instrumented function. Intercepting std::rethrow_exception directly is not easily possible since it depends on the C++ standard library implementation (e.g. libcxx vs libstdc++) and the mangled name it produces for this function. As a rather simple workaround, we're intercepting _Unwind_RaiseException for libstdc++. For libcxxabi, we can intercept the ABI function __cxa_rethrow_primary_exception. Patch by Robert Schneider. Reviewers: kcc, eugenis, alekseyshl, vitalybuka Reviewed By: vitalybuka Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42644 llvm-svn: 326132
* Use NULL instead of nullptr in invalid-pointer-pairs-compare-null.cc; ↵Kuba Mracek2018-02-021-8/+8
| | | | | | nullptr is not available on older Darwin systems. llvm-svn: 324136
* [asan] Make concurrent_overflow.cc less flakyKuba Mracek2018-02-021-3/+4
| | | | | | | | The "sleep(5)" sometimes times out on our bots, causing the test to fail. Let's use pthread_join. Differential Revision: https://reviews.llvm.org/D42862 llvm-svn: 324126
* Make detect_invalid_pointer_pairs option to be tristate.Alex Shlyapnikov2018-02-016-6/+48
| | | | | | | | | | | | | | | | Summary: With the change, one can choose not to report comparison (or subtraction) of a pointer with nullptr pointer. Reviewers: kcc, jakubjelinek, alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D41479 llvm-svn: 323995
* [PowerPC][asan] Fix asan tests to handle changed memory layoutsBill Seurer2018-01-231-5/+13
| | | | | | | | | | In more recent Linux kernels with 47 bit VMAs the layout of virtual memory for powerpc64 changed causing the address sanitizer to not work properly. This patch fixes up a test case that was found to fail on some newer Fedora releases that use different address ranges. ref: https://reviews.llvm.org/D40907 llvm-svn: 323217
* Small fixes for detect_invalid_pointer_pairs.Alex Shlyapnikov2018-01-222-1/+5
| | | | | | | | | | | | | | | | | Summary: One test-case uses a wrong operation (should be subtraction). Second test-case should declare a global variables before a tested one in order to guarantee we will find a red-zone. Reviewers: kcc, jakubjelinek, alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek Differential Revision: https://reviews.llvm.org/D41481 llvm-svn: 323162
* Hotfix for test/asan/TestCases/alloca_constant_size.ccKamil Rytarowski2018-01-171-0/+1
| | | | | | Add missing endif. llvm-svn: 322638
* [Sanitizers, test] Fix sanitizer tests on Solaris (PR 33274)Kamil Rytarowski2018-01-179-4/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch (on top of the previous two (https://reviews.llvm.org/D40898 and https://reviews.llvm.org/D40899) complete the compiler-rt side of the the Solaris sanitizer port. It contains the following sets of changes: * For the time being, the port is for 32-bit x86 only, so reject the various tests on x86_64. * When compiling as C++, <setjmp.h> resp. <iso/setjmp_iso.h> only declares _setjmp and _longjmp inside namespace std. * MAP_FILE is a Windows feature. While e.g. Linux <sys/mman.h> provides a no-op compat define, Solaris does not. * test/asan/TestCases/Posix/coverage.cc was initially failing like this: /vol/gcc/src/llvm/llvm/local/projects/compiler-rt/lib/sanitizer_common/scripts/sancov.py: 4 files merged; 2 PCs total rm: cannot remove '/var/gcc/llvm/local/projects/compiler-rt/test/asan/I386SunOSConfig/TestCases/Posix/Output/coverage': Invalid argument Further digging revealed that the rm was trying to remove the running test's working directory which failed as observed. cd'ing out of the dir before let the test pass. * Two tests needed a declaration of alloca. I've now copied the existing code from test/asan/TestCases/alloca_constant_size.cc, but it may be more profitable and maintainable to have a common testsuite header where such code is collected. * Similarly, Solaris' printf %p format doesn't include the leading 0x. * In test/asan/TestCases/malloc-no-intercept.c, I had to undef __EXTENSIONS__ (predefined by clang for no apparent reason) to avoid conflicting declarations for memalign. * test/ubsan/TestCases/Float/cast-overflow.cpp has different platform dependent ways to define BYTE_ORDER and friends. Why not just use __BYTE_ORDER__ and friends as predefined by clang and gcc? Patch by Rainer Orth. Reviewers: kcc, alekseyshl Reviewed By: alekseyshl Subscribers: srhines, kubamracek, mgorny, krytarowski, fedor.sergeev, JDevlieghere, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40900 llvm-svn: 322635
* [Sanitizers] Export aligned new/delete from runtimes.Alex Shlyapnikov2017-12-231-31/+3
| | | | | | | | | | | | | | | | Summary: Export aligned new/delete to make dynamic runtimes work again. Remove all valid new/delete cases from ASan test, there's a test in common for that. Reviewers: eugenis Subscribers: srhines, kubamracek, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D41548 llvm-svn: 321394
* [asan] Add interceptor for printf_chkMaxim Ostapenko2017-12-185-0/+98
| | | | | | | | | | | | There could be a situation when a specific DSO was built with FORTIFY_SOURCE option. In case asan-ed binary link against that DSO, libasan can't handle the possible memory error because it does not have interceptors for spinrtf_chk, snprintf_chk, vprintf_chk, vsnprintf_chk, __fprintf_chk functions. Let's interceptors for them. Patch by Denis Khalikov. Differential Revision: https://reviews.llvm.org/D40951 llvm-svn: 320990
* Update another sanitizer test for C++14.Ahmed Bougacha2017-12-101-1/+1
| | | | | | Follow-up to r320251. llvm-svn: 320284
* Update sanitizer tests for C++14 default in ClangTim Northover2017-12-091-2/+2
| | | | llvm-svn: 320251
* [PowerPC][asan] Update asan to handle changed memory layouts in newer kernelsBill Seurer2017-12-071-6/+13
| | | | | | | | | | | | | | | In more recent Linux kernels with 47 bit VMAs the layout of virtual memory for powerpc64 changed causing the address sanitizer to not work properly. This patch adds support for 47 bit VMA kernels for powerpc64 and fixes up test cases. https://reviews.llvm.org/D40908 There is an associated patch for trunk. Tested on several 4.x and 3.x kernel releases. llvm-svn: 320110
* [ASan] Disable invalid-pointer-pairs-threads.cc on Darwin.Alex Shlyapnikov2017-12-041-0/+3
| | | | | | | | pthread barriers are not available on OS X Differential revision: https://reviews.llvm.org/D40600 llvm-svn: 319681
* [ASan] Fix test/asan/TestCases/Posix/invalid-pointer-pairs-threads.ccAlex Shlyapnikov2017-12-041-1/+1
| | | | | | | | Explicitly add pthread for asan-dynamic config. Differential revision: https://reviews.llvm.org/D40600 llvm-svn: 319671
* [ASan] Enhance libsanitizer support for invalid-pointer-pair.Alex Shlyapnikov2017-12-045-0/+312
| | | | | | | | | | | | | | | | | | | | Following patch adds support of all memory origins in CheckForInvalidPointerPair function. For small difference of pointers, it's directly done in shadow memory (the limit was set to 2048B). Then we search for origin of first pointer and verify that the second one has the same origin. If so, we verify that it points either to a same variable (in case of stack memory or a global variable), or to a same heap segment. Committing on behanf of marxin and jakubjelinek. Reviewers: alekseyshl, kcc Subscribers: llvm-commits Differential revision: https://reviews.llvm.org/D40600 llvm-svn: 319668
* Add missing signal.h header:Ismail Donmez2017-12-011-0/+1
| | | | | | | | | | | | | | | /havana/work/llvm/projects/compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cc:158:20: error: variable has incomplete type 'struct sigaction' struct sigaction act = {}; ^ /havana/work/llvm/projects/compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cc:158:10: note: forward declaration of 'sigaction' struct sigaction act = {}; ^ /havana/work/llvm/projects/compiler-rt/test/asan/TestCases/Linux/swapcontext_annotation.cc:160:17: error: use of undeclared identifier 'SIGPROF' if (sigaction(SIGPROF, &act, 0)) { ^ 2 errors generated. llvm-svn: 319532
* [sanitizer] Add 'strip_env' flag to enable/disable removing sanitizer dylib ↵Kuba Mracek2017-11-291-0/+6
| | | | | | | | | | from DYLD_INSERT_LIBRARIES On macOS, we usually don't require launching the target with DYLD_INSERT_LIBRARIES anymore. However, it is still necessary when running a target that is not instrumented (and e.g. dlopen's an instrument library later). In any case, ASan and TSan currently remove themselves from the DYLD_INSERT_LIBRARIES environment variable to avoid passing it onto children. This works well e.g. when instrumenting a shell. A problem arises when the target is a non-instrumented shim (e.g. "xcrun") that either re-execs or launches a child that is supposed to get DYLD_INSERT_LIBRARIES propagated. To support this mode, this patch introduces 'strip_env' flag that can be used to keep DYLD_INSERT_LIBRARIES untouched. Differential Revision: https://reviews.llvm.org/D39991 llvm-svn: 319365
* [asan] Don't crash on fclose(NULL)Kuba Mracek2017-11-291-0/+13
| | | | | | | | It's explicitly forbidden to call fclose with NULL, but at least on Darwin, this succeeds and doesn't segfault. To maintain binary compatibility, ASan should survice fclose(NULL) as well. Differential Revision: https://reviews.llvm.org/D40053 llvm-svn: 319347
* [asan] Allow getpwnam(NULL) for binary compatibilityKuba Mracek2017-11-291-0/+15
| | | | | | | | Calling getpwnam(NULL) is probably a bug, but at least on Darwin, such a call succeeds without segfaulting. I have some existing code that relies on that. To maintain binary compatibility, ASan should also survive a call to getpwnam with NULL. Differential Revision: https://reviews.llvm.org/D40052 llvm-svn: 319344
* Enable PDB generation with lld in asan and cfi tests on Windows.Peter Collingbourne2017-11-171-5/+1
| | | | | | | | | PDB emission now works well enough that we can rely on it for these tests to pass. Differential Revision: https://reviews.llvm.org/D40188 llvm-svn: 318546
* [asan] Properly mark or disable tests that only work with shadow scale of 3Walter Lee2017-11-1611-9/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D39774 llvm-svn: 318471
* [asan] Port tests to shadow scale of 5Walter Lee2017-11-166-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | The tests are ported as follows: contiguous_container_crash.cc use-after-delete.cc use-after-free.cc Replace hardwired shadow granularity in CHECK statements with regex. max_redzone.cc Bump max_redzone parameter to 32. memset_test.cc Bump size parameter of __asan_poison_memory_region to 32. scariness_score_test.cc For "far-from-bounds" heap overflow, make sure overflow is more than one shadow granularity away. At large shadow granularity, there is not enough redzone between stack elements to detect far-from-bounds, so fake out that test. Differential Revision: https://reviews.llvm.org/D39773 llvm-svn: 318470
* Revert new ThinLTO ASAN test until lit support addedTeresa Johnson2017-11-091-55/+0
| | | | | | | This reverts commit r317723 and r317728. Will be re-added when support for LTO/ThinLTO added to test/asan/lit.cfg. llvm-svn: 317823
* [ThinLTO] New test needs to require LTOTeresa Johnson2017-11-081-0/+2
| | | | | | | Fix buildbot failures: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/5262/steps/annotate/logs/stdio llvm-svn: 317728
* [ThinLTO] Ensure sanitizer passes are runTeresa Johnson2017-11-081-0/+53
| | | | | | Recommit new test as linux-only. llvm-svn: 317723
* Revert "[ThinLTO] Ensure sanitizer passes are run"Teresa Johnson2017-11-081-6/+0
| | | | | | | | | | | | This reverts commit r317715. It failed a Windows buildbot since ThinLTO is presumably not supported, leading to a corrupt file error on the object file: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/19395/steps/run%20check-asan/logs/stdio Will re-commit the new ThinLTO part of the test to a linux only test file. llvm-svn: 317717
* [ThinLTO] Ensure sanitizer passes are runTeresa Johnson2017-11-081-0/+6
| | | | | | | | | | | | | | | Summary: Test fix to pass manager for ThinLTO. Depends on D39565. Reviewers: pcc Subscribers: kubamracek, mehdi_amini, llvm-commits, inglorion Differential Revision: https://reviews.llvm.org/D39566 llvm-svn: 317715
* [Sanitizers] ASan: detect new/delete calls with mismatched alignment.Alex Shlyapnikov2017-10-251-0/+168
| | | | | | | | | | | | | | | | | | | ASan allocator stores the requested alignment for new and new[] calls and on delete and delete[] verifies that alignments do match. The representable alignments are: default alignment, 8, 16, 32, 64, 128, 256 and 512 bytes. Alignments > 512 are stored as 512, hence two different alignments > 512 will pass the check (possibly masking the bug), but limited memory requirements deemed to be a resonable tradeoff for relaxed conditions. The feature is controlled by new_delete_type_mismatch flag, the same one protecting new/delete matching size check. Differential revision: https://reviews.llvm.org/D38574 Issue: https://github.com/google/sanitizers/issues/799 llvm-svn: 316595
* [Sanitizers] New sanitizer API to purge allocator quarantine.Alex Shlyapnikov2017-10-231-6/+12
| | | | | | | | | | | | | | | | Summary: Purging allocator quarantine and returning memory to OS might be desired between fuzzer iterations since, most likely, the quarantine is not going to catch bugs in the code under fuzz, but reducing RSS might significantly prolong the fuzzing session. Reviewers: cryptoad Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D39153 llvm-svn: 316347
* ASan allocates a global data initialization array at the tail end of eachDmitry Mikulin2017-09-272-0/+18
| | | | | | | | | | | | | | | | compunit's .data section. This vector is not poisoned. Because of this the first symbol of the following section has no left red zone. As a result, ASan cannot detect underflow for such symbols. Poison ASan allocated metadata, it should not be accessible to user code. This fix does not eliminate the problem with missing left red zones but it reduces the set of vulnerable symbols from first symbols in each input data section to first symbols in the output section of the binary. Differential Revision: https://reviews.llvm.org/D38056 llvm-svn: 314365
* [mips][asan] Fix preinstalled_signal.cc test for mipsSimon Dardis2017-09-261-0/+6
| | | | | | | | Linux for mips has a non-standard layout for the kernel sigaction struct. Adjust the layout by the minimally amount to get the test to pass, as we don't require the usage of the restorer function. llvm-svn: 314200
OpenPOWER on IntegriCloud