summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/hwasan/hwasan_linux.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [hwasan] Remove lazy thread-initialisationDavid Spickett2019-11-041-6/+1
| | | | | | | | | | | | | | | | | | | | | This was an experiment made possible by a non-standard feature of the Android dynamic loader. It required introducing a flag to tell the compiler which ABI was being targeted. This flag is no longer needed, since the generated code now works for both ABI's. We leave that flag untouched for backwards compatibility. This also means that if we need to distinguish between targeted ABI's again we can do that without disturbing any existing workflows. We leave a comment in the source code and mention in the help text to explain this for any confused person reading the code in the future. Patch by Matthew Malcomson Differential Revision: https://reviews.llvm.org/D69574
* [compiler-rt] Expose __hwasan_tag_mismatch_stubDavid Tellenbach2019-10-241-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: GCC would like to emit a function call to report a tag mismatch rather than hard-code the `brk` instruction directly. __hwasan_tag_mismatch_stub contains most of the functionality to do this already, but requires exposure in the dynamic library. This patch moves __hwasan_tag_mismatch_stub outside of the anonymous namespace that it was defined in and declares it in hwasan_interface_internal.h. We also add the ability to pass sizes larger than 16 bytes to this reporting function by providing a fourth parameter that is only looked at when the size provided is not in the original accepted range. This does not change the behaviour where it is already being called, since the previous definition only accepted sizes up to 16 bytes and hence the change in behaviour is not seen by existing users. The change in declaration does not matter, since the only existing use is in the __hwasan_tag_mismatch function written in assembly. Reviewers: eugenis, kcc, pcc, #sanitizers Reviewed By: eugenis, #sanitizers Subscribers: kristof.beyls, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D69113 Patch by Matthew Malcomson <matthew.malcomson@arm.com>
* Revert "Expose __hwasan_tag_mismatch_stub"David Tellenbach2019-10-241-20/+15
| | | | | | Attribution to author of patch got lost. This reverts commit 612eadb7bc06b8f1a094976e06155f46ebd70d7c.
* Expose __hwasan_tag_mismatch_stubDavid Tellenbach2019-10-241-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: GCC would like to emit a function call to report a tag mismatch rather than hard-code the `brk` instruction directly. __hwasan_tag_mismatch_stub contains most of the functionality to do this already, but requires exposure in the dynamic library. This patch moves __hwasan_tag_mismatch_stub outside of the anonymous namespace that it was defined in and declares it in hwasan_interface_internal.h. We also add the ability to pass sizes larger than 16 bytes to this reporting function by providing a fourth parameter that is only looked at when the size provided is not in the original accepted range. This does not change the behaviour where it is already being called, since the previous definition only accepted sizes up to 16 bytes and hence the change in behaviour is not seen by existing users. The change in declaration does not matter, since the only existing use is in the __hwasan_tag_mismatch function written in assembly. Tested with gcc and clang on an AArch64 vm. Reviewers: eugenis, kcc, pcc, #sanitizers Reviewed By: eugenis, #sanitizers Subscribers: kristof.beyls, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D69113
* libhwasan initialisation include kernel syscall ABI relaxationEvgeniy Stepanov2019-10-171-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Until now AArch64 development has been on patched kernels that have an always on relaxed syscall ABI where tagged pointers are accepted. The patches that have gone into the mainline kernel rely on each process opting in to this relaxed ABI. This commit adds code to choose that ABI into __hwasan_init. The idea has already been agreed with one of the hwasan developers (http://lists.llvm.org/pipermail/llvm-dev/2019-September/135328.html). The patch ignores failures of `EINVAL` for Android, since there are older versions of the Android kernel that don't require this `prctl` or even have the relevant values. Avoiding EINVAL will let the library run on them. I've tested this on an AArch64 VM running a kernel that requires this prctl, having compiled both with clang and gcc. Patch by Matthew Malcomson. Reviewers: eugenis, kcc, pcc Reviewed By: eugenis Subscribers: srhines, kristof.beyls, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D68794 llvm-svn: 375166
* [Sanitizer] Linux refactor shadow huge page mode handlingDavid Carlier2019-08-051-2/+1
| | | | | | | | | | | | Disabling Transparent huge page mode refactored in one function. Reviewers: vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D65771 llvm-svn: 367925
* [hwasan] Fix HWASAN_WITH_INTERCEPTORS=OFF build on not-android.Evgeniy Stepanov2019-05-031-1/+11
| | | | | | | | | | | | | | | | | Summary: I'm not aware of any platforms where this will work, but the code should at least compile. HWASAN_WITH_INTERCEPTORS=OFF means there is magic in libc that would call __hwasan_thread_enter / __hwasan_thread_exit as appropriate. Reviewers: pcc, winksaville Subscribers: srhines, kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61337 llvm-svn: 359914
* [HWASan] Save + print registers when tag mismatch occurs in AArch64.Mitch Phillips2019-03-081-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change change the instrumentation to allow users to view the registers at the point at which tag mismatch occured. Most of the heavy lifting is done in the runtime library, where we save the registers to the stack and emit unwind information. This allows us to reduce the overhead, as very little additional work needs to be done in each __hwasan_check instance. In this implementation, the fast path of __hwasan_check is unmodified. There are an additional 4 instructions (16B) emitted in the slow path in every __hwasan_check instance. This may increase binary size somewhat, but as most of the work is done in the runtime library, it's manageable. The failure trace now contains a list of registers at the point of which the failure occured, in a format similar to that of Android's tombstones. It currently has the following format: Registers where the failure occurred (pc 0x0055555561b4): x0 0000000000000014 x1 0000007ffffff6c0 x2 1100007ffffff6d0 x3 12000056ffffe025 x4 0000007fff800000 x5 0000000000000014 x6 0000007fff800000 x7 0000000000000001 x8 12000056ffffe020 x9 0200007700000000 x10 0200007700000000 x11 0000000000000000 x12 0000007fffffdde0 x13 0000000000000000 x14 02b65b01f7a97490 x15 0000000000000000 x16 0000007fb77376b8 x17 0000000000000012 x18 0000007fb7ed6000 x19 0000005555556078 x20 0000007ffffff768 x21 0000007ffffff778 x22 0000000000000001 x23 0000000000000000 x24 0000000000000000 x25 0000000000000000 x26 0000000000000000 x27 0000000000000000 x28 0000000000000000 x29 0000007ffffff6f0 x30 00000055555561b4 ... and prints after the dump of memory tags around the buggy address. Every register is saved exactly as it was at the point where the tag mismatch occurs, with the exception of x16/x17. These registers are used in the tag mismatch calculation as scratch registers during __hwasan_check, and cannot be saved without affecting the fast path. As these registers are designated as scratch registers for linking, there should be no important information in them that could aid in debugging. Reviewers: pcc, eugenis Reviewed By: pcc, eugenis Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, hiraditya, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58857 llvm-svn: 355738
* [NFC][Sanitizer] Add new BufferedStackTrace::Unwind APIJulian Lettner2019-03-011-4/+3
| | | | | | | | | | | | | | | | | | | | | Retrying without replacing call sites in sanitizer_common (which might not have a symbol definition). Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 > llvm-svn: 355168 llvm-svn: 355172
* Revert "[NFC][Sanitizer] Add new BufferedStackTrace::Unwind API"Julian Lettner2019-03-011-3/+4
| | | | | | This reverts commit 6112f37e758ebf2405955e091a745f5003c1f562. llvm-svn: 355171
* [NFC][Sanitizer] Add new BufferedStackTrace::Unwind APIJulian Lettner2019-03-011-4/+3
| | | | | | | | | | | | | | | | Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 llvm-svn: 355168
* hwasan: Rename source files from cc to cppNico Weber2019-02-271-0/+436
As discussed elsewhere: LLVM uses cpp as its C++ source extension; the sanitizers should too. This updates files in hwasan. Patch generated by for f in lib/hwasan/*.cc ; do svn mv $f ${f%.cc}.cpp; done followed by for f in lib/hwasan/*.cpp ; do sed -i '' -e '1s/\.cc -/.cpp /' $f; done CMakeLists.txt updated manually. Differential Revision: https://reviews.llvm.org/D58620 llvm-svn: 354989
OpenPOWER on IntegriCloud