summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan
Commit message (Collapse)AuthorAgeFilesLines
...
* [ASan] [MinGW] Only try to export MSVC specific C++ symbols if building with ↵Martin Storsjo2018-09-261-1/+1
| | | | | | | | a MSVC like compiler Differential Revision: https://reviews.llvm.org/D51878 llvm-svn: 343073
* [ASan] [Windows] Avoid including windows.h in asan_malloc_win.ccMartin Storsjo2018-09-251-2/+11
| | | | | | | | | | Instead provide manual declarations of the used types, to avoid pulling in conflicting declarations of some of the functions that are to be overridden. Differential Revision: https://reviews.llvm.org/D51914 llvm-svn: 343014
* [winasan] Unpoison the stack in NtTerminateThreadDavid Major2018-09-201-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: 342652
* [ASan] [Windows] Remove const from _msize function declaration parameterMartin Storsjo2018-09-111-1/+1
| | | | | | | | | This function isn't declared with a const parameter anywhere; neither in MSVC (neither in ucrt or in older msvcrt versions) nor in mingw-w64. Differential Revision: https://reviews.llvm.org/D51876 llvm-svn: 341903
* [Xray] Darwin improving slightly the supportDavid Carlier2018-08-301-0/+1
| | | | | | | | | | | | | using sysctl to get the tic frequency data. still linkage issue for X-ray_init not resolved. Reviewers: dberris, kubamracek Reviewed By: dberris Differential Revision: https://reviews.llvm.org/D51399 llvm-svn: 341019
* [sanitizer] Revert D50940Kostya Kortchinsky2018-08-292-2/+2
| | | | | | | | | | | | | | | | | Summary: The previous version of the patch makes some code unable to distinguish failure to map address 0 and error. Revert to turn the bots back to green while figuring out a new approach. Reviewers: eugenis Reviewed By: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D51451 llvm-svn: 340957
* [sanitizer] Change Mmap*NoAccess to return nullptr on errorKostya Kortchinsky2018-08-232-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: `MmapNoAccess` & `MmapFixedNoAccess` return directly the result of `internal_mmap`, as opposed to other Mmap functions that return nullptr. This inconsistency leads to some confusion for the callers, as some check for `~(uptr)0` (`MAP_FAILED`) for failure (while it can fail with `-ENOMEM` for example). Two potential solutions: change the callers, or make the functions return `nullptr` on failure to follow the precedent set by the other functions. The second option looked more appropriate to me. Correct the callers that were wrongly checking for `~(uptr)0` or `MAP_FAILED`. TODO for follow up CLs: - There are a couple of `internal_mmap` calls in XRay that check for MMAP_FAILED as a result as well (cc: @dberris); they should use `internal_iserror`; Reviewers: eugenis, alekseyshl, dberris, kubamracek Reviewed By: alekseyshl Subscribers: kristina, kubamracek, delcypher, #sanitizers, dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D50940 llvm-svn: 340576
* Add header guard to asan_report.hFilipe Cabecinhas2018-08-021-0/+4
| | | | llvm-svn: 338700
* [asan] Fix typoFangrui Song2018-07-301-1/+1
| | | | llvm-svn: 338225
* Fix Asan-i386-calls-Test AddressSanitizer.ShadowGapTest on FreeBSDFangrui Song2018-07-281-1/+1
| | | | | | | | | 0x22000000 happens to be on the left of a heap allocation and the error message is different (heap-buffer-overflow). FreeBSD NetBSD have larger SHADOW_OFFSET (0x40000000) but let's try not using #ifdef here. llvm-svn: 338208
* Mark REAL(swapcontext) with indirect_return attribute on x86H.J. Lu2018-07-201-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When shadow stack from Intel CET is enabled, the first instruction of all indirect branch targets must be a special instruction, ENDBR. lib/asan/asan_interceptors.cc has ... int res = REAL(swapcontext)(oucp, ucp); ... REAL(swapcontext) is a function pointer to swapcontext in libc. Since swapcontext may return via indirect branch on x86 when shadow stack is enabled, as in this case, int res = REAL(swapcontext)(oucp, ucp); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This function may be returned via an indirect branch. Here compiler must insert ENDBR after call, like call *bar(%rip) endbr64 I opened an LLVM bug: https://bugs.llvm.org/show_bug.cgi?id=38207 to add the indirect_return attribute so that it can be used to inform compiler to insert ENDBR after REAL(swapcontext) call. We mark REAL(swapcontext) with the indirect_return attribute if it is available. This fixed: https://bugs.llvm.org/show_bug.cgi?id=38249 Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D49608 llvm-svn: 337603
* sanitizers: consistently check result of MmapFixedNoReserveDmitry Vyukov2018-07-201-2/+1
| | | | | | | | | | | | | | | | MmapFixedNoReserve does not terminate process on failure. Failure to check its result and die will always lead to harder to debug crashes later in execution. This was observed in Go processes due to some address space conflicts. Consistently check result of MmapFixedNoReserve. While we are here also add warn_unused_result attribute to prevent such bugs in future and change return type to bool as that's what all callers want. Reviewed in https://reviews.llvm.org/D49367 llvm-svn: 337531
* [sanitizer] Use -Wl,-z,global on AndroidKostya Kortchinsky2018-07-131-14/+0
| | | | | | | | | | | | | | | | | | | | | | | Summary: Use `-Wl,-z,global` for all Sanitizer shared libraries on Android. We want them to be in the global group (https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#changes-to-library-search-order) to avoid any alloc/dealloc mismatch between the libc allocator & said library. `audioserver` was one of the binary that exhibited the problem with Scudo, this seems to fix it. [edited for accuracy] Reviewers: eugenis, alekseyshl Reviewed By: eugenis Subscribers: kubamracek, srhines, mgorny, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D49198 llvm-svn: 337010
* [CMake] Add compiler-rt header files to the list of sources for targetsDan Liew2018-07-101-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when building with an IDE so that header files show up in the UI. This massively improves the development workflow in IDEs. To implement this a new function `compiler_rt_process_sources(...)` has been added that adds header files to the list of sources when the generator is an IDE. For non-IDE generators (e.g. Ninja/Makefile) no changes are made to the list of source files. The function can be passed a list of headers via the `ADDITIONAL_HEADERS` argument. For each runtime library a list of explicit header files has been added and passed via `ADDITIONAL_HEADERS`. For `tsan` and `sanitizer_common` a list of headers was already present but it was stale and has been updated to reflect the current state of the source tree. The original version of this patch used file globbing (`*.{h,inc,def}`) to find the headers but the approach was changed due to this being a CMake anti-pattern (if the list of headers changes CMake won't automatically re-generate if globbing is used). The LLVM repo contains a similar function named `llvm_process_sources()` but we don't use it here for several reasons: * It depends on the `LLVM_ENABLE_OPTION` cache variable which is not set in standalone compiler-rt builds. * We would have to `include(LLVMProcessSources)` which I'd like to avoid because it would include a bunch of stuff we don't need. Differential Revision: https://reviews.llvm.org/D48422 llvm-svn: 336663
* [ASan] Minor ASan error reporting cleanupAlex Shlyapnikov2018-07-093-100/+84
| | | | | | | | | | | | | | Summary: - use proper Error() decorator for error messages - refactor ASan thread id and name reporting Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D49044 llvm-svn: 336573
* [Sanitizers] Remove OOM/BadRequest allocator error handling policies.Alex Shlyapnikov2018-06-201-8/+8
| | | | | | | | | | | | | | | | | | | Summary: Remove the generic error nadling policies and handle each allocator error explicitly. Although more verbose, it allows for more comprehensive, precise and actionable allocator related failure reports. This finishes up the series of changes of the particular sanitizer allocators, improves the internal allocator error reporting and removes now unused policies. Reviewers: vitalybuka, cryptoad Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D48328 llvm-svn: 335147
* [asan] Avoid deadlock when initializing the symbolizer CHECK failsReid Kleckner2018-06-191-2/+8
| | | | llvm-svn: 335007
* [sanitizer] Use const char* in internal_simple_strtollVitaly Buka2018-06-171-1/+1
| | | | llvm-svn: 334900
* [ASan] Linker-initialize static ScopedInErrorReport::current_error_.Alex Shlyapnikov2018-06-142-1/+2
| | | | | | | | | | | | | | | | | | | Summary: Static ScopedInErrorReport::current_error_ can be linker initialized to shave one global ctor call on application startup and be __asan_init-safe. Global constructors in ASan runtime are bad because __asan_init runs from preinit_array, before any such constructors. Issue: https://github.com/google/sanitizers/issues/194 Reviewers: eugenis, morehouse Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D48141 llvm-svn: 334748
* [ASAN] fix typos and disable long-object-path test for win32Peter Wu2018-06-141-2/+2
| | | | | | | | Glob patterns seem unsupported for commands executed by the emulated shell (LIT_USE_INTERNAL_SHELL=1). Disable the test while that is being addressed (a workaround such as "cd a-*" also does not work). llvm-svn: 334719
* [ASAN] fix startup crash in dlsym for long paths since glibc 2.27Peter Wu2018-06-141-1/+18
| | | | | | | | | | | | | | | | | | | | Summary: Error messages for dlsym used to be stored on the stack, but since commit 2449ae7b ("ld.so: Introduce struct dl_exception") in glibc 2.27 these are now stored on the heap (and thus use the dlsym alloc pool). Messages look like "undefined symbol: __isoc99_printf\0/path/to/a.out". With many missing library functions and long object paths, the pool is quickly exhausted. Implement a simple mechanism to return freed memory to the pool (clear it in case it is used for calloc). Fixes https://github.com/google/sanitizers/issues/957 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D47995 llvm-svn: 334703
* [asan, myriad] Use local pool for new/delete when ASan run-time is not upWalter Lee2018-06-083-4/+73
| | | | | | | | This can happen on Myriad RTEMS so needs to be handled. Differential Revision: https://reviews.llvm.org/D47916 llvm-svn: 334329
* [Sanitizers] Check alignment != 0 for aligned_alloc and posix_memalignAlex Shlyapnikov2018-06-087-1/+61
| | | | | | | | | | | | | | | Summary: Move the corresponding tests to the common folder (as all of the sanitizer allocators will support this feature soon) and add the checks specific to aligned_alloc to ASan and LSan allocators. Reviewers: vitalybuka Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D47924 llvm-svn: 334316
* Introduce CheckASLR() in sanitizersKamil Rytarowski2018-06-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: At least the ASan, MSan, TSan sanitizers require disabled ASLR on a NetBSD. Introduce a generic CheckASLR() routine, that implements a check for the current process. This flag depends on the global or per-process settings. There is no simple way to disable ASLR in the build process from the level of a sanitizer or during the runtime execution. With ASLR enabled sanitizers that operate over the process virtual address space can misbehave usually breaking with cryptic messages. This check is dummy for !NetBSD. Sponsored by <The NetBSD Foundation> Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: cryptoad, kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D47442 llvm-svn: 333985
* [asan, myriad] Implement aligned local pool allocationWalter Lee2018-06-011-1/+25
| | | | | | | | Extend the local pool allocation support to posix_memalign. Differential Revision: https://reviews.llvm.org/D47642 llvm-svn: 333788
* [asan, myriad] Configure platform interceptorsWalter Lee2018-06-011-0/+2
| | | | | | | | | | | Myriad only uses the platform interceptors for memory allocation routines. Configure them properly. Also add a missing guard around aligned alloc interceptor. Differential Revision: https://reviews.llvm.org/D47641 llvm-svn: 333784
* [asan] Remove unneeded VirtualQuery from exception handlerReid Kleckner2018-05-301-5/+0
| | | | | | | | We don't use the result of the query, and all tests pass if I remove it. During startup, ASan spends a fair amount of time in this handler, and the query is much more expensive than the call to commit the memory. llvm-svn: 333595
* [asan, myriad] Simplify main thread handlingWalter Lee2018-05-301-23/+10
| | | | | | | | | | On Myriad RTEMS, we don't need to treat the main thread differently. The existing thread hooks will do the right thing, so get rid of all the unneeded special logic. Differential Revision: https://reviews.llvm.org/D47502 llvm-svn: 333504
* [asan, myriad] Reset shadow memory during exitWalter Lee2018-05-301-14/+17
| | | | | | | | | Reset shadow memory during exit. Also update a cut-and-paste comment, and do some minor refactoring of InitializeShadowMemory. Differential Revision: https://reviews.llvm.org/D47501 llvm-svn: 333503
* [asan] Use dynamic allocator space address on Android/AArch64.Evgeniy Stepanov2018-05-221-1/+2
| | | | | | | | | | | | | | Summary: We need one library to support all of 39, 42 and 48 bit VMAs, and there is no common address that works for all of them. Reviewers: kcc, alekseyshl, javed.absar Subscribers: rengolin, srhines, kubamracek, kristof.beyls, llvm-commits, cryptoad Differential Revision: https://reviews.llvm.org/D47160 llvm-svn: 333025
* [asan] Make GetCurrentThread RTEMS-friendlyWalter Lee2018-05-212-0/+6
| | | | | | | | | | | | | | | | | On RTEMS, system and user code all live in a single binary and address space. There is no clean separation, and instrumented code may execute before the ASan run-time is initialized (or after it has been destroyed). Currently, GetCurrentThread() may crash if it's called before ASan run-time is initialized. Make it return nullptr instead. Similarly, fix __asan_handle_no_return so that it gives up rather than try something that may crash. Differential Revision: https://reviews.llvm.org/D46459 llvm-svn: 332888
* Align ClearShadowForThreadStackAndTLS for NetBSD/i386Kamil Rytarowski2018-05-191-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The static TLS vector for the main thread on NetBSD/i386 can be unaligned in terms of the shadow granularity. Align the start of it with Round Down and end of it with Round Up operations for the shadow granularity shift. Example static TLS vector ranges on NetBSD/i386: tls_begin_=0xfbee7244 tls_end_=0xfbee726c. ClearShadowForThreadStackAndTLS() is called from the Main Thread bootstrap functions. This change restores the NetBSD x86 32-bit (i386) support. Sponsored by <The NetBSD Foundation> Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D46585 llvm-svn: 332792
* [asan] Explicitly declare memintrinsics interceptors to have C linkageWalter Lee2018-05-181-6/+6
| | | | | | | | This is needed on RTEMS. Also update a comment. Differential Revision: https://reviews.llvm.org/D47079 llvm-svn: 332746
* [asan] Remove an unsigned compare >= 0Walter Lee2018-05-181-1/+1
| | | | | | | | | This is not needed after we've forked the Myriad version. Not to mention it produces a compiler warning. Differential Revision: https://reviews.llvm.org/D47054 llvm-svn: 332744
* [asan] Add target-specific files for Myriad RTEMS portWalter Lee2018-05-182-0/+264
| | | | | | Differential Revision: https://reviews.llvm.org/D46468 llvm-svn: 332691
* [asan] Add support for Myriad RTEMS memory mapWalter Lee2018-05-184-52/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Myriad RTEMS memory system has a few unique aspects that require support in the ASan run-time. - A limited amount of memory (currently 512M). - No virtual memory, no memory protection. - DRAM starts at address 0x80000000. Other parts of memory may be used for MMIO, etc. - The second highest address bit is the "cache" bit, and 0x80000000 and 0x84000000 alias to the same memory. To support the above, we make the following changes: - Use a ShadowScale of 5, to reduce shadow memory overhead. - Adjust some existing macros to remove assumption that the lowest memory address is 0. - add a RawAddr macro that on Myriad strips the cache bit from the input address, before using the address for shadow memory (for other archs this does nothing). - We must check that an address is in DRAM range before using it to index into shadow memory. Differential Revision: https://reviews.llvm.org/D46456 llvm-svn: 332690
* [sanitizer] Trivial portion of the port to Myriad RTEMSWalter Lee2018-05-186-13/+18
| | | | | | | | | | | | | | | | | | | | | This commit contains the trivial portion of the port of ASan to Myriad RTEMS. - Whitelist platform in sanitizer_platform.h, ubsan_platform.h - Turn off general interception - Use memset for FastPoisonShadow - Define interception wrappers - Set errno symbol correctly - Enable ASAN_LOW_MEMORY - Enable preinit array - Disable slow unwinding - Use fuchsia offline symbolizer - Disable common code for: InitializeShadowMemory, CreateMainThread, AsanThread::ThreadStart, StartReportDeadlySignal, MaybeReportNonExecRegion. Differential Revision: https://reviews.llvm.org/D46454 llvm-svn: 332681
* [asan] Add a magic shadow value for shadw gapWalter Lee2018-05-162-0/+4
| | | | | | | | | This gives us something to insert into the shadow gap for systems that don't have memory protection turned on there (i.e. on Myriad). Differential Revision: https://reviews.llvm.org/D46457 llvm-svn: 332557
* [asan] Restore check removed by r332033Walter Lee2018-05-161-0/+2
| | | | | | | | Needed by fiber handling code, and possibly other code paths. Differential Revision: https://reviews.llvm.org/D46981 llvm-svn: 332553
* [ASan] Fix range check in AddrIsInHighShadowDavid Major2018-05-111-2/+2
| | | | | | | | This appears to be a copy/paste artifact from `AddrIsInHighMem`. It was caught by Firefox's jit-tests on Win64. Differential Revision: https://reviews.llvm.org/D46291 llvm-svn: 332092
* [asan] Enable memtrinsics interception for RTEMSWalter Lee2018-05-101-5/+5
| | | | | | | | | | Replace decltype(memcpy) with decltype(__asan_memcpy) because memcpy has not been defined in any headers on RTEMS. Similarly for memmove and memset. Differential Revision: https://reviews.llvm.org/D46625 llvm-svn: 332047
* [asan] Initialize fake stack during thread initWalter Lee2018-05-102-3/+3
| | | | | | | | | | | If detect-stack-use-after-return is on, initialize fake stack during AsanThread::Init(), rather than lazily. This is required on Myriad. From kcc: "There used to be a reason why this was done lazily, but I don't remember if we still have that reason." Tested on x86. Differential Revision: https://reviews.llvm.org/D46626 llvm-svn: 332033
* Register NetBSD/i386 in asan_mapping.hKamil Rytarowski2018-05-101-0/+10
| | | | | | | | | | | | | | | | | | | | | Summary: Introduce kNetBSD_ShadowOffset32 and document NetBSD/i386 (hosted on amd64 kernel) process virtual address space ranges. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D46708 llvm-svn: 332027
* [lsan] Report unsuspended threadsVitaly Buka2018-05-091-0/+5
| | | | | | | | | | | | | | | Summary: Leak checker needs to suspend all process threads. If we have some running thread in registry but not suspended we can have false leak report. So we will report this case here for future debugging. Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D46663 llvm-svn: 331936
* [CMake] Build shared version of runtimes for FuchsiaPetr Hosek2018-05-091-1/+1
| | | | | | | | | Fuchsia is no longer treated as UNIX which means we need to explicitly enable building of shared versions of runtimes. Differential Revision: https://reviews.llvm.org/D46609 llvm-svn: 331922
* [sanitizer] Cleanup sorting functionsVitaly Buka2018-05-091-4/+4
| | | | llvm-svn: 331915
* [sanitizer] Remove unneeded blank linesVitaly Buka2018-05-091-1/+0
| | | | llvm-svn: 331831
* [sanitizer] Update .clang-format in compiler-rtVitaly Buka2018-05-091-0/+2
| | | | | | Historically style is Google, but we never used AllowShortIfStatementsOnASingleLine. llvm-svn: 331829
* [asan] Fix bug introduced by r331647Walter Lee2018-05-081-1/+1
| | | | | | unmap_shadow_on_exit was inadvertently flipped for non-RTEMS. llvm-svn: 331737
* [asan] Port asan_malloc_linux.cc to RTEMSWalter Lee2018-05-071-6/+16
| | | | | | | | | | | | We reuse the allocation interceptors as is. RTEMS doesn't support dlsyms. However, it needs to handle memory allocation requests before the ASan run-time has been initialized. We use the dlsym alloc pool for this purpose, and we increase its size to 4k to support this usage. Differential Revision: https://reviews.llvm.org/D46465 llvm-svn: 331649
OpenPOWER on IntegriCloud