summaryrefslogtreecommitdiff
path: root/include/sanitizer
AgeCommit message (Collapse)Author
2018-07-06[MSan] Add functions to enable/disable interceptor checks.Matt Morehouse
Summary: The motivation for this change is to make libFuzzer+MSan possible without instrumenting libFuzzer. See https://github.com/google/sanitizers/issues/958. Reviewers: eugenis Reviewed By: eugenis Subscribers: llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D48890 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@336447 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01[libFuzzer] Report at most one crash per input.Matt Morehouse
Summary: Fixes https://github.com/google/sanitizers/issues/788/, a deadlock caused by multiple crashes happening at the same time. Before printing a crash report, we now test and set an atomic flag. If the flag was already set, the crash handler returns immediately. Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D46277 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331310 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-25[scudo] Adding an interface function to print allocator statsKostya Kortchinsky
Summary: This adds `__scudo_print_stats` as an interface function to display the Primary and Secondary allocator statistics for Scudo. Reviewers: alekseyshl, flowerhack Reviewed By: alekseyshl Subscribers: delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D46016 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@330857 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-03Remove obsolete ptrace(2) operations from NetBSDKamil Rytarowski
PT_SET_SIGMASK and PT_GET_SIGMASK will be removed from NetBSD without backward compat (it shortlived in a development branch). Sponsored by <The NetBSD Foundation> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@326657 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-15Implement a large part of NetBSD syscalls of netbsd_syscall_hooks.hKamil Rytarowski
This is a follow up of: r325206 - Add NetBSD syscall hooks skeleton in sanitizers Sponsored by <The NetBSD Foundation> git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325248 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-15Add NetBSD syscall hooks skeleton in sanitizersKamil Rytarowski
Summary: Implement the skeleton of NetBSD syscall hooks for use with sanitizers. Add a script that generates the rules to handle syscalls on NetBSD: generate_netbsd_syscalls.awk. It has been written in NetBSD awk(1) (patched nawk) and is compatible with gawk. Generate lib/sanitizer_common/sanitizer_platform_limits_netbsd.h that is a public header for applications, and included as: <sanitizer_common/sanitizer_platform_limits_netbsd.h>. Generate sanitizer_syscalls_netbsd.inc that defines all the syscall rules for NetBSD. This file is modeled after the Linux specific file: sanitizer_common_syscalls.inc. Start recognizing NetBSD syscalls with existing sanitizers: ASan, ESan, HWASan, TSan, MSan. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, kcc, dvyukov, eugenis Reviewed By: vitalybuka Subscribers: hintonda, kubamracek, mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D42048 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325206 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-04[scudo] s/unsigned long/size_t/ for __scudo_set_rss_limitKostya Kortchinsky
Summary: `__scudo_set_rss_limit`'s `LimitMb` should really be a `size_t`. Update accordingly the prototype. To avoid the `NOLINT` and conform with the other Sanitizers, use the sanitizers types for the internal definition. This should have no functional change. Additionally, capitalize a variable name to follow the LLVM coding standards. Reviewers: alekseyshl, flowerhack Reviewed By: alekseyshl Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D41704 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321803 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-21[sanitizer] Make function declarations C-compatiblePetr Hosek
The public sanitizer headers are intended to be usable from either C++ or C, but they declare no-argument functions with the syntax that is not a proper prototype declaration in C. This goes unnoticed until someone uses -Wsystem-headers. Patch By: mcgrathr Reviewers: phosek, vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D41475 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321305 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13[scudo] Adding a public Scudo interfaceKostya Kortchinsky
Summary: The first and only function to start with allows to set the soft or hard RSS limit at runtime. Add associated tests. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: mgorny, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D41128 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320611 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-09Hardware-assisted AddressSanitizer (compiler-rt)Evgeniy Stepanov
Summary: Runtime library for HWASan, initial commit. Does not randomize tags yet, does not handle stack or globals. Reviewers: kcc, pcc, alekseyshl Subscribers: srhines, kubamracek, dberris, mgorny, llvm-commits, krytarowski Differential Revision: https://reviews.llvm.org/D40935 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320231 91177308-0d34-0410-b5e6-96231b3b80d8
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