summaryrefslogtreecommitdiff
path: root/lib/asan/asan_win_dll_thunk.cc
AgeCommit message (Collapse)Author
2017-06-29Fix WinASan after moving wcslen interceptor to sanitizer_commonReid Kleckner
Do this by removing SANITIZER_INTERCEPT_WCSLEN and intercept wcslen everywhere. Before this change, we were already intercepting wcslen on Windows, but the interceptor was in asan, not sanitizer_common. After this change, we stopped intercepting wcslen on Windows, which broke asan_dll_thunk.c, which attempts to thunk to __asan_wcslen in the ASan runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306706 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23Add strtok interceptor for ASAN for Windows.Alex Shlyapnikov
Summary: Fixes test broken by D30384 Reviewers: eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D31312 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298658 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15[compiler-rt][asan|win] Fix ASAN exception handler missing importEtienne Bergeron
Summary: This patch is adding a missing ASAN API redirection from an instrumented DLL. The bug was introduced here: https://reviews.llvm.org/D29463 This is causing this chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=692580 Reviewers: rnk Reviewed By: rnk Subscribers: kubamracek, dberris, llvm-commits, chrisha, thakis Differential Revision: https://reviews.llvm.org/D30001 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295232 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02[sanitizer] Intercept weak functions in dll_thunks.Marcos Pividori
In this diff, I update current implementation of the interception in dll_thunks to consider the special case of weak functions. First we check if the client has redefined the function in the main executable (for example: __sanitizer_cov_trace_pc_guard). It we can't find it, then we look for the default implementation (__sanitizer_cov_trace_pc_guard__dll). The default implementation is always available because the static runtime is linked to the main executable. Differential Revision: https://reviews.llvm.org/D29155 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293952 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02[sanitizer] Split dll_thunks into different sanitizers.Marcos Pividori
When the sanitizer is implemented as a static library and is included in the main executable, we need an auxiliary static library dll_thunk that will be linked to the dlls that have instrumentation, so they can refer to the runtime in the main executable. Basically, it uses interception to get a pointer the function in the main executable and override its function with that pointer. Before this diff, all of the implementation for dll_thunks was included in asan. In this diff I split it into different sanitizers, so we can use other sanitizers regardless of whether we include asan or not. All the sanitizers include a file sanitizer_win_dll_thunk.cc that register functions to be intercepted in the binary section: DLLTH When the dll including dll_thunk is initialized, it will execute __dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc, which will consider all the CB registered in the section DLLTH. So, all the functions registered will be intercepted, and redirected to the implementation in the main executable. All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan, ubsan and sanitizer coverage in the address sanitizer library. Differential Revision: https://reviews.llvm.org/D29154 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293951 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31[sanitizer] Define as weak, functions that are declared as weak.Marcos Pividori
Differential Revision: https://reviews.llvm.org/D29228 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293681 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-29General definition for weak functionsMarcos Pividori
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293419 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20[sanitizer] [asan] Use macros to simplify weak aliases on Windows.Marcos Pividori
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292650 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-13Add DLL thunks for new sancov APIs to fix Windows testsReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289587 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05[sanitizers] __sanitizer_get_module_and_offset_for_pc interface functionMike Aizatsky
Summary: The function computes full module name and coverts pc into offset. Reviewers: kcc Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D26820 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@288711 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-17[asan] Create a .ASAN$G(A-Z) section for global registrationReid Kleckner
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287246 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-15Allow users to call ASan's deadly exception report mechanismReid Kleckner
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287040 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-15[asan] Reduce prototype duplication with decltypeReid Kleckner
NFC git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287000 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-09Pacify lint checkJonas Hahnfeld
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@286346 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-08[asan/win] Add init hooks to .CRT$XLABReid Kleckner
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@286290 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12Follow up to r283955: add _recalloc_base dll thunkReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@284059 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-04[sanitizer-coverage] remove stale code, second attempt after failed r282994Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@283185 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-30[compiler-rt] Add support for the dynamic shadow allocationEtienne Bergeron
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282882 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-21revert 282085, 281909, they broke 32-bit dynamic ASan and the ↵Nico Weber
sanitizer-windows bot git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282096 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19[compiler-rt] Add support for the dynamic shadow allocationEtienne Bergeron
Summary: This patch is adding the needed code to compiler-rt to support dynamic shadow. This is to support this patch: https://reviews.llvm.org/D23354 It's adding support for using a shadow placed at a dynamic address determined at runtime. The dynamic shadow is required to work on windows 64-bits. Reviewers: rnk, kcc, vitalybuka Subscribers: kubabrecka, dberris, llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23363 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281909 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19[sanitizer] rename __sanitizer_symbolize_data to ↵Kostya Serebryany
__sanitizer_symbolize_global (to avoid conflict with another definition) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281902 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19[sanitizer] add __sanitizer_symbolize_data (can only print the names of the ↵Kostya Serebryany
globals for now) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281886 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-16Remove undefined weak hooks from dll thunk export list to really fix windows ↵Reid Kleckner
build git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15[asan] provide dummy implementations for __sanitizer_cov_trace_pc_*Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281677 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15[sanitizer] Fixup: Do not introduce __sanitizer namespace globallyAnna Zaks
Use the namespace in asan_win_dll_thunk.cc to fix the Windows bot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281659 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15Really fix the Windows sanitizer buildReid Kleckner
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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281619 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-14[asan] fix windowsKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281548 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-01Fix dll_host.cc test after adding div and gep trace coverage pointsReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@280387 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29[asan] Remove runtime flag detect_stack_use_after_scopeVitaly Buka
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279981 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-25[asan] fix windows botKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279781 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18[asan] trying to fix the windows botKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279030 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18[asan] Add __asan_set_shadow_*Vitaly Buka
Summary: We are poisoning small allocas using store instruction from instrumented code. For larger allocas we'd like to insert function calls instead of multiple stores. PR27453 Reviewers: kcc, eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23616 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279019 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-05[sanitizers] trace buffer API to use user-allocated buffer.Mike Aizatsky
Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D23186 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277858 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01[compiler-rt] Fix various typos in asan dll [NFC]Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277345 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-19Add detect_stack_use_after_scope runtime flagVitaly Buka
Summary: This flag could be used to disable check in runtime. Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D22495 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276004 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15[compiler-rt] Fix 64-bits exception handlers in ASAN 64-bits runtimeEtienne Bergeron
Summary: This is adding the appropriate suport for exception handling for 64-bits ASAN on windows. Reviewers: rnk Subscribers: kubabrecka, llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22395 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275585 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14[asan] Avoid hooking memchr() on Windows64Etienne Bergeron
There is not enough padding in front of memchr(), and, the first 6 bytes contains a branch instruction. Basically the current interception will not work on memchr(). It was disabled before, but was missing the part to disable it for INTERCEPT_LIBRARY_FUNCTION. Patch by Wei Wang Differential Revision: https://reviews.llvm.org/D22371 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275494 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21Fix asan_win_dll_thunk.cc testDmitry Vyukov
Add the two public functions I added in my last commit in asan_win_dll_thunk.cc Author: blastrock (Philippe Daouadi) Reviewed in http://reviews.llvm.org/D21557 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273288 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16[sanitizers] introduce yet another API function: ↵Kostya Serebryany
__sanitizer_install_malloc_and_free_hooks git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272943 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-30Update asan_win_dll_thunk.cc to fix the windows buildbot.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271203 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-22[asan] Intercept strdup on WindowsReid Kleckner
Some unit tests were failing because we didn't intercept strdup. It turns out it works just fine on 2013 and 2015 with a small patch to the interception logic. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264013 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21[asan] Add new _*_base interceptors for VS 2015Reid Kleckner
There are some places in the CRT (such as mbctype) that directly call _malloc_base. If you are incrementally linking a binary with ASan from before this change, this change appears to result in a linker error. Retrying the link succeeds for some reason. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264005 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-21[asan] Add strrchr to asan_win_dll_thunk.Evgeniy Stepanov
"dll_host.cc" test says there is a mismatch. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263998 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-05[sancov] adding internal functionMike Aizatsky
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256806 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-04[ASan] Fix the links to bugs and wikipages.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254735 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11[Windows] Add exports for dll_host test broken by r252071 and r251071Reid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252784 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06[ASan] Add two new functions to DLL thunk.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252359 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18[windows] Implement GetProcAddress internally to avoid initializing the CRTReid Kleckner
ASan uses GetProcAddress to get the address of malloc so it can patch it. Newer versions of Windows make GetProcAddress initialize the DLL before returning a function pointer into it. That's perfectly reasonable, but ASan needs to finish patching malloc before CRT initialization. So now we roll our own GetProcAddress. Fixes PR24237 Based on a patch by David Major Originally written by David Major as part of: https://hg.mozilla.org/mozilla-central/file/tip/toolkit/xre/WindowsCrtPatch.h git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245377 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-31[libFuzzer] prepare for __sanitizer_cov_trace_switch in libFuzzer and ↵Kostya Serebryany
sanitizer coverage. Also fix pedantic warnings git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243721 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-23[asan] Trying to make peace with the Windows bots, take 2Kuba Brecka
There are some test failures after r243003 and r243004 ("Rename the ABI versioning symbol to '__asan_version_mismatch_check' instead abusing '__asan_init'"). See http://reviews.llvm.org/D11004 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243007 91177308-0d34-0410-b5e6-96231b3b80d8