summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan
Commit message (Collapse)AuthorAgeFilesLines
...
* [NFC][Sanitizer] Hard-code fast/slow unwinder at call siteJulian Lettner2019-02-271-3/+6
| | | | | | | | | | | | | Also assert that the caller always gets what it requested. This purely mechanical change simplifies future refactorings and eventual removal of BufferedStackTrace::Unwind. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58557 llvm-svn: 355022
* Revert "[compiler-rt] Intercept the bcmp() function."Vlad Tsyrklevich2019-02-261-26/+16
| | | | | | | This reverts commits r354851, 354852, 354853 and r354888. They were causing build failures on the android sanitizer bot. llvm-svn: 354906
* [compiler-rt] Intercept the bcmp() function.Clement Courbet2019-02-261-16/+26
| | | | | | | | | | | | | | | | | | | | | Summary: I have not introduced a separate hook for `bcmp()` as I don't think there should be any reason for a sanitizer to treat it differently from `memcmp()`. This is only enabled when building on POSIX with GNU extensions. Context: this is to avoid losing coverage when emitting `bcmp() == 0` instead of `memcmp() == 0` in llvm, see https://reviews.llvm.org/D56593. Reviewers: mgorny, krytarowski, vitalybuka, dvyukov Subscribers: kubamracek, dberris, delcypher, jdoerfert, #sanitizers, llvm-commits, jyknight Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D58379 llvm-svn: 354851
* [winasan] Unpoison stack memory when threads exit (redux)David Major2019-02-261-0/+13
| | | | | | | | | | | | | | This is a second attempt at r342652 using a TLS callback instead of an interceptor. In long-running builds we've seen some ASan complaints during thread creation that we suspect are due to leftover poisoning from previous threads whose stacks occupied that memory. This patch adds a callback that unpoisons the stack memory when a thread exits. Differential Revision: https://reviews.llvm.org/D58641 llvm-svn: 354836
* Revert "[asan] Fix vfork handling.", +1Evgeniy Stepanov2019-02-217-33/+0
| | | | | | Revert r354625, r354627 - multiple build failures. llvm-svn: 354629
* [asan] Fix vfork handling.Evgeniy Stepanov2019-02-211-4/+2
| | | | | | | | __asan_handle_vfork was unpoisoning the wrong part of the stack. Adjust the test to catch this reliably (current failure is non-deterministic). llvm-svn: 354627
* [hwasan,asan] Intercept vfork.Evgeniy Stepanov2019-02-217-0/+35
| | | | | | | | | | | | | | Summary: AArch64 only for now. Reviewers: vitalybuka, pcc Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, jdoerfert, #sanitizers, llvm-commits, kcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58313 llvm-svn: 354625
* [compiler-rt] Cleanup usage of C++ ABI libraryJonas Hahnfeld2019-02-161-1/+1
| | | | | | | | | | | | | Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking unit tests. This needs to be a full C++ library and cannot be libcxxabi. Recommit r354132 which I reverted in r354153 because it broke a sanitizer bot. This was because of the "fixes" for pthread linking, so I've removed these changes. Differential Revision: https://reviews.llvm.org/D58012 llvm-svn: 354198
* Revert "[compiler-rt] Cleanup usage of C++ ABI library"Jonas Hahnfeld2019-02-151-1/+1
| | | | | | | This reverts r354132 because it breaks sanitizer-x86_64-linux: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/19915 llvm-svn: 354153
* [compiler-rt] Cleanup usage of C++ ABI libraryJonas Hahnfeld2019-02-151-1/+1
| | | | | | | | | Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking unit tests. This needs to be a full C++ library and cannot be libcxxabi. Differential Revision: https://reviews.llvm.org/D58012 llvm-svn: 354132
* sanitizers: Introduce ThreadType enumDmitry Vyukov2019-02-074-7/+6
| | | | | | | | | | | | | Replace bool workerthread flag with ThreadType enum. This change is preparation for fiber support. [dvyukov: fixed build of sanitizer_thread_registry_test.cc] Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57839 Context: https://reviews.llvm.org/D54889 llvm-svn: 353390
* [ASan] On Darwin record global allocator pointer and size in introspection ↵Dan Liew2019-01-211-1/+17
| | | | | | | | | | | | struct. This implements `mi_extra_init(...)` for the ASan allocator on Darwin and uses the `__lsan::GetAllocatorGlobalRange(...)` function to retrieve the allocator pointer and size. rdar://problem/45284065 llvm-svn: 351713
* On Darwin add allocator address and size fields toDan Liew2019-01-211-0/+1
| | | | | | | | | | | | | | `sanitizer_malloc_introspection_t` and initialize them to zero. We allow sanitizer implementations to perform different initialization by defining `COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT` to be `1` and providing an implementation of `mi_extra_init(...)`. We use these changes in future patches to implement malloc zone enumeration. rdar://problem/45284065 llvm-svn: 351712
* On Darwin allow for sanitizer malloc implementations to provide a zoneDan Liew2019-01-211-0/+1
| | | | | | | | | | | | | | | | enumerator. This is done by defining `COMMON_MALLOC_HAS_ZONE_ENUMERATOR` to `1` and then by providing an implementation of the `mi_enumerator(...)` function. If a custom implementation isn't desired the macro is set to `0` which causes a stub version (that fails) to be used. Currently all Darwin sanitizers that have malloc implementations define this to be `0` so there is no functionality change. rdar://problem/45284065 llvm-svn: 351711
* Fix bug in `AsanAllocatorASVT` (ASan) and `AllocatorASVT` (LSan) templated ↵Dan Liew2019-01-201-1/+2
| | | | | | | | | | | | | | alias. We forgot to pass `AddressSpaceView` to the `CombinedAllocator` which meant we would always use `LocalAddressSpaceView` for the `CombinedAllocator` leading to a static_assert failing when we tried to do `AsanAllocatorASVT<RemoteAddressSpaceView>` or `AllocatorASVT<RemoteAddressSpaceView>`. rdar://problem/45284065 llvm-svn: 351689
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1977-308/+231
| | | | | | | | | | | | | | | | | 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
* [asan] Add fallback for Thumb after r350139Diana Picus2019-01-141-0/+11
| | | | | | | | | | | | | | This reverts r350806 which marked some tests as UNSUPPORTED on ARM and instead reintroduces the old code path only for Thumb, since that seems to be the only target that broke. It would still be nice to find the root cause of the breakage, but with the branch point for LLVM 8.0 scheduled for next week it's better to put things in a stable state while we investigate. Differential Revision: https://reviews.llvm.org/D56594 llvm-svn: 351040
* [asan] Support running without /procEvgeniy Stepanov2019-01-081-6/+14
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: vitalybuka, pcc, krytarowski Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56141 llvm-svn: 350590
* Add support for background thread on NetBSD in ASanKamil Rytarowski2018-12-291-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Change the point of calling MaybeStartBackgroudThread() from AsanInitInternal() that is too early on NetBSD to a constructor (with aid of C++11 lambda construct). Enable the code for background thread as is for NetBSD. Rename test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc to test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cc and allow runs on NetBSD. This tests passes correctly. Reviewers: vitalybuka, joerg, eugenis Reviewed By: eugenis Subscribers: eugenis, kubamracek, fedor.sergeev, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55887 llvm-svn: 350139
* Revert "[asan] Support running without /proc.", +1Evgeniy Stepanov2018-12-282-37/+14
| | | | | | | | | Revert r350104 "[asan] Fix build on windows." Revert r350101 "[asan] Support running without /proc." These changes break Mac build, too. llvm-svn: 350112
* [asan] Fix build on windows.Evgeniy Stepanov2018-12-271-1/+9
| | | | | | | | | | Reviewers: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56111 llvm-svn: 350104
* [asan] Support running without /proc.Evgeniy Stepanov2018-12-272-14/+29
| | | | | | | | | | | | | | | | | | Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55874 llvm-svn: 350101
* Do not rely on that subject of ErrorAllocTypeMismatch is a heap address.Martin Liska2018-12-272-7/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D54856. llvm-svn: 350085
* Introduce `AddressSpaceView` template parameter to `CombinedAllocator`.Dan Liew2018-12-211-4/+14
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow up to https://reviews.llvm.org/D55764 . For the ASan and LSan allocatorsthe type declarations have been modified so that it's possible to create a combined allocator type that consistently uses a different type of `AddressSpaceView`. We intend to use this in future patches. For the other sanitizers they just use `LocalAddressSpaceView` by default because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov, yln Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55766 llvm-svn: 349957
* Introduce `AddressSpaceView` template parameter to `SizeClassAllocator64`.Dan Liew2018-12-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow up patch to r349138. This patch makes a `AddressSpaceView` a type declaration in the allocator parameters used by `SizeClassAllocator64`. For ASan, LSan, and the unit tests the AP64 declarations have been made templated so that `AddressSpaceView` can be changed at compile time. For the other sanitizers we just hard-code `LocalAddressSpaceView` because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55764 llvm-svn: 349954
* Remove pointless casts.Evgeniy Stepanov2018-12-201-2/+2
| | | | llvm-svn: 349717
* Reimplement Thread Static Data ASan routines with TLSKamil Rytarowski2018-12-191-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Thread Static Data cannot be used in early init on NetBSD and FreeBSD. Reuse the ASan TSD API for compatibility with existing code with an alternative implementation using Thread Local Storage. New version uses Thread Local Storage to store a pointer with thread specific data. The destructor from TSD has been replaced with a TLS destrucutor that is called upon thread exit. Reviewers: joerg, vitalybuka, jfb Reviewed By: vitalybuka Subscribers: dim, emaste, ro, jfb, devnexen, kubamracek, mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55596 llvm-svn: 349619
* Introduce `AddressSpaceView` template parameter to `SizeClassAllocator32`, ↵Dan Liew2018-12-141-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `FlatByteMap`, and `TwoLevelByteMap`. Summary: This is a follow up patch to r346956 for the `SizeClassAllocator32` allocator. This patch makes `AddressSpaceView` a template parameter both to the `ByteMap` implementations (but makes `LocalAddressSpaceView` the default), some `AP32` implementations and is used in `SizeClassAllocator32`. The actual changes to `ByteMap` implementations and `SizeClassAllocator32` are very simple. However the patch is large because it requires changing all the `AP32` definitions, and users of those definitions. For ASan and LSan we make `AP32` and `ByteMap` templateds type that take a single `AddressSpaceView` argument. This has been done because we will instantiate the allocator with a type that isn't `LocalAddressSpaceView` in the future patches. For the allocators used in the other sanitizers (i.e. HWAsan, MSan, Scudo, and TSan) use of `LocalAddressSpaceView` is hard coded because we do not intend to instantiate the allocators with any other type. In the cases where untemplated types have become templated on a single `AddressSpaceView` parameter (e.g. `PrimaryAllocator`) their name has been changed to have a `ASVT` suffix (Address Space View Type) to indicate they are templated. The only exception to this are the `AP32` types due to the desire to keep the type name as short as possible. In order to check that template is instantiated in the correct a way a `static_assert(...)` has been added that checks that the `AddressSpaceView` type used by `Params::ByteMap::AddressSpaceView` matches the `Params::AddressSpaceView`. This uses the new `sanitizer_type_traits.h` header. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov Subscribers: mgorny, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D54904 llvm-svn: 349138
* Windows ASan: Instrument _msize_base()Vlad Tsyrklevich2018-12-142-0/+7
| | | | | | | | | | | | | | | | | | | | Summary: A recent update to the VS toolchain in chromium [1] broke the windows ASan bot because the new toolchain calls _msize_base() instead of _msize() in a number of _aligned_* UCRT routines. Instrument _msize_base() as well. [1] https://crbug.com/914947 Reviewers: rnk, #sanitizers, vitalybuka Reviewed By: rnk, #sanitizers, vitalybuka Subscribers: vitalybuka, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55684 llvm-svn: 349115
* [asan] Don't check ODR violations for particular types of globalsVitaly Buka2018-12-131-4/+9
| | | | | | | | | | | | | | | | | Summary: private and internal: should not trigger ODR at all. unnamed_addr: current ODR checking approach fail and rereport false violation if a linker merges such globals linkonce_odr, weak_odr: could cause similar problems and they are already not instrumented for ELF. Reviewers: eugenis, kcc Subscribers: kubamracek, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D55621 llvm-svn: 349015
* Fix bug where we'd try symbolize a second time with the same arguments.Dan Liew2018-12-111-1/+1
| | | | | | | | | | | | | | | | | Summary: Fix bug where we'd try symbolize a second time with the same arguments even though symbolization failed the first time. This looks like a long standing typo given that the guard for trying symbolization again is to only try it if symbolization failed using `binary` and `original_binary != binary`. Reviewers: kubamracek, glider, samsonov Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55504 llvm-svn: 348841
* Fix IOError exception being raised in `asan_symbolize.py`crash whenDan Liew2018-12-071-0/+4
| | | | | | | | | using `atos` symbolizer on Darwin when the binaries don't exist. For now we just produce an unsymbolicated stackframe when the binary doesn't exist. llvm-svn: 348659
* [asan] Remove use_odr_indicator runtime flagVitaly Buka2018-12-042-5/+1
| | | | | | | | | | | | | | Summary: Flag was added for testing 3 years ago. Probably it's time to simplify code and usage by removing it. Reviewers: eugenis, m.ostapenko Subscribers: mehdi_amini, kubamracek, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D55254 llvm-svn: 348315
* Introduce a way to allow the ASan dylib on Darwin platforms to be loaded via ↵Dan Liew2018-12-017-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `dlopen()`. Summary: The purpose of this option is provide a way for the ASan dylib to be loaded via `dlopen()` without triggering most initialization steps (e.g. shadow memory set up) that normally occur when the ASan dylib is loaded. This new functionality is exposed by - A `SANITIZER_SUPPORTS_INIT_FOR_DLOPEN` macro which indicates if the feature is supported. This only true for Darwin currently. - A `HandleDlopenInit()` function which should return true if the library is being loaded via `dlopen()` and `SANITIZER_SUPPORTS_INIT_FOR_DLOPEN` is supported. Platforms that support this may perform any initialization they wish inside this function. Although disabling initialization is something that could potentially apply to other sanitizers it appears to be unnecessary for other sanitizers so this patch only makes the change for ASan. rdar://problem/45284065 Reviewers: kubamracek, george.karpenkov, kcc, eugenis, krytarowski Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D54469 llvm-svn: 348078
* Revert r346560 "[winasan] Unpoison the stack in NtTerminateThread"Reid Kleckner2018-11-291-11/+1
| | | | | | | | | | | This reverts r343606 again. The NtTerminateThread interceptor is causing problems in NaCl: https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/CrWinAsan/1839 I reproduced the problem locally and tried my best to debug them, but it's beyond me. llvm-svn: 347933
* Re-land r343606 "[winasan] Unpoison the stack in NtTerminateThread"Reid Kleckner2018-11-091-1/+11
| | | | | | | | | This change was reverted because it caused some nacl tests in chromium to fail. I attempted to reproduce those problems locally, but I was unable to. Let's reland this and let Chromium's test infrastructure discover any problems. llvm-svn: 346560
* [CMake][ASan][HWASan] Set an explicit dependency on libc++ headersPetr Hosek2018-11-071-8/+20
| | | | | | | | | | | | | | We have seen failing builds due to a race condition between RTAsan_dynamic and libc++ headers builds, specifically libc++ headers depend on __config and if this header hasn't been copied into the final location, including other headers will typically result in failure. To avoid this race, we add an explicit dependency on libc++ headers which ensures that they've been copied into place before the sanitizer object library build starts. Differential Revision: https://reviews.llvm.org/D54198 llvm-svn: 346339
* [sanitizer] Use "fast mmap" kernel flag for shadow memory on macOS 10.13.4+Kuba Mracek2018-11-061-0/+2
| | | | | | | | This speeds up process startup and teardown and also reduces lock contention when running multiple ASanified/TSanified processes simultaneously. Should greatly improve lit testing time. Differential Revision: https://reviews.llvm.org/D48445 llvm-svn: 346262
* [asan] Remove flags for clang-cl before it supported EHReid Kleckner2018-10-311-5/+0
| | | | | | | Also remove -Wno-undefined-inline, which needed to work around PR19898, which was fixed. llvm-svn: 345677
* Disable BufferOverflowAfterManyFrees for NetBSDKamil Rytarowski2018-10-301-0/+2
| | | | | | This test hangs in the i386 mode. llvm-svn: 345666
* [sanitizer] Fix mallopt interceptor.Evgeniy Stepanov2018-10-251-1/+1
| | | | | | On error, mallopt is supposed to return 0, not -1. llvm-svn: 345323
* [sanitizers] [windows] Use a linker directive pragma for psapiMartin Storsjo2018-10-101-1/+0
| | | | | | | | | | | | | This allows users of static libraries (such as ubsan) to link without knowing about this transitive dependency, if using the psapi functions that require linking to a separate psapi library. Since Windows 7, these functions (EnumProcessModules, GetModuleInformation, GetProcessMemoryInfo) are remapped to K32- prefixed ones, available in kernel32.dll. Differential Revision: https://reviews.llvm.org/D53012 llvm-svn: 344126
* Disable failing tests lib/asan/tests on NetBSDKamil Rytarowski2018-10-092-0/+4
| | | | | | These isses are not analyzed. llvm-svn: 344045
* Revert r343606/r342652 "[winasan] Unpoison the stack in NtTerminateThread""Reid Kleckner2018-10-051-11/+1
| | | | | | This still seems to be causing pnacl + asan to crash. llvm-svn: 343876
* Reland r342652 "[winasan] Unpoison the stack in NtTerminateThread"David Major2018-10-021-1/+11
| | | | | | | | In long-running builds we've seen some ASan complaints during thread creation that we suspect are due to leftover poisoning from previous threads whose stacks occupied that memory. This patch adds a hook that unpoisons the stack just before the NtTerminateThread syscall. Differential Revision: https://reviews.llvm.org/D52091 llvm-svn: 343606
* [sanitizer] Use -Wl,-z,global on Android for sanitizers except UBsanStephen Hines2018-10-021-0/+8
| | | | | | | | | | | | | | | | | | Summary: This essentially reverts r337010 since it breaks UBSan, which is used for a few platform libraries. The "-z global" flag is now added for Scudo as well. The only other sanitizer shared libraries are for asan and hwasan, which have also been reinstated to use the global flag. Reviewers: cryptoad, eugenis Reviewed By: cryptoad Subscribers: kubamracek, mgorny, delcypher, #sanitizers, nickdesaulniers, chh, kongyi, pirama, llvm-commits Differential Revision: https://reviews.llvm.org/D52770 llvm-svn: 343599
* Revert r342652 "[winasan] Unpoison the stack in NtTerminateThread"Hans Wennborg2018-09-281-11/+1
| | | | | | | | | | | | | This seems to cause the thread's exit code to be clobbered, breaking Chromium tests. Also revert follow-up r342654. > In long-running builds we've seen some ASan complaints during thread creation that we suspect are due to leftover poisoning from previous threads whose stacks occupied that memory. This patch adds a hook that unpoisons the stack just before the NtTerminateThread syscall. > > Differential Revision: https://reviews.llvm.org/D52091 llvm-svn: 343322
* [asan] [windows] Don't use CheckFailed in dynamic runtime thunk modeMartin Storsjo2018-09-261-1/+1
| | | | | | | | | | Since SVN r342651, CheckFailed isn't exported from asan-dynamic. See comments in https://reviews.llvm.org/D52279#1246222 for a longer discussion on this issue. Differential Revision: https://reviews.llvm.org/D52566 llvm-svn: 343136
* [winasan] Pin the ASan DLL to prevent unloadingDavid Major2018-09-261-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D52505 llvm-svn: 343123
* [CMake] [MinGW] Build address sanitizer for MinGW if building with clangMartin Storsjo2018-09-261-1/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D51885 llvm-svn: 343074
OpenPOWER on IntegriCloud