summaryrefslogtreecommitdiff
path: root/lib/safestack
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/{interception/tests,safestack} to .cppNico Weber2019-08-012-2/+4
| | | | | | | | Like r367463, but for interception/tests and safestack. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367560 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Explain why tinfo at the end of the bufferVitaly Buka2019-02-071-0/+2
| | | | | | | | | | | | | | Reviewers: pcc, eugenis, vlad.tsyrklevich Reviewed By: vlad.tsyrklevich Subscribers: llvm-commits, jfb, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D57863 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@353482 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Remove pageSizeVitaly Buka2019-02-071-9/+2
| | | | | | | | | | | | | | | | | Summary: 3rd party sysconf interceptor may crash if it's called before unsafe_stack_setup However pageSize is not useful here. mmap should round up on it's own, SFS_CHECK can be removed. Reviewers: eugenis, vlad.tsyrklevich Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D57924 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@353481 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Don't crash if stack size is not aligned as expectedVitaly Buka2019-02-071-1/+1
| | | | | | | | | | | | | | | | Summary: From runtime side looks it's OK to RoundUpTo to needed alignment as buffer is going to be RoundUpTo to page size anyway. Reviewers: eugenis, pcc Subscribers: #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D57866 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@353475 91177308-0d34-0410-b5e6-96231b3b80d8
* Enhance support for NetBSD in SafeStackKamil Rytarowski2019-01-251-5/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Always try to detect and call internal or real libc symbols instead of locally installed interceptors. This covers: - GetTid() - TgKill() - Mmap() - Munmap() - Mprotect() This cherry-picks code from sanitizer_common/sanitizer_netbsd.cc. Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D57179 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@352154 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Return syscalls for mmap, munmap and mprotectVitaly Buka2019-01-222-4/+31
| | | | | | This function can be already intercepted by instrumented code. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351783 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Remove unsupported platformsVitaly Buka2019-01-211-12/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351716 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Fix FreeBSD runtime buildVitaly Buka2019-01-211-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351715 91177308-0d34-0410-b5e6-96231b3b80d8
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-193-12/+9
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Add ThreadId type as uint64_tVitaly Buka2019-01-182-4/+11
| | | | | | | | | | Reviewers: krytarowski, eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D56937 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351607 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Remove dependency of SafeStack on sanitizer_commonVitaly Buka2019-01-184-35/+138
| | | | | | | | | | | | | | Summary: SafeStack needs just few functions from there, but sanitizer_common introduces conflicts with other runtimes, e.g. SCUDO. Reviewers: eugenis, kcc, cryptoad Subscribers: mgorny, krytarowski, fedor.sergeev, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D56886 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351506 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Replace statics with unnamed namespaceVitaly Buka2019-01-181-29/+33
| | | | | | | | | | Reviewers: eugenis Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D56888 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351503 91177308-0d34-0410-b5e6-96231b3b80d8
* SafeStack: Fix thread liveness check on *BSDVlad Tsyrklevich2018-08-281-1/+4
| | | | | | | | | | | | | | | | Summary: The Linux/BSD system call interfaces report errors differently, use the internal_iserror() function to correctly check errors on either. Reviewers: eugenis Reviewed By: eugenis Subscribers: delcypher, llvm-commits, #sanitizers, krytarowski, kcc, devnexen Differential Revision: https://reviews.llvm.org/D51368 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@340856 91177308-0d34-0410-b5e6-96231b3b80d8
* SafeStack: Use correct unsafe stack sizesVlad Tsyrklevich2018-08-211-1/+3
| | | | | | | | | | | | | | | | | Summary: When deallocating thread stacks, we use one thread's unsafe stack size to deallocate another thread's unsafe stack; however, the two sizes may differ. Record an unsafe stack's size in the thread stack linked list. Reviewers: pcc, eugenis Reviewed By: eugenis Subscribers: delcypher, llvm-commits, #sanitizers, kcc Differential Revision: https://reviews.llvm.org/D51016 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@340308 91177308-0d34-0410-b5e6-96231b3b80d8
* Reland "SafeStack: Delay thread stack clean-up""Vlad Tsyrklevich2018-08-141-21/+57
| | | | | | | | | | This relands commit r339405 (reverted in commit r339408.) The original revert was due to tests failing on a darwin buildbot; however, after looking at the affected code more I realized that the Darwin safestack support has always been broken and disabled it in r339719. This relands the original commit. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@339723 91177308-0d34-0410-b5e6-96231b3b80d8
* SafeStack: Disable Darwin supportVlad Tsyrklevich2018-08-141-21/+6
| | | | | | | | | | | | | | | | | Summary: Darwin support does not appear to be used as evidenced by the fact that the pthread interceptors have never worked and there is no support for other common threading mechanisms like GCD. Reviewers: pcc, eugenis, kubamracek Reviewed By: pcc, kubamracek Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc Differential Revision: https://reviews.llvm.org/D50718 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@339719 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "SafeStack: Delay thread stack clean-up"Vlad Tsyrklevich2018-08-101-57/+21
| | | | | | | | | This reverts commit r339405, it's failing on Darwin buildbots because it doesn't seem to have a tgkill/thr_kill2 interface. It has a __pthread_kill() syscall, but that relies on having a handle to the thread's port which is not equivalent to it's tid. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@339408 91177308-0d34-0410-b5e6-96231b3b80d8
* SafeStack: Delay thread stack clean-upVlad Tsyrklevich2018-08-091-21/+57
| | | | | | | | | | | | | | | | | | Summary: glibc can call SafeStack instrumented code even after the last pthread data destructor has run. Delay cleaning-up unsafe stacks for threads until the thread is dead by having future threads clean-up prior threads stacks. Reviewers: pcc, eugenis Reviewed By: eugenis Subscribers: cryptoad, eugenis, kubamracek, delcypher, llvm-commits, #sanitizers, kcc Differential Revision: https://reviews.llvm.org/D50406 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@339405 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix for Darwin buildbot failure due to r337037Vlad Tsyrklevich2018-07-131-2/+3
| | | | | | | Duplicate __get_unsafe_stack_bottom instead of using an alias for platforms that don't suppport it like Darwin. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337044 91177308-0d34-0410-b5e6-96231b3b80d8
* SafeStack: Add builtins to read unsafe stack top/bottomVlad Tsyrklevich2018-07-131-1/+10
| | | | | | | | | | | | | | | | | | | | Summary: Introduce built-ins to read the unsafe stack top and bottom. The unsafe stack top is required to implement garbage collection scanning for Oilpan. Currently there is already a built-in 'get_unsafe_stack_start' to read the bottom of the unsafe stack, but I chose to duplicate this API because 'start' is ambiguous (e.g. Oilpan uses WTF::GetStackStart to read the safe stack top.) Reviewers: pcc Reviewed By: pcc Subscribers: llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D49152 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337037 91177308-0d34-0410-b5e6-96231b3b80d8
* [safestack] Lazy initialization of interceptorsVitaly Buka2018-05-261-4/+16
| | | | | | | | | Interceptors initialization may try to allocate memory and to call not initialized allocator. It's similar to r326025 for CFI. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@333329 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Remove unneeded blank linesVitaly Buka2018-05-091-1/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331831 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Update .clang-format in compiler-rtVitaly Buka2018-05-091-0/+2
| | | | | | Historically style is Google, but we never used AllowShortIfStatementsOnASingleLine. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@331829 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable SafeStack on NetBSDKamil Rytarowski2017-08-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: make check-safestack: -- Testing: 8 tests, 8 threads -- Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Testing Time: 0.44s Expected Passes : 7 Unsupported Tests : 1 Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, kcc, fjricci, filcab Reviewed By: vitalybuka Subscribers: mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36542 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310646 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Do not introduce __sanitizer namespace globallyAnna Zaks2016-09-151-0/+2
| | | | | | | | | | | | The definitions in sanitizer_common may conflict with definitions from system headers because: The runtime includes the system headers after the project headers (as per LLVM coding guidelines). lib/sanitizer_common/sanitizer_internal_defs.h pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with: using namespace __sanitizer; // NOLINT This patch solves the problem by introducing the namespace only within the sanitizer namespaces as proposed by Dmitry. Differential Revision: https://reviews.llvm.org/D21947 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281657 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] Connect Compiler-RT targets to LLVM Runtimes directoryChris Bieneman2016-08-261-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch builds on LLVM r279776. In this patch I've done some cleanup and abstracted three common steps runtime components have in their CMakeLists files, and added a fourth. The three steps I abstract are: (1) Add a top-level target (i.e asan, msan, ...) (2) Set the target properties for sorting files in IDE generators (3) Make the compiler-rt target depend on the top-level target The new step is to check if a command named "runtime_register_component" is defined, and to call it with the component name. The runtime_register_component command is defined in llvm/runtimes/CMakeLists.txt, and presently just adds the component to a list of sub-components, which later gets used to generate target mappings. With this patch a new workflow for runtimes builds is supported. The new workflow when building runtimes from the LLVM runtimes directory is: > cmake [...] > ninja runtimes-configure > ninja asan The "runtimes-configure" target builds all the dependencies for configuring the runtimes projects, and runs CMake on the runtimes projects. Running the runtimes CMake generates a list of targets to bind into the top-level CMake so subsequent build invocations will have access to some of Compiler-RT's targets through the top-level build. Note: This patch does exclude some top-level targets from compiler-rt libraries because they either don't install files (sanitizer_common), or don't have a cooresponding `check` target (stats). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279863 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Fix VisualStudio virtual folders layoutEtienne Bergeron2016-07-111-0/+2
| | | | | | | | | | | | | | | | | | | | Summary: This patch is a refactoring of the way cmake 'targets' are grouped. It won't affect non-UI cmake-generators. Clang/LLVM are using a structured way to group targets which ease navigation through Visual Studio UI. The Compiler-RT projects differ from the way Clang/LLVM are grouping targets. This patch doesn't contain behavior changes. Reviewers: kubabrecka, rnk Subscribers: wang0109, llvm-commits, kubabrecka, chrisha Differential Revision: http://reviews.llvm.org/D21952 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275111 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] [safestack] Enable for aarch64Adhemerval Zanella2015-12-111-1/+6
| | | | | | | | | | | | | | | This patch enables the safestack for aarch64. The frontend already have it enabled on all supported architectures and no adjustment is required in llvm. The compiler-rt adjustments are basically add on the cmake configuration to enable the tests and fix the pagesize debug check by getting its value at runtime (since aarch64 has multiple pagesize depending of kernel configuration). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255345 91177308-0d34-0410-b5e6-96231b3b80d8
* Tell clang-format that (most) sanitizers are written using Google style guide.Alexey Samsonov2015-11-191-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253608 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Apply modernize-use-nullptr fixes in sanitizersVedant Kumar2015-10-011-1/+1
| | | | | | | | | | | | | | | | | | - Trim spaces. - Use nullptr in place of 0 for pointer variables. - Use '!p' in place of 'p == 0' for null pointer checks. - Add blank lines to separate function definitions. - Add 'extern "C"' or 'namespace foo' comments after the appropriate closing brackets This is a continuation of work from 409b7b82. The focus here is on the various sanitizers (not sanitizer_common, as before). Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13225 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248966 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] Unify build rules for sanitizer_common for Apple and non-Apple ↵Alexey Samsonov2015-08-271-0/+1
| | | | | | | | | platforms. Additionally, link safestack runtime on OS X with nolibc version of sanitizer_common runtime, as we do on Linux. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@246227 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] merge add_compiler_rt_runtime and add_compiler_rt_darwin_runtime ↵Chris Bieneman2015-08-251-13/+14
| | | | | | | | | | | | | | | | into a single function Summary: This refactoring moves much of the Apple-specific behavior into a function in AddCompilerRT. The next cleanup patch will remove more of the if(APPLE) checks in the outlying CMakeLists. This patch adds a bunch of new functionality to add_compiler_rt_runtime so that the target names don't need to be reconstructed outside the call. It also updates some of the call sites to exercise the new functionality, but does not update all uses fully. Subsequent patches will further update call sites and move to using the new features. Reviewers: filcab, bogner, kubabrecka, zaks.anna, glider, samsonov Subscribers: beanz, rengolin, llvm-commits Differential Revision: http://reviews.llvm.org/D12292 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245970 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo in lib/safestack/CMakeLists.txt that prevents safestack static ↵Kuba Brecka2015-08-191-1/+1
| | | | | | library from being built on OS X. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245438 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] Backing out part of r245317. Turns out safestack and profile don't ↵Chris Bieneman2015-08-181-1/+1
| | | | | | work correctly on the iOS simulator and enabling it breaks tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245326 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] Refactoring add_compiler_rt functions for darwin runtimes.Chris Bieneman2015-08-181-7/+10
| | | | | | | | | | | | Summary: This patch consolidates add_compiler_rt_osx_static_runtime and add_compiler_rt_darwin_dynamic_runtime into a single new function add_compiler_rt_darwin_runtime. Reviewers: filcab, samsonov, bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12106 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245317 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Implement logging to syslog.Evgeniy Stepanov2015-07-231-0/+1
| | | | | | | | | | | | | | | | | | Previously, Android target had a logic of duplicating all sanitizer output to logcat. This change extends it to all posix platforms via the use of syslog, controlled by log_to_syslog flag. Enabled by default on Android, off everywhere else. A bit of cmake magic is required to allow Printf() to call a libc function. I'm adding a stub implementation to support no-libc builds like dfsan and safestack. This is a second attempt. I believe I've fixed all the issues that prompted the revert: Mac build, and all kinds of non-CMake builds (there are 3 of those). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243051 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r242975.Evgeniy Stepanov2015-07-231-1/+0
| | | | | | | Breaks Mac build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242978 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Implement logging to syslog.Evgeniy Stepanov2015-07-221-0/+1
| | | | | | | | | | | | | | Previously, Android target had a logic of duplicating all sanitizer output to logcat. This change extends it to all posix platforms via the use of syslog, controlled by log_to_syslog flag. Enabled by default on Android, off everywhere else. A bit of cmake magic is required to allow Printf() to call a libc function. I'm adding a stub implementation to support no-libc builds like dfsan and safestack. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242975 91177308-0d34-0410-b5e6-96231b3b80d8
* SafeStack: Add another missing header to try to fix FreeBSD build.Peter Collingbourne2015-06-241-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240564 91177308-0d34-0410-b5e6-96231b3b80d8
* SafeStack: Add #include of <stdint.h>.Peter Collingbourne2015-06-241-0/+1
| | | | | | Should fix the FreeBSD build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240555 91177308-0d34-0410-b5e6-96231b3b80d8
* Update SafeStack TODO in the safestack.ccPeter Collingbourne2015-06-231-24/+32
| | | | | | | | | | | | This patch clarifies the TODO note at the top of safestack.cc and brings it more in sync with what we (the CPI team) actually plan to work on in the future. Patch by Volodymyr Kuznetsov! Differential Revision: http://reviews.llvm.org/D10600 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240473 91177308-0d34-0410-b5e6-96231b3b80d8
* Protection against stack-based memory corruption errors using SafeStack: ↵Peter Collingbourne2015-06-152-0/+264
compiler-rt runtime support library This patch adds runtime support for the Safe Stack protection to compiler-rt (see http://reviews.llvm.org/D6094 for the detailed description of the Safe Stack). This patch is our implementation of the safe stack on top of compiler-rt. The patch adds basic runtime support for the safe stack to compiler-rt that manages unsafe stack allocation/deallocation for each thread. Original patch by Volodymyr Kuznetsov and others at the Dependable Systems Lab at EPFL; updates and upstreaming by myself. Differential Revision: http://reviews.llvm.org/D6096 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@239763 91177308-0d34-0410-b5e6-96231b3b80d8