summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/cfi/cfi.cc
Commit message (Collapse)AuthorAgeFilesLines
* cfi: Rename source file from cc to cppNico Weber2019-02-281-476/+0
| | | | | | See discussion on https://reviews.llvm.org/D58620 for the review. llvm-svn: 355144
* [sanitizer] Decorate /proc/self/maps better.Evgeniy Stepanov2019-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Refactor the way /proc/self/maps entries are annotated to support most (all?) posix platforms, with a special implementation for Android. Extend the set of decorated Mmap* calls. Replace shm_open with internal_open("/dev/shm/%s"). Shm_open is problematic because it calls libc open() which may be intercepted. Generic implementation has limits (max number of files under /dev/shm is 64K on my machine), which can be conceivably reached when sanitizing multiple programs at once. Android implemenation is essentially free, and enabled by default. The test in sanitizer_common is copied to hwasan and not reused directly because hwasan fails way too many common tests at the moment. Reviewers: pcc, vitalybuka Subscribers: srhines, kubamracek, jfb, llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D57720 llvm-svn: 353255
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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. llvm-svn: 351636
* Unbreak linux cfi buildDavid Carlier2018-10-011-0/+1
| | | | llvm-svn: 343512
* [Cfi] Compiling cfi library on FreeBSD and NetBSDDavid Carlier2018-10-011-6/+33
| | | | | | | | | | | | Making the library slighty more portable. Reviewers: vitalybuka, krytarowski Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D51682 llvm-svn: 343510
* Fix warnings in a static assert added to CFI.Chandler Carruth2018-07-161-1/+2
| | | | llvm-svn: 337178
* [cfi] Don't pass a uint16_t to memset. Make sure the 16-bit constant is ↵Filipe Cabecinhas2018-07-161-1/+4
| | | | | | | | | | | | appropriate for us. Reviewers: eugenis, pcc, kcc Subscribers: delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D49252 llvm-svn: 337170
* [cfi] Lazy initialization of CFI interceptorsVitaly Buka2018-02-241-3/+18
| | | | | | | | | | | | | | Summary: Interceptors initialization may need to allocate memory. So if we initialize too early we can crash in non initialized allocator. Reviewers: pcc, eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43669 llvm-svn: 326025
* (NFC) Rename GetMax{,User}VirtualAddress.Evgeniy Stepanov2017-11-071-1/+1
| | | | | | | Future change will introduce GetMaxVirtualAddress that will not take the kernel area into account. llvm-svn: 317638
* [cfi] Accept weak definition of __cfi_check.Evgeniy Stepanov2017-04-071-1/+2
| | | | | | | https://reviews.llvm.org/D31796 results in LLD emitting __cfi_check as a weak symbol, while Gold keeps it strong. Accept both. llvm-svn: 299804
* [cfi] Fix symbol lookup hack in cross-dso cfi to handle LLD binaries.Evgeniy Stepanov2017-04-061-2/+9
| | | | llvm-svn: 299604
* [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 llvm-svn: 281657
* [sancov] common flags initialization.Mike Aizatsky2016-03-181-1/+1
| | | | | | | | | | | | 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 llvm-svn: 263820
* [cfi] Safe handling of unaddressable vtable pointers (compiler-rt).Evgeniy Stepanov2016-02-031-1/+1
| | | | | | | | | | | 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 llvm-svn: 259717
* Cast the fifth arg to mremap to void *Alexey Samsonov2016-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 259540
* [cfi] Simplify the code in CfiSlowPathCommon.Evgeniy Stepanov2016-01-281-7/+2
| | | | llvm-svn: 259085
* [cfi] Fix recovery from out-of-bounds vtable error.Evgeniy Stepanov2016-01-281-3/+6
| | | | llvm-svn: 259007
* [cfi] Fix gcc build.Evgeniy Stepanov2016-01-271-12/+14
| | | | llvm-svn: 258977
* [cfi] Exclude __cfi_slowpath_diag from the non-diag rtl.Evgeniy Stepanov2016-01-261-1/+3
| | | | | | | Calls to __cfi_slowpath_diag are only emitted when building with diagnostics, and linking the diag rtl. llvm-svn: 258881
* [cfi] Better handling of wild target address.Evgeniy Stepanov2016-01-261-25/+56
| | | | | | | | | | | | | 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. llvm-svn: 258879
* [cfi] Hide runtime implementation in a namespace.Evgeniy Stepanov2016-01-261-55/+60
| | | | | | | | Move all internal stuff into namespace __cfi. Remove the double underscore prefix from anything that's now inside the namespace. llvm-svn: 258859
* [cfi] Support for dlopen and dlclose.Evgeniy Stepanov2016-01-261-41/+136
| | | | | | Add dlopen/dlclose interceptors to update CFI shadow for loaded/unloaded libraries. llvm-svn: 258857
* [cfi] Cross-DSO CFI diagnostic mode (compiler-rt part)Evgeniy Stepanov2016-01-251-6/+22
| | | | | | | | | | | | | | | * 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. llvm-svn: 258744
* [cfi] Fix __cfi_slowpath and __cfi_check signature.Evgeniy Stepanov2016-01-081-3/+3
| | | | | | The first argument is uint64_t, not uintptr_t. llvm-svn: 257233
* [cfi] Fix handling of uninstrumented libraries.Evgeniy Stepanov2015-12-221-1/+1
| | | | | | CFI shadow for non-CFI libraries should be "unchecked", not "invalid". llvm-svn: 256285
* [cfi] Exclude ubsan runtime library from non-diag CFI builds.Evgeniy Stepanov2015-12-161-2/+7
| | | | | | | Split the CFI runtime in two: cfi and cfi_diag. The latter includes UBSan runtime to allow printing diagnostics. llvm-svn: 255735
* [cfi] Fix GCC build.Evgeniy Stepanov2015-12-161-2/+2
| | | | llvm-svn: 255733
* [cfi] Fix shadow sanity check.Evgeniy Stepanov2015-12-161-4/+5
| | | | | | | The current check may break if the starting address in fill_shadow is not page-aligned. llvm-svn: 255725
* Cross-DSO control flow integrity (compiler-rt part).Evgeniy Stepanov2015-12-151-0/+265
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. llvm-svn: 255695
OpenPOWER on IntegriCloud