summaryrefslogtreecommitdiff
path: root/include/sanitizer
AgeCommit message (Collapse)Author
2017-10-23[Sanitizers] New sanitizer API to purge allocator quarantine.Alex Shlyapnikov
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316347 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-20[tsan] Add Mutex annotation flag for constant-initialized ↵Dmitry Vyukov
__tsan_mutex_linker_init behavior Add a new flag, _⁠_tsan_mutex_not_static, which has the opposite sense of _⁠_tsan_mutex_linker_init. When the new _⁠_tsan_mutex_not_static flag is passed to _⁠_tsan_mutex_destroy, tsan ignores the destruction unless the mutex was also created with the _⁠_tsan_mutex_not_static flag. This is useful for constructors that otherwise woud set _⁠_tsan_mutex_linker_init but cannot, because they are declared constexpr. Google has a custom mutex with two constructors, a "linker initialized" constructor that relies on zero-initialization and sets ⁠_⁠_tsan_mutex_linker_init, and a normal one which sets no tsan flags. The "linker initialized" constructor is morally constexpr, but we can't declare it constexpr because of the need to call into tsan as a side effect. With this new flag, the normal c'tor can set _⁠_tsan_mutex_not_static, the "linker initialized" constructor can rely on tsan's lazy initialization, and _⁠_tsan_mutex_destroy can still handle both cases correctly. Author: Greg Falcon (gfalcon) Reviewed in: https://reviews.llvm.org/D39095 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316209 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-22[lsan] Add __lsan_default_optionsVitaly Buka
For consistency with asan, msan, tsan and ubsan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@314048 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-14[ASAN] Revert r313303 - Add macro denoting availability of new ↵Eric Fiselier
`__asan_handle_no_return()` function. It was pointed out that compiler-rt has always defined the symbol, but only recently added it to the public headers. Meaning that libc++abi can re-declare it instead of needing this macro. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313306 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-14[ASAN] Add macro denoting availability of new `__asan_handle_no_return()` ↵Eric Fiselier
function. Summary: Libc++abi attempts to use the newly added `__asan_handle_no_return()` when built under ASAN. Unfortunately older versions of compiler-rt do not provide this symbol, and so libc++abi needs a way to detect if `asan_interface.h` actually provides the function. This patch adds the macro `SANITIZER_ASAN_INTERFACE_HAS_HANDLE_NO_RETURN` which can be used to detect the availability of the new function. Reviewers: phosek, kcc, vitalybuka, alekseyshl Reviewed By: phosek Subscribers: mclow.lists, cfe-commits Differential Revision: https://reviews.llvm.org/D37871 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313303 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-08Prevent DCE on __lsan_is_turned_off and re-enable test caseFrancis Ricci
Summary: -dead_strip in ld64 strips weak interface symbols, which I believe is most likely the cause of this test failure. Re-enable after marking the interface function as used. Reviewers: alekseyshl, kubamracek, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37635 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312824 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-28[asan] Move __asan_handle_no_return to public headerPetr Hosek
Heretofore asan_handle_no_return was used only by interceptors, i.e. code private to the ASan runtime. However, on systems without interceptors, code like libc++abi is built with -fsanitize=address itself and should call asan_handle_no_return directly from __cxa_throw so that no interceptor is required. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D36811 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311869 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27[sancov] Implement __sanitizer_cov_reset.Evgeniy Stepanov
Summary: Clears all collected coverage. Reviewers: kcc Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D35958 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309333 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-02[sanitizer-coverage] nuke more stale codeKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304504 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01[sanitizer-coverage] nuke more stale codeKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304500 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-31[sanitizer-coverage] remove stale code (old coverage); compiler-rt part Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304318 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03[tsan] Detect races on modifying accesses in Swift codeKuba Mracek
This patch allows the Swift compiler to emit calls to `__tsan_external_write` before starting any modifying access, which will cause TSan to detect races on arrays, dictionaries and other classes defined in non-instrumented modules. Races on collections from the Swift standard library and user-defined structs and a frequent cause of subtle bugs and it's important that TSan detects those on top of existing LLVM IR instrumentation, which already detects races in direct memory accesses. Differential Revision: https://reviews.llvm.org/D31630 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302050 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01tsan: support linker init flag in __tsan_mutex_destroyDmitry Vyukov
For a linker init mutex with lazy flag setup (no __tsan_mutex_create call), it is possible that no lock/unlock happened before the destroy call. Then when destroy runs we still don't know that it is a linker init mutex and will emulate a memory write. This in turn can lead to false positives as the mutex is in fact linker initialized. Support linker init flag in destroy annotation to resolve this. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301795 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21[tsan] Publish the TSan external API in tsan_interface.hKuba Mracek
Let's make the TSan external API available and commented in the public header: void *__tsan_external_register_tag(const char *object_type); void __tsan_external_assign_tag(void *addr, void *tag); void __tsan_external_read(void *addr, void *caller_pc, void *tag); void __tsan_external_write(void *addr, void *caller_pc, void *tag); Differential Revision: https://reviews.llvm.org/D32358 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301003 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19[sanitizer-coverage] remove more unused codeKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300780 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19[sanitizer-coverage] remove run-time support for ↵Kostya Serebryany
-fsanitize-coverage=indirect-calls git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300775 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19[sanitizer-coverage] remove run-time support for the deprecated ↵Kostya Serebryany
-fsanitize-coverage=8bit-counters git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300745 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-26tsan: add new mutex annotationsDmitry Vyukov
There are several problems with the current annotations (AnnotateRWLockCreate and friends): - they don't fully support deadlock detection (we need a hook _before_ mutex lock) - they don't support insertion of random artificial delays to perturb execution (again we need a hook _before_ mutex lock) - they don't support setting extended mutex attributes like read/write reentrancy (only "linker init" was bolted on) - they don't support setting mutex attributes if a mutex don't have a "constructor" (e.g. static, Java, Go mutexes) - they don't ignore synchronization inside of lock/unlock operations which leads to slowdown and false negatives The new annotations solve of the above problems. See tsan_interface.h for the interface specification and comments. Reviewed in https://reviews.llvm.org/D31093 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-15[asan] add one more argument to __sanitizer_print_memory_profile, remove a ↵Kostya Serebryany
redundant weak definition. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297914 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-12[sancov] __sanitizer_dump_coverage apiMike Aizatsky
Subscribers: kubabrecka, mgorny Differential Revision: https://reviews.llvm.org/D26758 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289498 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05[sanitizers] __sanitizer_get_module_and_offset_for_pc interface functionMike Aizatsky
Summary: The function computes full module name and coverts pc into offset. Reviewers: kcc Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D26820 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288711 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-04[sanitizer-coverage] remove stale code, second attempt after failed r282994Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283185 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-28[ASAN] Pass previous stack information through __sanitizer_finish_switch_fiberDmitry Vyukov
This patch extends __sanitizer_finish_switch_fiber method to optionally return previous stack base and size. This solves the problem of coroutines/fibers library not knowing the original stack context from which the library is used. It's incorrect to assume that such context is always the default stack of current thread (e.g. one such library may be used from a fiber/coroutine created by another library). Bulding a separate stack tracking mechanism would not only duplicate AsanThread, but also require each coroutines/fibers library to integrate with it. Author: Andrii Grynenko (andriigrynenko) Reviewed in: https://reviews.llvm.org/D24628 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282582 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19[sanitizer] rename __sanitizer_symbolize_data to ↵Kostya Serebryany
__sanitizer_symbolize_global (to avoid conflict with another definition) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281902 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19[sanitizer] add __sanitizer_symbolize_data (can only print the names of the ↵Kostya Serebryany
globals for now) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281886 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25[sanitizer] add __sanitizer_symbolize_pc. ↵Kostya Serebryany
https://github.com/google/sanitizers/issues/322 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279780 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-05[sanitizers] trace buffer API to use user-allocated buffer.Mike Aizatsky
Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D23186 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277858 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19[esan|wset] Fix flaky sampling testsDerek Bruening
Adds a new esan public interface routine __esan_get_sample_count() and uses it to ensure that tests of sampling receive the minimum number of samples. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275948 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15[sanitizers] add interceptor for memmem; add weak hooks for strncasecmp, ↵Kostya Serebryany
strcasecmp, strstr, strcasestr, memmem git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-09[esan] Add __esan_report for mid-run dataDerek Bruening
Summary: Adds a new public interface routine __esan_report() which can be used to request profiling results prior to abnormal termination (e.g., for a server process killed by its parent where the normal exit does not allow for normal result reporting). Implements this for the working-set tool. The cache frag tool is left unimplemented as it requires missing iteration capabilities. Adds a new test. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D22098 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274964 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24[sanitizer] Add syscall handlers for sigaction and rt_sigaction.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273746 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21[asan] add primitives that allow coroutine implementationsDmitry Vyukov
This patch adds the __sanitizer_start_switch_fiber and __sanitizer_finish_switch_fiber methods inspired from what can be found here https://github.com/facebook/folly/commit/2ea64dd24946cbc9f3f4ac3f6c6b98a486c56e73 . These methods are needed when the compiled software needs to implement coroutines, fibers or the like. Without a way to annotate them, when the program jumps to a stack that is not the thread stack, __asan_handle_no_return shows a warning about that, and the fake stack mechanism may free fake frames that are still in use. Author: blastrock (Philippe Daouadi) Reviewed in http://reviews.llvm.org/D20913 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273260 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16[sanitizers] introduce yet another API function: ↵Kostya Serebryany
__sanitizer_install_malloc_and_free_hooks git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272943 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02[asan] fix arm buildKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271474 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02[asan] add an interface function __sanitizer_print_memory_profile (a basic ↵Kostya Serebryany
memory profiler; asan/Linux-only for now) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271463 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27[sanitizers] introduce __sanitizer_set_report_fd so that we can re-route the ↵Kostya Serebryany
sanitizer logging to another fd from inside the process git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271046 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-12[libFuzzer] extend the weak memcmp/strcmp/strncmp interceptors to receive ↵Kostya Serebryany
the result of the computations. With that, don't do any mutations if memcmp/etc returned 0 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257423 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-05[sancov] coverage pc bufferMike Aizatsky
Differential Revision: http://reviews.llvm.org/D15871 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256804 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-04Asan: utility function to determine first wrongly poisoned byte inMike Aizatsky
container. Differential Revision: http://reviews.llvm.org/D14341 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252071 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22[sanitizer-coverage] introduce __sanitizer_get_total_unique_caller_callee_pairsKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251071 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12[msan] Add __msan_copy_shadow interface function.Evgeniy Stepanov
This can be used to annotate copies of memory that are not observed by MSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@250124 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21[MSan] Deprecate __msan_set_death_callback() in favor of ↵Alexey Samsonov
__sanitizer_set_death_callback(). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245754 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across ↵Alexey Samsonov
all sanitizers. Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245734 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30[sanitizer] add a weak hook for strncmp interceptor, both to dfsan and other ↵Kostya Serebryany
sanitizers. Hide the declaration and the calls in better macros git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243610 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-30[sanitizer] add a weak hook for memcmp interceptor, to be used primarily for ↵Kostya Serebryany
fuzzing. More hooks will be added later. So far this is a Linux-only feature git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243601 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-17re-added changes due to svn config setting issuesNaomi Musgrave
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242589 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-07Add dfsan_weak_hook_memcmpKostya Serebryany
Summary: Add a weak hook to be called from dfsan's custom memcmp. The primary user will be lib/Fuzzer. If this works well we'll add more hooks (strcmp, etc). Test Plan: Will be covered by lib/Fuzzer tests. Reviewers: pcc Reviewed By: pcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9541 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@236679 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-24[lsan] Add an interface function for on-demand leak checking.Sergey Matveev
Summary: Add an interface function which can be used to periodically trigger leak detection in a long-running process. NB: The meaning of the kIgnored tag has been changed to allow easy clean-up between subsequent leak checks. Previously, this tag was applied to explicitly ignored (i.e. with __lsan_disable() or __lsan_ignore_object()) chunks *and* any chunks only reachable from those. With this change, it's only applied to explicitly ignored chunks. Reviewers: samsonov Reviewed By: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9159 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@235728 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-24Revert r235726 "interface"Sergey Matveev
Accidentally committed from local branch. :( git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@235727 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-24interfaceSergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@235726 91177308-0d34-0410-b5e6-96231b3b80d8