summaryrefslogtreecommitdiff
path: root/lib/interception/interception_win.cc
Commit message (Collapse)AuthorAgeFilesLines
* compiler-rt: Rename .cc files in lib/interception to .cpp.Nico Weber2019-07-311-1022/+0
| | | | | | | | | | | | See https://reviews.llvm.org/D58620 for discussion, and for the commands I ran. In addition I also ran for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done and manually updated references to renamed files found by that. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367456 91177308-0d34-0410-b5e6-96231b3b80d8
* [winasan] Fix strrchr interception with vs2019 CRTReid Kleckner2019-04-041-0/+2
| | | | | | | | | | | | | | strrchr in vs2019 CRT begins with unrecognized instructions. VCRUNTIME140!strrchr: 4533c9 xor r9d, r9d 4c8bc1 mov r8, rcx Patch by Christopher Reid! Differential Revision: https://reviews.llvm.org/D60217 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@357725 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler rt] Win64 GetInstructionSize additional register MOV + stack ↵Reid Kleckner2019-02-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | alignment AND Current interception code does not cover all of the required registers on Windows for a specific flavor of MOV, so this patch adds cases to identify the following 5-byte instructions on 64-bit Windows: mov QWORD PTR [rsp + XX], rdx <- second integer argument mov QWORD PTR [rsp + XX], r9 <- third integer argument mov QWORD PTR [rsp + XX], r8 <- fourth integer argument The instruction for MOV [...] RCX is already covered in the previous version. Patch by Matthew McGovern! Reviewers: rnk Differential Revision: https://reviews.llvm.org/D57339 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@353483 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* [winasan] Reduce hotpatch prefix check to 8 bytesDavid Major2018-09-201-4/+4
| | | | | | | | | | Same idea as r310419: The 8 byte nop is a suffix of the 9 byte nop, and we need at most 6 bytes. Differential Revision: https://reviews.llvm.org/D51788 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@342649 91177308-0d34-0410-b5e6-96231b3b80d8
* [winasan] Update GetInstructionSize for Win10 1803David Major2018-05-111-0/+1
| | | | | | | | | | | | In Windows version 1803, the first instruction of ntdll!strchr is: 8a01 mov al,byte ptr [rcx] This is the only needed change for this version as far as I can tell. Differential Revision: https://reviews.llvm.org/D46458 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@332095 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sanitizers] Use SANITIZER_* macros in lib/interceptionKamil Rytarowski2017-12-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Unlike the rest of the sanitizer code, lib/interception uses native macros like __linux__ to check for specific targets instead of the common ones like SANITIZER_LINUX. When working on the Solaris port of the sanitizers, the current style was found to not only be inconsistent, but clumsy to use because the canonical way to check for Solaris is to check for __sun__ && __svr4__ which is a mouthful. Therefore, this patch switches to use SANITIZER_* macros instead. Tested on x86_64-pc-linux-gnu. Reviewers: kcc, vitalybuka Reviewed By: vitalybuka Subscribers: #sanitizers, srhines, krytarowski, llvm-commits, fedor.sergeev Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39798 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319906 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Intercept heap routines in VS2010 CRTReid Kleckner2017-10-301-0/+1
| | | | | | | Users have requested that we add it to the list: https://github.com/google/sanitizers/issues/864 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316929 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Add more x86 prologue decodings to handle x64 VC 2017 CRTReid Kleckner2017-10-241-0/+3
| | | | | | Fixes atoi and strtol interception. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316482 91177308-0d34-0410-b5e6-96231b3b80d8
* [winasan] Fix hotpatching ntdll!strcpy for Win10 creators editionReid Kleckner2017-08-081-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The 9 byte nop is a suffix of the 10 byte nop, and we need at most 6 bytes. ntdll's version of strcpy is written in assembly and is very clever. strcat tail calls strcpy but with a slightly different arrangement of argument registers at an alternate entry point. It looks like this: ntdll!strcpy: 00007ffd`64e8a7a0 4c8bd9 mov r11,rcx ntdll!__entry_from_strcat_in_strcpy: 00007ffd`64e8a7a3 482bca sub rcx,rdx 00007ffd`64e8a7a6 f6c207 test dl,7 If we overwrite more than two bytes in our interceptor, that label will no longer be a valid instruction boundary. By recognizing the 9 byte nop, we use the two byte backwards branch to start our trampoline, avoiding this issue. Fixes https://github.com/google/sanitizers/issues/829 Patch by David Major git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310419 91177308-0d34-0410-b5e6-96231b3b80d8
* [WinASan] Fix hotpatching new Win 10 build 1703 x64 strnlen prologueReid Kleckner2017-06-161-1/+6
| | | | | | | | | | | The first instruction of the new ucrtbase!strnlen implementation loads a global, presumably to dispatch between SSE and non-SSE optimized strnlen implementations. Fixes PR32895 and probably https://github.com/google/sanitizers/issues/818 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305581 91177308-0d34-0410-b5e6-96231b3b80d8
* [interception] Check for export table's size before referring to its elements.Marcos Pividori2017-01-301-0/+2
| | | | | | | | | | | | This fix a bug, when calling InternalGetProcAddress() for an executable that doesn't export any symbol. So the table is empty. If we don't check for this condition, the program fails with Error 0xc0000142. Also, I add a regression test for Windows. Differential Revision: https://reviews.llvm.org/D28502 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293521 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[interception] Check for export table's size before referring to its ↵Marcos Pividori2017-01-221-2/+0
| | | | | | | | elements." This reverts commit r292747 because cmake fails for some archs. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292751 91177308-0d34-0410-b5e6-96231b3b80d8
* [interception] Check for export table's size before referring to its elements.Marcos Pividori2017-01-221-0/+2
| | | | | | | | | | | | This fix a bug, when calling InternalGetProcAddress() for an executable that doesn't export any symbol. So the table is empty. If we don't check for this condition, the program fails with Error 0xc0000142. Also, I add a regression test for Windows. Differential Revision: https://reviews.llvm.org/D28502 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292747 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Don't assert that a target is within 2GB on 32-bit WindowsReid Kleckner2016-11-151-0/+6
| | | | | | | | | | | | | | | | Summary: In a 32-bit address space, PC-relative jump targets are wrapped, so a direct branch at 0x90000001 can reach address 0x10000000 with a displacement of 0x7FFFFFFFF. This can happen in applications, such as Chrome, that are linked with /LARGEADDRESSAWARE. Reviewers: etienneb Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D26650 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@286997 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Fix interception of crt atoll on win10 CRT.Etienne Bergeron2016-09-301-0/+1
| | | | | | | | | | | | | | | | Summary: The check-asan-dynamic tests were broken on win10 because the interception library was not able to hook on some functions. credits: thanks sebastian marchand to help debugging this on win10. Reviewers: rnk Subscribers: chrisha, llvm-commits, dberris Differential Revision: https://reviews.llvm.org/D25120 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282904 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Fix interception of multiple defined symbols.Etienne Bergeron2016-09-281-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MSVC compiler is generating multiple instance of the exception handler when compiling on win64 with /MD. see: https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx Two tests were failing when running: ``` ninja check-asan-dynamic. ``` The tests were failing because only the first occurence of the function was patched. The function `__C_specific_handler` is defined in `ntdll` and `vcruntime140`. After this patch, there is still two remaining tests failing. ``` ******************** Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Testing Time: 87.81s ******************** Failing Tests (2): AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memchr.cc AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memcpy_indirect.cc Expected Passes : 342 Passes With Retry : 2 Expected Failures : 16 Unsupported Tests : 152 Unexpected Failures: 2 ``` Reviewers: rnk, vitalybuka Subscribers: vitalybuka, llvm-commits, chrisha, dberris Differential Revision: https://reviews.llvm.org/D24983 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282614 91177308-0d34-0410-b5e6-96231b3b80d8
* [compilter-rt] Try to fix correctly rL277560Etienne Bergeron2016-08-031-3/+5
| | | | | | | rL277560: [compiler-rt] Fix broken interception unittest git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277567 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Add more interception patterns.Etienne Bergeron2016-08-021-1/+6
| | | | | | | | | | | | | | Summary: These instructions where not supported on my win7 computer. They were happening on strstr when building chrome unittests with asan. Reviewers: rnk Subscribers: llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23081 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277519 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Intercept RtlRaiseException instead of kernel32!RaiseExceptionReid Kleckner2016-08-021-0/+3
| | | | | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277518 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Add support for interception redirect exports.Etienne Bergeron2016-07-311-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: On windows, an export can be redirected to an other DLL. This patch is adding the required support to the internal GetProcAddress implementation. This case was encountered by instrumenting chromium (win 64-bits) using this GN configuration: ``` is_component_build = true is_debug = false enable_nacl = false is_clang = true is_asan = true clang_base_path = "d:\src\llvm\ninja64" clang_use_chrome_plugins = false clang_version = "4.0.0" ``` The operating system is win7 (x64). Visual Studio: 2015 Professional Reviewers: rnk Subscribers: llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D22880 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277294 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Add support for relative offset adjustment in interceptionEtienne Bergeron2016-07-211-9/+32
| | | | | | | | | | | | | | | | | Summary: Some instructions can only be copied if the relative offset is adjusted. This patch adds support for two common instruction. It's quite common to have a indirect load in the prologue (loading the security cookie). Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22647 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276336 91177308-0d34-0410-b5e6-96231b3b80d8
* [interception] Remove extra whitespace to appease linters (NFC)Vedant Kumar2016-07-181-2/+2
| | | | | | | | Attempt to fix: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/7774 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275901 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Fix incorrect handling of indirect load.Etienne Bergeron2016-07-181-2/+16
| | | | | | | | | | | | | | | | | | | | | | Summary: Indirect load are relative offset from RIP. The current trampoline implementation is incorrectly copying these instructions which make some unittests crashing. This patch is not fixing the unittests but it's fixing the crashes. The functions are no longer hooked. Patches will come soon to fix these unittests. Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22410 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275892 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Allow trampoline allocation further and 1 gig.Etienne Bergeron2016-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: The trampoline allocation limits the memory scanning to 1 gig. There is an unittest that is allocating a large object which make it impossible to the trampoline allocator to find a free spot. see shadow_mapping_failures: ``` char bigchunk[1 << 30]; ``` This patch is not fixing the unittest but it's fixing it's infinite loop behavior. Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22471 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275887 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Fix incorrect handling of indirect load.Etienne Bergeron2016-07-151-15/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: Indirect load are relative offset from RIP. The current trampoline implementation is incorrectly copying these instructions which make some unittests crashing. This patch is not fixing the unittests but it's fixing the crashes. The functions are no longer hooked. Patches will come soon to fix these unittests. Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22410 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275584 91177308-0d34-0410-b5e6-96231b3b80d8
* TestCase null_deref was failing in Win64:Etienne Bergeron2016-07-151-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | c:\lipo\work\asan\b_llvm>c:\lipo\work\asan\b_llvm\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output\null_deref.cc.tmp ================================================================= ==5488==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000028 (pc 0x7ff701f91067 bp 0x000c8cf8fbf0 sp 0x000c8cf8fbb0 T0) ==5488==The signal is caused by a READ memory access. ==5488==Hint: address points to the zero page. #0 0x7ff701f91066 in NullDeref(int *) C:\lipo\work\asan\llvm\projects\compiler-rt\test\asan\TestCases\null_deref.cc:15:10 #1 0x8a0388830a67 (<unknown module>) The reason was symbols was not initilized. In fact, it was first inited with a call to stack.Print(), which calls WinSymbolizerTool::SymbolizePC, then InitializeDbgHelpIfNeeded(). Since the StackWalk was performed before the stack.Print(), stack frames where not gathered correctly. There should be a better place to initialize symbols. For now, this patch makes the test happy. Patch by Wei Wang Differential Revision: https://reviews.llvm.org/D22410 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275580 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Add more assembly patterns for interceptionEtienne Bergeron2016-07-141-1/+7
| | | | | | | | | | | | | | | | Summary: These patterns are encounter when using instrumented DLL. Without this patch, asan lit test are crashing when trying to hook on RaiseException function. Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22340 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275489 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Fix interception unittest on Windows64.Etienne Bergeron2016-07-121-0/+1
| | | | | | | | | | | | | | | mov edi,edi is _not_ NOP in 64-bit, use 66,90h instead. This bug was causing interception unittest to crash on Windows64 (windows 8 and windows 10). Credits to etienneb for finding the root cause. Patch by: Wei Wang Differential Revision: http://reviews.llvm.org/D22274 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275207 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Enhance function padding detection for function interceptionEtienne Bergeron2016-07-121-1/+24
| | | | | | | | | | | | | | | | | Summary: Many CRT (64-bits) functions contains a "hint-nop". The current padding detection is not able to recognize the 10-bytes padding and the HotPatch hooking technique cannot be used. Other patterns may be discover and may be added later. Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: http://reviews.llvm.org/D22258 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275180 91177308-0d34-0410-b5e6-96231b3b80d8
* fix incorrect constant (from http://reviews.llvm.org/D22111)Etienne Bergeron2016-07-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275136 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Refactor the interception code on windows.Etienne Bergeron2016-07-111-271/+634
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is a cleanup and refactoring of the interception code on windows Enhancement: * Adding the support for 64-bits code * Adding several hooking technique: * Detour * JumpRedirect * HotPatch * Trampoline * Adding a trampoline memory pool (64-bits) and release the allocated memory in unittests Cleanup: * Adding unittests for 64-bits hooking techniques * Enhancing the RoundUpInstruction by sharing common decoder Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: http://reviews.llvm.org/D22111 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275123 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Enhance unittest coverage for lib interceptionEtienne Bergeron2016-07-071-9/+31
| | | | | | | | | | | | | | Summary: This patch is adding more unittests for testing the interception of 32-bits code. Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: http://reviews.llvm.org/D22077 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274775 91177308-0d34-0410-b5e6-96231b3b80d8
* [compilter-rt] Add unittests for interception libraryEtienne Bergeron2016-07-061-1/+2
| | | | | | | | | | | | | | Summary: This patch is adding unittests for the interception library. Reviewers: rnk Subscribers: majnemer, llvm-commits, wang0109, chrisha, tberghammer, danalbert, srhines Differential Revision: http://reviews.llvm.org/D21980 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274657 91177308-0d34-0410-b5e6-96231b3b80d8
* Add missing decoding patterns toRoundUpToInstrBoundaryEtienne Bergeron2016-06-201-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The RoundUpToInstrBoundary determines intructions boundary and it's used to determine how to patch (intercept) functions. The current x64-bit implementation is incomplete. This patch is adding patterns observed when trying to sanitize a 64-bit executable on my computer. Thw two current functions not intercepted are: ``` RaiseExceptionStub: 000000007720C3B0 EB 06 jmp RaiseException (07720C3B8h) 000000007720C3B2 90 nop 000000007720C3B3 90 nop 000000007720C3B4 90 nop 000000007720C3B5 90 nop 000000007720C3B6 90 nop 000000007720C3B7 90 nop RaiseException: 000000007720C3B8 FF 25 3A 18 09 00 jmp qword ptr [__imp_RaiseException (07729DBF8h)] 000000007720C3BE 8B 44 24 54 mov eax,dword ptr [rsp+54h] 000000007720C3C2 85 C0 test eax,eax 000000007720C3C4 0F 84 F5 05 00 00 je Wow64NtCreateKey+12Fh (07720C9BFh) ``` ``` CreateThreadStub: 0000000077215A10 48 83 EC 48 sub rsp,48h 0000000077215A14 48 8B 44 24 78 mov rax,qword ptr [rsp+78h] 0000000077215A19 48 89 44 24 38 mov qword ptr [rsp+38h],rax 0000000077215A1E 8B 44 24 70 mov eax,dword ptr [rsp+70h] ``` Reviewers: rnk Subscribers: wang0109, chrisha Differential Revision: http://reviews.llvm.org/D21519 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273176 91177308-0d34-0410-b5e6-96231b3b80d8
* This patch attempts to primitive support for Win64 asanEtienne Bergeron2016-06-061-26/+147
| | | | | | | | | | | | | | | | Some known issues are: When "head" include instructions that involve branching, the "cut and paste" approach may break down in a way that function interception still work but calling back the original function does not work. The jmp [rip -8] saves some bytes in the "head" but finding the safe zone of 0xCC is not implemented yet. So it may stomp on preceding codes. The shadow offset is not working yet on Win64. More complexity maybe involved since there are some differences regarding virtual address space between Window 8 and Windows 8.1/10. Patch by: Wang Wei Differential Revision: http://reviews.llvm.org/D20884 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271915 91177308-0d34-0410-b5e6-96231b3b80d8
* This patch is activating the build of Asan on Windows 64-bits.Etienne Bergeron2016-05-271-3/+14
| | | | | | | | | | | | | | | | | | | | It's fixing compilation errors. The runtime is not yet working. Missing features: OverrideFunction for x64 an equiv function for inline asm (atomic_compare_exchange_strong) shadow memory offset needs to be adjusted RoundUpToInstrBoundary for x64 They will be implemented by subsequent patches. Patch by Wei Wang. Differential revision: http://reviews.llvm.org/D20455 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271049 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Intercept all Heap* related imports from ucrtbase.dllReid Kleckner2016-03-241-8/+73
| | | | | | | | | | | | | | | | | | | | | | ucrtbase.dll appears to be built with some kind of cross-module inlining, because there are calls to imported Heap* routines sprinkled throughout the code. This inlining defeats our attempts to hotpatch malloc, _malloc_base, and related functions. Failing to intercept an allocation or deallocation results in a crash when the program attempts to deallocate or reallocate memory with the wrong allocator. This change patches the IAT of ucrtbase.dll to replace the addresses of the imported Heap* functions with implementations provided by ASan. We don't globally intercept the win32 Heap* functions because they are typically used by system DLLs that run before ASan initializes. Eventually, we may want to intercept them, but for now I think this is the minimal change that will keep ASan stable. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D18413 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264327 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Add ucrtbase.dll to the list of DLLs to interceptReid Kleckner2016-03-221-0/+1
| | | | | | Reduces number of test failures in check-asan-dynamic with VS 2015. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264061 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Add one more x86 encoding to the interceptor for strrchrReid Kleckner2016-03-221-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264060 91177308-0d34-0410-b5e6-96231b3b80d8
* [asan] Intercept strdup on WindowsReid Kleckner2016-03-221-1/+4
| | | | | | | | 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
* [asan] Update hotpatch code for VS 2015 memset implementationReid Kleckner2016-03-211-0/+5
| | | | | | | | | In VS 2015, the memset fill parameter is zero extended from one byte instead of being copied wholesale. The issue reproduces with existing tests if you use VS2015. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263966 91177308-0d34-0410-b5e6-96231b3b80d8
* Sanitizer: define WIN32_LEAN_AND_MEANSaleem Abdulrasool2015-10-291-0/+1
| | | | | | | | Define WIN32_LEAN_AND_MEAN before including Windows.h. This is already being done in some places. This does it more broadly. This permits building ASAN on Linux for Winndows, as well as reduces the amount of included declarations. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251649 91177308-0d34-0410-b5e6-96231b3b80d8
* [windows] Implement GetProcAddress internally to avoid initializing the CRTReid Kleckner2015-08-181-4/+55
| | | | | | | | | | | | | | | | | 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
* [ASan/Win] Fix a CHECK failure when an exception is thrown from a callback ↵Timur Iskhodzhanov2015-03-171-4/+9
| | | | | | | | passed to BindIoCompletionCallback This also simplifies how we handle QueueUserWorkItem git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232499 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for intercepting functions from msvcr110.dllEhsan Akhgari2014-09-251-1/+4
| | | | | | | | | | | | | | Summary: This finishes support for ASAN on MSVC2012. Test Plan: |ninja check-asan| passes locally with this on MSVC2012. Reviewers: timurrrr Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5494 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@218465 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan/Win] Intercept memory allocation functions in the MD CRTTimur Iskhodzhanov2014-08-251-0/+27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216382 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan/Win] Land the trivial bits of -MD RTL support (PR20214)Timur Iskhodzhanov2014-08-221-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216265 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan/Win] Remove old, unused and non-functional code that will be ↵Timur Iskhodzhanov2014-08-151-14/+0
| | | | | | re-written soon git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215707 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for intercepting thunks of the formEhsan Akhgari2014-07-141-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212979 91177308-0d34-0410-b5e6-96231b3b80d8