summaryrefslogtreecommitdiff
path: root/lib/cfi/cfi.cc
AgeCommit message (Collapse)Author
2017-11-07(NFC) Rename GetMax{,User}VirtualAddress.Evgeniy Stepanov
Future change will introduce GetMaxVirtualAddress that will not take the kernel area into account. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317638 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-07[cfi] Accept weak definition of __cfi_check.Evgeniy Stepanov
https://reviews.llvm.org/D31796 results in LLD emitting __cfi_check as a weak symbol, while Gold keeps it strong. Accept both. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299804 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-06[cfi] Fix symbol lookup hack in cross-dso cfi to handle LLD binaries.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15[compiler-rt] Do not introduce __sanitizer namespace globallyAnna Zaks
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
2016-03-18[sancov] common flags initialization.Mike Aizatsky
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-03[cfi] Safe handling of unaddressable vtable pointers (compiler-rt).Evgeniy Stepanov
Avoid crashing when printing diagnostics for vtable-related CFI errors. In diagnostic mode, the frontend does an additional check of the vtable pointer against the set of all known vtable addresses and lets the runtime handler know if it is safe to inspect the vtable. http://reviews.llvm.org/D16824 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259717 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-02Cast the fifth arg to mremap to void *Alexey Samsonov
Summary: Since the prototype of mremap is ``` void *mremap(void *old_address, size_t old_size, size_t new_size, int flags, ... /* void *new_address*/); ``` we need to cast new_address to void * when calling mremap. Otherwise, the wrong value will be passed to mremap on x32. Patch by H.J Lu! Reviewers: kcc, eugenis, samsonov Subscribers: samsonov, llvm-commits Differential Revision: http://reviews.llvm.org/D16805 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259540 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-28[cfi] Simplify the code in CfiSlowPathCommon.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259085 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-28[cfi] Fix recovery from out-of-bounds vtable error.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259007 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-27[cfi] Fix gcc build.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258977 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26[cfi] Exclude __cfi_slowpath_diag from the non-diag rtl.Evgeniy Stepanov
Calls to __cfi_slowpath_diag are only emitted when building with diagnostics, and linking the diag rtl. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258881 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26[cfi] Better handling of wild target address.Evgeniy Stepanov
This change enables diagnostics when the target address for a CFI check is out of bounds of any known library, or even not in the limits of the address space. This happens when casting pointers to uninitialized memory. Ubsan code does not yet handle some of these situations correctly, so it is still possible to see a segmentation fault instead of a proper diagnostic message once in a while. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258879 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26[cfi] Hide runtime implementation in a namespace.Evgeniy Stepanov
Move all internal stuff into namespace __cfi. Remove the double underscore prefix from anything that's now inside the namespace. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258859 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26[cfi] Support for dlopen and dlclose.Evgeniy Stepanov
Add dlopen/dlclose interceptors to update CFI shadow for loaded/unloaded libraries. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258857 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-25[cfi] Cross-DSO CFI diagnostic mode (compiler-rt part)Evgeniy Stepanov
* add __cfi_slowpath_diag with a 3rd parameter which is a pointer to the diagnostic info for the ubsan handlers. *__cfi_check gets a 3rd parameter as well. * unify vcall/cast/etc and icall diagnostic info format, and merge the handlers to have a single entry point (actually two points due to abort/noabort variants). * tests Note that this comes with a tiny overhead in the non-diag mode: cfi_slowpath must pass 0 as the 3rd argument to cfi_check. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258744 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-08[cfi] Fix __cfi_slowpath and __cfi_check signature.Evgeniy Stepanov
The first argument is uint64_t, not uintptr_t. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@257233 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-22[cfi] Fix handling of uninstrumented libraries.Evgeniy Stepanov
CFI shadow for non-CFI libraries should be "unchecked", not "invalid". git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256285 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16[cfi] Exclude ubsan runtime library from non-diag CFI builds.Evgeniy Stepanov
Split the CFI runtime in two: cfi and cfi_diag. The latter includes UBSan runtime to allow printing diagnostics. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255735 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16[cfi] Fix GCC build.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255733 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16[cfi] Fix shadow sanity check.Evgeniy Stepanov
The current check may break if the starting address in fill_shadow is not page-aligned. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255725 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-15Cross-DSO control flow integrity (compiler-rt part).Evgeniy Stepanov
This is an initial version of the runtime cross-DSO CFI support library. It contains a number of FIXMEs, ex. it does not support the diagnostic mode nor dlopen/dlclose, but it works and can be tested. Diagnostic mode, in particular, would require some refactoring (we'd like to gather all CFI hooks in the UBSan library into one function so that we could easier pass the diagnostic information down to __cfi_check). It will be implemented later. Once the diagnostic mode is in, I plan to create a second test configuration to run all existing tests in both modes. For now, this patch includes only a few new cross-DSO tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255695 91177308-0d34-0410-b5e6-96231b3b80d8