summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/gwp_asan
Commit message (Collapse)AuthorAgeFilesLines
* [GWP-ASan] 32-bit test pointers, allow multi-init for test.Mitch Phillips2019-12-092-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: GWP-ASan test currently fail on 32-bit platforms, as some of the pointers are larger than `uintptr_t` on 32-bit platforms. Fix up all those instances. Also add an uncompress varint test where the result is an underflow. Furthermore, allow multi-init for testing. Each gtest when running `check-gwp_asan` apparently runs in its own instance, but when integrating these tests into Android, this behaviour isn't the same. We remove the global multi-init check here, to allow for testing to work elsewhere, and we're not really worried about multi-init anyway as it's part of our contract with the allocator. Reviewers: eugenis, vlad.tsyrklevich Reviewed By: eugenis Subscribers: #sanitizers, llvm-commits, pcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71121
* [GWP-ASan] Add GWP_ASAN_ prefix to macros.Mitch Phillips2019-11-253-21/+9
| | | | | | | | | | | | | | | | | Summary: When platforms use their own `LIKELY()` definitions, it can be quite troublesome to ensure they don't conflict with the GWP-ASan internal definitions. Just force the GWP_ASAN_ prefix to help this issue. Reviewers: eugenis Reviewed By: eugenis Subscribers: #sanitizers, llvm-commits, cferris, pcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70683
* [GWP-ASan] Respect compiler-rt's -fno-ltoMitch Phillips2019-11-071-1/+2
| | | | | | | https://bugs.llvm.org/show_bug.cgi?id=43722 GWP-ASan didn't include SANITIZER_COMMON_CFLAGS, and thus would produce LLVM bitcode files, when compiler-rt is generally built without LTO.
* Add GWP-ASan fuzz target to compiler-rt/tools.Mitch Phillips2019-08-272-72/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: @eugenis to approve addition of //compiler-rt/tools. @pree-jackie please confirm that this WFY. D66494 introduced the GWP-ASan stack_trace_compressor_fuzzer. Building fuzz targets in compiler-rt is a new affair, and has some challenges: - If the host compiler doesn't have compiler-rt, the -fsanitize=fuzzer may not be able to link against `libclang_rt.fuzzer*`. - Things in compiler-rt generally aren't built when you want to build with sanitizers using `-DLLVM_USE_SANITIZER`. This tricky to work around, so we create the new tools directory so that we can build fuzz targets with sanitizers. This has the added bonus of fixing the problem above as well, as we can now just guard the fuzz target build to only be done with `-DLLVM_USE_SANITIZE_COVERAGE=On`. Reviewers: eugenis, pree-jackie Reviewed By: eugenis, pree-jackie Subscribers: dberris, mgorny, #sanitizers, llvm-commits, eugenis, pree-jackie, lebedev.ri, vitalybuka, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66776 llvm-svn: 370094
* [GWP_ASAN] Avoid using VERSION_GREATER_EQUAL in cmake filesBjorn Pettersson2019-08-261-1/+1
| | | | | | | | | | | This is a fixup for r369823 which introduced the use of VERSION_GREATER_EQUAL in the cmake config for gwp_asan. Minimum supported version of cmake in LLVM is 3.4.3 and VERSION_GREATER_EQUAL was not introduced until later versions of cmake. llvm-svn: 369891
* [GWP-ASan] Split options_parser and backtrace_sanitizer_common.Mitch Phillips2019-08-236-19/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: optional/options_parser and optional/backtrace_sanitizer_common are logically separate components. They both use sanitizer-common to power their functionality, but there was an unstated implicit dependency that in order for backtrace_sanitizer_common to function correctly, one had to also use options_parser. This was because options_parser called __sanitizer::InitialiseCommonFlags. This is a requirement for backtrace_sanitizer_common to work, as the sanitizer unwinder uses the sanitizer_common flags and will SEGV on a null page if they're not initialised correctly. This patch removes this hidden dependency. You can now use backtrace_sanitizer_common without the requirements of options_parser. This patch also makes the GWP-ASan unit tests only have a soft dependency on sanitizer-common. The unit tests previously explicitly used __sanitizer::Printf, which is now provided under tests/optional/printf_sanitizer_common. This allows Android to build the unit tests using their own signal-safe printf(). Reviewers: eugenis Reviewed By: eugenis Subscribers: srhines, mgorny, #sanitizers, llvm-commits, vlad.tsyrklevich, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66684 llvm-svn: 369825
* Fix stack_trace_compressor builds for Clang < 6.0Mitch Phillips2019-08-231-3/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: Clang 4.* doesn't supply -fsanitize=fuzzer, and Clang 5.* doesn't supply -fsanitize=fuzzer-no-link. Generally, in LLVM, fuzz targets are added through the add_llvm_fuzzer build rule, which can't be used in compiler-rt (as it has to be able to be standalone built). Instead of adding tooling to add a dummy main (which kind of defeats the purpose of these fuzz targets), we instead build the fuzz target only when the Clang version is >= 6.*. Reviewers: tejohnson Subscribers: mgorny, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66682 llvm-svn: 369823
* Revert "[GWP-ASan] Remove c++ standard lib dependency."Petr Hosek2019-08-222-17/+17
| | | | | | | This reverts commit r369606: this doesn't addressed the underlying problem and it's not the correct solution. llvm-svn: 369623
* [GWP-ASan] Remove c++ standard lib dependency.Petr Hosek2019-08-222-17/+17
| | | | | | | | | | | Remove c++ standard library dependency for now for @phosek. They have a complicated build system that breaks with the fuzzer target here. Also added a todo to remedy later. Differential Revision: https://reviews.llvm.org/D66568 llvm-svn: 369606
* [GWP-ASan] Add public-facing documentation [6].Mitch Phillips2019-08-212-3/+58
| | | | | | | | | | | | | | | | | | | | | Summary: Note: Do not submit this documentation until Scudo support is reviewed and submitted (should be #[5]). See D60593 for further information. This patch introduces the public-facing documentation for GWP-ASan, as well as updating the definition of one of the options, which wasn't properly merged. The document describes the design and features of GWP-ASan, as well as how to use GWP-ASan from both a user's standpoint, and development documentation for supporting allocators. Reviewers: jfb, morehouse, vlad.tsyrklevich Reviewed By: morehouse, vlad.tsyrklevich Subscribers: kcc, dexonsmith, kubamracek, cryptoad, jfb, #sanitizers, llvm-commits, vlad.tsyrklevich, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D62875 llvm-svn: 369552
* [GWP-ASan] Build stack_trace_compressor_fuzzer.Mitch Phillips2019-08-211-17/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Flips the switch to build stack_trace_compressor_fuzzer. This was recently temporarily disabled in rL369079 as it was breaking the sanitizer buildbots. My diagnosis of the problem is that on clang-only bootstrap builds, we build gwp_asan before libfuzzer. This causes a discrepancy when the clang driver attempts to link libclang_rt.fuzzer* as CMake doesn't see a dependency there. I've (hopefully) fixed the issue by adding a direct dependency for the fuzz target so CMake can resolve the build order properly. As part of this, the libFuzzer 'fuzzer' target has to be discovered before the declaration of the fuzz target. pcc@ for mild review + notification as buildcop. Reviewers: pcc Reviewed By: pcc Subscribers: mgorny, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66494 llvm-svn: 369551
* [GWP-ASan] Fix typos.Mitch Phillips2019-08-201-3/+3
| | | | | | | | | | | | | | | | | | Summary: Fix two spelling typos and de-indent a guarded #define so that it's consistent with clang-format. Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66311 llvm-svn: 369433
* Disable stack_trace_compressor_fuzzer.Mitch Phillips2019-08-161-13/+17
| | | | | | | | Should hopefully fix the remainder of the buildbot issues. Just disabling this for now with a comment that I'm working on it. Can actually fix the real problem when I'm at a real computer. llvm-svn: 369079
* Moved binary off add_llvm_executable.Mitch Phillips2019-08-151-1/+1
| | | | | | | | Used add_executable instead, as this allows a standalone compiler-rt to build, as the add_llvm_executable build target isn't accessible in a standalone CRT preparation. llvm-svn: 369071
* Re-instate 369051.Mitch Phillips2019-08-151-1/+2
| | | | | | | Looks like I accidentally reverted r369051 to the old CMake-version-specific flag when committing 369055. llvm-svn: 369067
* Guard fuzzer build behind Clang-only flags.Mitch Phillips2019-08-151-11/+12
| | | | | | | Should fix sanitizer buildbots and any one else who's building compiler-rt using gcc. llvm-svn: 369055
* Remove CMake >= v3.13 target_link_options.Mitch Phillips2019-08-151-1/+2
| | | | | | Instead, use set_target_properties. llvm-svn: 369051
* [GWP-ASan] Implement stack frame compression.Mitch Phillips2019-08-157-19/+517
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces stack frame compression to GWP-ASan. Each stack frame is variable-length integer encoded as the difference between frame[i] and frame[i - 1]. Furthermore, we use zig-zag encoding on the difference to ensure that negative differences are also encoded into a relatively small number of bytes. Examples of what the compression looks like can be seen in `gwp_asan/tests/compression.cpp`. This compression can reduce the memory consumption cost of stack traces by ~50%. Reviewers: vlad.tsyrklevich Reviewed By: vlad.tsyrklevich Subscribers: mgorny, #sanitizers, llvm-commits, eugenis, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66189 llvm-svn: 369048
* [GWP-ASan] Update backtrace function signature.Mitch Phillips2019-08-126-57/+89
| | | | | | | | | | | | | | | | | | | | Summary: Updates the function signature and comments for backtracing (and printing backtraces). This update brings GWP-ASan in line with future requirements for stack frame compression, wherein the length of the trace is provided explicitly, rather than relying on nullptr-termination. Reviewers: vlad.tsyrklevich Reviewed By: vlad.tsyrklevich Subscribers: #sanitizers, llvm-commits, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66099 llvm-svn: 368619
* Remove a few straggler ".cc"s in compiler-rt/libNico Weber2019-08-015-5/+5
| | | | llvm-svn: 367589
* [GWP-ASan] Add thread ID to PRNG seed.Mitch Phillips2019-07-162-5/+7
| | | | | | | | | | | | | | | | | | | Summary: Adds thread ID to PRNG seed for increased entropy. In particular, this allows multiple runs in quick succession that will have different PRNG seeds, allowing for better demos/testing. Reviewers: kcc Reviewed By: kcc Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D64453 llvm-svn: 366253
* Removed -mno-omit-leaf-frame-pointer from flags.Mitch Phillips2019-07-161-2/+0
| | | | | | | Removes -mno-omit-leaf-frame-pointer from Scudo and GWP-ASan's CFlags. Attempt to fix the sanitizer buildbots. llvm-svn: 366228
* Explicitly define __STDC_FORMAT_MACROS for PRIu64Mitch Phillips2019-07-111-0/+6
| | | | | | | | | | | | | | | | | | | | Summary: Builds are failing on RHEL machines because of PRIu64. lvm/projects/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp:420:50: error: expected ')' `snprintf(ThreadBuffer, kThreadBufferLen, "%" PRIu64, ThreadID);` inttypes.h in RHEL uses PRIu64 macros only when __STDC_FORMAT_MACROS is defined. Author: DTharun Reviewers: hctim Reviewed By: hctim Differential Revision: https://reviews.llvm.org/D64388 llvm-svn: 365801
* [GWP-ASan] Add generic unwinders and structure backtrace output.Mitch Phillips2019-07-0212-116/+412
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds two flavours of generic unwinder and all the supporting cruft. If the supporting allocator is okay with bringing in sanitizer_common, they can use the fast frame-pointer based unwinder from sanitizer_common. Otherwise, we also provide the backtrace() libc-based unwinder as well. Of course, the allocator can always specify its own unwinder and unwinder-symbolizer. The slightly changed output format is exemplified in the first comment on this patch. It now better incorporates backtrace information, and displays allocation details on the second line. Reviewers: eugenis, vlad.tsyrklevich Reviewed By: eugenis, vlad.tsyrklevich Subscribers: srhines, kubamracek, mgorny, cryptoad, #sanitizers, llvm-commits, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D63841 llvm-svn: 364941
* [GWP-ASan] Guard against recursive allocs. Pack TLS for perf.Mitch Phillips2019-06-252-15/+51
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Add a recursivity guard for GPA::allocate(). This means that any recursive allocations will fall back to the supporting allocator. In future patches, we will introduce stack trace collection support. The unwinder will be provided by the supporting allocator, and we can't guarantee they don't call malloc() (e.g. backtrace() on posix may call dlopen(), which may call malloc(). Furthermore, this patch packs the new TLS recursivity guard into a thread local struct, so that TLS variables should be hopefully not fall across cache lines. Reviewers: vlad.tsyrklevich, morehouse, eugenis Reviewed By: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits, eugenis Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D63736 llvm-svn: 364356
* [GWP-ASan] Disable GWP-ASan on Android for now.Mitch Phillips2019-06-171-1/+2
| | | | | | | | | | | | | | | | | | | Summary: Temporarily disable GWP-ASan for android until the bugs at: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/87 ... can be fixed. See comments for the full bug trace. Reviewers: eugenis Reviewed By: eugenis Subscribers: srhines, kubamracek, mgorny, cryptoad, jfb, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D63460 llvm-svn: 363624
* Attempt to fix GWP-ASan build failure on sanitizer-android. Add -fPIC.Mitch Phillips2019-06-171-1/+1
| | | | llvm-svn: 363604
* Change GWP-ASan build to use '-pthread' instead of '-lpthread' in orderMitch Phillips2019-06-061-1/+1
| | | | | | | | to try and fix android buildbot. Also make sure that the empty dummy test contains an output file name so the android_build.py wrapper script doesn't check fail. llvm-svn: 362758
* Fixup files added in r362636 to build with gcc 5.4. NFCIDouglas Yung2019-06-062-13/+13
| | | | llvm-svn: 362682
* [GWP-ASan] Core Guarded Pool Allocator [4].Mitch Phillips2019-06-0511-3/+1111
| | | | | | | | | | | | | | | | | | | | | Summary: See D60593 for further information. This patch introduces the core of GWP-ASan, being the guarded pool allocator. This class contains the logic for creating and maintaining allocations in the guarded pool. Its public interface is to be utilised by supporting allocators in order to provide sampled guarded allocation behaviour. This patch also contains basic functionality tests of the allocator as unittests. The error-catching behaviour will be tested in upcoming patches that use Scudo as an implementing allocator. Reviewers: vlad.tsyrklevich, eugenis, jfb Reviewed By: vlad.tsyrklevich Subscribers: dexonsmith, kubamracek, mgorny, cryptoad, jfb, #sanitizers, llvm-commits, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D62872 llvm-svn: 362636
* Changed force build of GWP-ASan options parser to be staticallyMitch Phillips2019-06-051-1/+1
| | | | | | | linked instead of dynamic. This should help resolve a downstream build order issue against libc++. llvm-svn: 362566
* [GWP-ASan] Configuration options [3].Mitch Phillips2019-06-045-0/+253
| | | | | | | | | | | | | | | | | | | | | Summary: See D60593 for further information. This patch introduces the configuration options for GWP-ASan. In general, we expect the supporting allocator to populate the options struct, and give that to GWP-ASan during initialisation. For allocators that are okay with pulling in sanitizer_common, we also provide an optional parser that populates the gwp_asan::Options struct with values provided in the GWP_ASAN_OPTIONS environment variable. This patch contains very little logic, and all of the testable components (i.e. the optional parser's internal logic) is tested as part of the sanitizer_common testbed. Reviewers: vlad.tsyrklevich, morehouse, jfb Reviewed By: morehouse Subscribers: dexonsmith, kubamracek, mgorny, #sanitizers, llvm-commits, vitalybuka Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D62698 llvm-svn: 362527
* Attempt to fix test failure for armv8.Mitch Phillips2019-05-301-2/+2
| | | | | | | | Looks like armv8 can't handle a thousand threads, which GWP-ASan requests when running a synchronised mutex test. Limiting this to 100 to attempt to fix the build issue. llvm-svn: 362163
* Attempt to fix 'mutex.h' not found when building mutex_posix.Mitch Phillips2019-05-301-1/+1
| | | | llvm-svn: 362149
* [GWP-ASan] Mutex implementation [2].Mitch Phillips2019-05-306-1/+239
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: See D60593 for further information. This patch pulls out the mutex implementation and the required definitions file. We implement our own mutex for GWP-ASan currently, because: 1. We must be compatible with the sum of the most restrictive elements of the supporting allocator's build system. Current targets for GWP-ASan include Scudo (on Linux and Fuchsia), and bionic (on Android). 2. Scudo specifies `-nostdlib++ -nonodefaultlibs`, meaning we can't use `std::mutex` or `mtx_t`. 3. We can't use `sanitizer_common`'s mutex, as the supporting allocators cannot afford the extra maintenance (Android, Fuchsia) and code size (Fuchsia) overheads that this would incur. In future, we would like to implement a shared base mutex for GWP-ASan, Scudo and sanitizer_common. This will likely happen when both GWP-ASan and Scudo standalone are not in the development phase, at which point they will have stable requirements. Reviewers: vlad.tsyrklevich, morehouse, jfb Reviewed By: morehouse Subscribers: dexonsmith, srhines, cfe-commits, kubamracek, mgorny, cryptoad, jfb, #sanitizers, llvm-commits, vitalybuka, eugenis Tags: #sanitizers, #llvm, #clang Differential Revision: https://reviews.llvm.org/D61923 llvm-svn: 362138
* Explicitly remove -stdlib=libc++, as we pass -nostdinc++ anyway. This should ↵Mitch Phillips2019-05-171-0/+3
| | | | | | fix the android builtbots, and is a direct copy from what Scudo does. llvm-svn: 361073
* [GWP-ASan] Fixed issue with c++ standard library dependency.Mitch Phillips2019-05-173-6/+6
| | | | | | | | | | | | | | | | | | | Summary: Removed dependency on c++ standard library. Some supporting allocators (namely Scudo on Fuchsia, and shortly, scudo standalone) has a hard requirement of no c++stdlib. This patch updates the build system so that we don't have any c++ stdlib dependencies. It also will conveniently fix a racy build-order bug discrepency between GWP-ASan and libc++. Reviewers: phosek, morehouse Reviewed By: phosek, morehouse Subscribers: kubamracek, mgorny, cryptoad, #sanitizers, llvm-commits, beanz, smeenai, vitalybuka Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D62048 llvm-svn: 360982
* [GWP-ASan] Initial build files, implementation of PRNG [1].Mitch Phillips2019-05-143-0/+77
Summary: See D60593 for further information. This patch slices off the PRNG implementation and the initial build files for GWP-ASan. Reviewers: vlad.tsyrklevich, morehouse, vitalybuka Reviewed By: morehouse Subscribers: srhines, kubamracek, mgorny, #sanitizers, llvm-commits, cryptoad, eugenis Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61867 llvm-svn: 360710
OpenPOWER on IntegriCloud