summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_win.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc file in lib/asan to .cppNico Weber2019-08-011-401/+0
| | | | | | Like r367463, but for asan. llvm-svn: 367558
* [sanitizers][windows] Rtl-Heap Interception and testsMatthew G McGovern2019-07-091-25/+50
| | | | | | | | | - Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap - Adds unit tests for the new interceptors and expands HeapAlloc tests to demonstrate new functionality. Reviewed as D62927 llvm-svn: 365422
* Revert "[sanitizers][windows] Rtl-Heap Interception and tests"JF Bastien2019-07-081-50/+25
| | | | | | | | | | | | | | | | | | | | | | | | Causes build failure on clang-ppc64be-linux-lnt: compiler-rt/lib/asan/asan_malloc_win.cc:23:2: error: #error "Missing arch or unsupported platform for Windows." #error "Missing arch or unsupported platform for Windows." ^~~~~ compiler-rt/lib/asan/asan_malloc_win.cc:25:10: fatal error: heapapi.h: No such file or directory #include <heapapi.h> ^~~~~~~~~~~ compilation terminated. [39/1151] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_debugging.cc.o [40/1151] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o FAILED: projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o /usr/bin/c++ -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/asan -Icompiler-rt/lib/asan -Iinclude -I/home/buildbots/ppc64be-clang-lnt-test/clang-ppc64be-lnt/llvm/include -Icompiler-rt/lib/asan/.. -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++11 -Wno-unused-parameter -O2 -UNDEBUG -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fno-lto -O3 -g -Wno-variadic-macros -Wno-non-virtual-dtor -fno-rtti -MD -MT projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o -MF projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o.d -o projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o -c compiler-rt/lib/asan/asan_malloc_win.cc compiler-rt/lib/asan/asan_malloc_win.cc:23:2: error: #error "Missing arch or unsupported platform for Windows." #error "Missing arch or unsupported platform for Windows." ^~~~~ compiler-rt/lib/asan/asan_malloc_win.cc:25:10: fatal error: heapapi.h: No such file or directory #include <heapapi.h> ^~~~~~~~~~~ llvm-svn: 365384
* [sanitizers][windows] Rtl-Heap Interception and testsMatthew G McGovern2019-07-081-25/+50
| | | | | | | | | - Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap - Adds unit tests for the new interceptors and expands HeapAlloc tests to demonstrate new functionality. Reviewed as D62927 llvm-svn: 365381
* Fix FIXME added in r359339Reid Kleckner2019-04-291-15/+11
| | | | | | | | | We have windows.h in asan_win.cc, so we can just use the correct prototypes for these EH-related interceptors without worrying. Also fix an unused variable warning while I'm here. llvm-svn: 359500
* [Sanitizer][Windows] Speculative fix for broken build on WindowsJulian Lettner2019-04-261-2/+7
| | | | llvm-svn: 359339
* [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
* 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
* Introduce a way to allow the ASan dylib on Darwin platforms to be loaded via ↵Dan Liew2018-12-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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
* 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
* 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
* [winasan] Pin the ASan DLL to prevent unloadingDavid Major2018-09-261-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D52505 llvm-svn: 343123
* [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] 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
* Fix-up for r326106: FindAvailableMemoryRange needs a nullptr as its 5th ↵Kuba Mracek2018-02-261-2/+2
| | | | | | argument. llvm-svn: 326111
* [compiler-rt] Cleanup SignalContext initializationVitaly Buka2017-09-141-1/+1
| | | | | | | | | | Reviewers: eugenis, alekseyshl Subscribers: kubamracek, dberris Differential Revision: https://reviews.llvm.org/D37827 llvm-svn: 313223
* [asan] Fix Windows buildVitaly Buka2017-09-131-1/+1
| | | | llvm-svn: 313177
* [asan] For iOS/AArch64, if the dynamic shadow doesn't fit, restrict the VM spaceKuba Mracek2017-07-121-0/+12
| | | | | | | | | | On iOS/AArch64, the address space is very limited and has a dynamic maximum address based on the configuration of the device. We're already using a dynamic shadow, and we find a large-enough "gap" in the VM where we place the shadow memory. In some cases and some device configuration, we might not be able to find a large-enough gap: E.g. if the main executable is linked against a large number of libraries that are not part of the system, these libraries can fragment the address space, and this happens before ASan starts initializing. This patch has a solution, where we have a "backup plan" when we cannot find a large-enough gap: We will restrict the address space (via MmapFixedNoAccess) to a limit, for which the shadow limit will fit. Differential Revision: https://reviews.llvm.org/D35098 llvm-svn: 307865
* [asan] Remove allow_user_segv_handler on Windows.Vitaly Buka2017-05-241-1/+1
| | | | | | | | | | | | | | | | | Summary: This flags is not covered by tests on Windows and looks like it's implemented incorrectly. Switching its default breaks some tests. Taking into account that related handle_segv flag is not supported on Windows it's safer to remove it until we commit to support it. Reviewers: eugenis, zturner, rnk Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D33471 llvm-svn: 303728
* [compiler-rt][asan] Add support for desallocation of unhandled pointersEtienne Bergeron2017-02-211-0/+4
| | | | | | | | | | | | | | Summary: On windows 10, the ucrt DLL is performing allocations before the function hooking and there are multiple allocations not handled by Asan. When a free occur at the end of the process, asan is reporting desallocations not malloc-ed. Reviewers: rnk, kcc Reviewed By: rnk, kcc Subscribers: kcc, llvm-commits, kubamracek, chrisha, dberris Differential Revision: https://reviews.llvm.org/D25946 llvm-svn: 295730
* [asan] Intercept SetUnhandledExceptionFilter.Marcos Pividori2017-02-021-24/+42
| | | | | | | | | | | | | | | | In this diff I update the code for asan on Windows, so we can intercept SetUnhandledExceptionFilter and catch some exceptions depending on the result of IsHandledDeadlyException() (which depends on asan flags). This way we have the same behavior on Windows and Posix systems. On Posix, we intercept signal and sigaction, so user's code can only register signal handlers for signals that are not handled by asan. After this diff, the same happens on Windows, user's code can only register exception handlers for exceptions that are not handled by asan. Differential Revision: https://reviews.llvm.org/D29463 llvm-svn: 293957
* [sanitizer] Move DescribeSignalOrException to sanitizer_common.Marcos Pividori2017-02-021-27/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D29459 llvm-svn: 293956
* [sanitizer] Move exception code to sanitizer_common.Marcos Pividori2017-02-021-28/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D29458 llvm-svn: 293955
* [asan] Properly handle exceptions.Marcos Pividori2017-02-021-10/+32
| | | | | | Differential Revision: https://reviews.llvm.org/D29457 llvm-svn: 293954
* General definition for weak functionsMarcos Pividori2017-01-291-12/+0
| | | | | | | | | | | | | | | | | | In this diff, I define a general macro for defining weak functions with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()". This way, we simplify the implementation for different platforms. For example, we cannot define weak functions on Windows, but we can use linker pragmas to create an alias to a default implementation. All of these implementation details are hidden in the new macro. Also, as I modify the name for exported weak symbols on Windows, I needed to temporarily disable "dll_host" test for asan, which checks the list of functions included in asan_win_dll_thunk. Differential Revision: https://reviews.llvm.org/D28596 llvm-svn: 293419
* [sanitizer] [asan] Use macros to simplify weak aliases on Windows.Marcos Pividori2017-01-201-22/+8
| | | | | | | | | This patch adds some useful macros for dealing with pragma directives on Windows. Also, I add appropriate documentation for future users. Differential Revision: https://reviews.llvm.org/D28525 llvm-svn: 292650
* [sancov] force default flags for windowsMike Aizatsky2017-01-051-3/+0
| | | | llvm-svn: 291089
* fixing build, accidentally deleted two linesMike Aizatsky2017-01-051-0/+2
| | | | llvm-svn: 291077
* [sancov] workaround for absence of weak symbols on winMike Aizatsky2017-01-051-0/+2
| | | | llvm-svn: 291076
* [sancov] workaround for absence of weak symbols on winMike Aizatsky2017-01-051-2/+1
| | | | llvm-svn: 291071
* [asan] Create a .ASAN$G(A-Z) section for global registrationReid Kleckner2016-11-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The expectation is that new instrumented code will add global variable metadata to the .ASAN$GL section, and we will use this new code to iterate over it. This technique seems to break when using incremental linking, which seems to align every global to a 256 byte boundary. Presumably this is so that it can incrementally cope with global changing size. Clang already passes -incremental:no as a linker flag when you invoke it to do the link step. The two tests added for this feature will fail until the LLVM instrumentation change in D26770 lands, so they are marked XFAIL for now. Reviewers: pcc, kcc, mehdi_amini, kubabrecka Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D26771 llvm-svn: 287246
* Allow users to call ASan's deadly exception report mechanismReid Kleckner2016-11-151-6/+14
| | | | | | | | | | | Users often have their own unhandled exception filters installed. ASan already goes to great lengths to install its own filter, but our core wars with Chrome crashpad have escalated to the point that its time to declare a truce. By exposing this hook, they can call us directly when they want ASan crash reporting without worrying about who initializes when. llvm-svn: 287040
* Pacify lint checkJonas Hahnfeld2016-11-091-2/+2
| | | | llvm-svn: 286346
* [asan/win] Add init hooks to .CRT$XLABReid Kleckner2016-11-081-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: User applications may register hooks in the .CRT$XL* callback list, which is called very early by the loader. This is very common in Chromium: https://cs.chromium.org/search/?q=CRT.XL&sq=package:chromium&type=cs This has flown under the radar for a long time because the loader appears to catch exceptions originating from these callbacks. It's a real problem when you're debugging an asan application, though, since it makes the program crash early. The solution is to add our own callback to this list, and sort it very early in the list like we do elsewhere. Also add a test with such an instrumented callback, and test that it gets called with asan. Reviewers: etienneb Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D26404 llvm-svn: 286290
* [compiler-rt] Add support for the dynamic shadow allocationEtienne Bergeron2016-09-301-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is adding support for dynamic shadow allocation. This is a merge and re-commit of the following patches. ``` [compiler-rt] Fix Asan build on Android https://reviews.llvm.org/D24768 [compiler-rt] Add support for the dynamic shadow allocation https://reviews.llvm.org/D23363 ``` This patch needed to re-land at the same time: ``` [asan] Support dynamic shadow address instrumentation https://reviews.llvm.org/D23354 ``` Reviewers: rnk, zaks.anna Subscribers: tberghammer, danalbert, kubabrecka, dberris, chrisha, llvm-commits Differential Revision: https://reviews.llvm.org/D25104 llvm-svn: 282882
* Really fix the Windows sanitizer buildReid Kleckner2016-09-151-3/+0
| | | | | | | | | | Don't list __sanitizer_print_memory profile as an INTERFACE_FUNCTION. It is not exported by ASan; it is exported by user code. Move the weak definition from asan_win.cc to sanitizer_win.cc to fix the ubsan tests. llvm-svn: 281619
* Fix the Windows build after r281546Reid Kleckner2016-09-141-0/+3
| | | | llvm-svn: 281558
* [asan] Reify ErrorDeadlySignalFilipe Cabecinhas2016-09-081-6/+5
| | | | | | | | | | | | Summary: Keep reifying other errors. Reviewers: kcc, samsonov Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23873 llvm-svn: 280930
* [asan] Remove runtime flag detect_stack_use_after_scopeVitaly Buka2016-08-291-6/+0
| | | | | | | | | | | | | | | Summary: We are going to use store instructions to poison some allocas. Runtime flag will require branching in instrumented code on every lifetime intrinsic. We'd like to avoid that. Reviewers: eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23967 llvm-svn: 279981
* Fix two tests in Win64 ASanReid Kleckner2016-08-051-4/+15
| | | | | | | | | | | | | | | | | | | | | Go back to intercepting kernel32!RaiseException, and only go for ntdll!RtlRaiseException if that fails. Fixes throw_and_catch.cc test. Work around an issue in LLVM's win64 epilogues. We end up with an epilogue that looks like this, and it drives the Win64 unwinder crazy until stack overflow: call ill_cc!__asan_handle_no_return xor eax,eax add rsp,40h // epilogue starts pop rbp // CSR ud2 // Trap here ret // Ret? nop word ptr [rax+rax] sub rsp,28h // Next function Will file a PR soon. llvm-svn: 277874
* Avoid re-entrancy between __sanitizer::Report, OutputDebugString, and ↵Reid Kleckner2016-08-041-2/+5
| | | | | | | | | | | | | RtlRaiseException Our Report implementation calls OutputDebugString, which calls RtlRaiseException, which can re-enter back into the ASan runtime and cause a hang. Don't treat this special debugger-only exception code as a noreturn event, since the stack won't really unwind all the way. llvm-svn: 277763
* [ASan] Report illegal instruction exceptions in ASanReid Kleckner2016-08-031-5/+33
| | | | | | | | | | | | | | | | | | | Summary: Respect the handle_sigill common flag and handle_segv flags while we're at it. We still handle signals/exceptions differently on Unix and Windows. The installation process is tricky on Windows, and difficult to push down into sanitizer_common without concerning it with the different static/dynamic CRT models on Windows. Reviewers: kcc, etienneb Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23098 llvm-svn: 277621
* [asan] Intercept RtlRaiseException instead of kernel32!RaiseExceptionReid Kleckner2016-08-021-4/+7
| | | | | | | | | | | | | | | | | | | | Summary: On my install of Windows 10, RaiseException is a tail call to kernelbase!RaiseException. Obviously, we fail to intercept that. Instead, try hooking at the ntdll!RtlRaiseException layer. It is unlikely that this layer will contain control flow. Intercepting at this level requires adding a decoding for 'LEA ESP, [ESP + 0xXXXXXXXX]', which is a really obscure way to write 'SUB ESP, 0xXXXXXXXX' that avoids clobbering EFLAGS. Reviewers: etienneb Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23046 llvm-svn: 277518
* [asan] Remove NtWaitForWorkViaWorkerFactory interceptorReid Kleckner2016-08-021-37/+0
| | | | | | | | | | | | | | | | Summary: On Windows 10, this gets called after TLS has been torn down from NTDLL, and we crash attempting to return fake_tsd. This interceptor isn't needed after r242948 anyway, so let's remove it. The ASan runtime can now tolerate unregistered threads calling __asan_handle_no_return. Reviewers: vitalybuka, etienneb Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D23044 llvm-svn: 277478
* [compiler-rt] Fix various typos in asan dll [NFC]Etienne Bergeron2016-08-011-3/+3
| | | | llvm-svn: 277345
* Disable thread safe statics in clang-cl, they call the CRTReid Kleckner2016-07-211-1/+1
| | | | | | Also remove the needless static that was using them. llvm-svn: 276327
* Fix clang-cl warning and crash in sanitizersReid Kleckner2016-07-211-1/+0
| | | | | | | | | | Make kStderrFd a macro to avoid dynamic initialization of the report_file global. This actually causes a crash at runtime, because ASan initializes before static initializers run. Remove an unused variable in asan_win.cc. llvm-svn: 276314
OpenPOWER on IntegriCloud