summaryrefslogtreecommitdiff
path: root/lib/interception
AgeCommit message (Collapse)Author
2017-12-06[Sanitizers] Use SANITIZER_* macros in lib/interceptionKamil Rytarowski
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
2017-11-10sanitizer_common: Try looking up symbols with RTLD_DEFAULT if RTLD_NEXT does ↵Peter Collingbourne
not work. If the lookup using RTLD_NEXT failed, the sanitizer runtime library is later in the library search order than the DSO that we are trying to intercept, which means that we cannot intercept this function. We still want the address of the real definition, though, so look it up using RTLD_DEFAULT. Differential Revision: https://reviews.llvm.org/D39779 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317930 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30[asan] Intercept heap routines in VS2010 CRTReid Kleckner
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
2017-10-24[asan] Add more x86 prologue decodings to handle x64 VC 2017 CRTReid Kleckner
Fixes atoi and strtol interception. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316482 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-12[cmake] [interception] Remove duplicate gtest from test COMPILE_DEPSMichal Gorny
Fix the gtest dependency to be included in DEPS only, rather than in COMPILE_DEPS + DEPS. The former variable is apparently used to provide unconditional dependencies, while the latter are only used for non-standalone builds. Since they are concatenated, specifying gtest in both is redundant. Furthermore, including it in COMPILE_DEPS causes build failure for standalone builds where 'gtest' target is not present. Differential Revision: https://reviews.llvm.org/D38839 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315605 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-13[Fuchsia] Magenta -> ZirconPetr Hosek
Fuchsia's lowest API layer has been renamed from Magenta to Zircon. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D37770 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313106 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-15[sanitizers CMake] NFC Refactor the logic for compiling and generating testsGeorge Karpenkov
into a function. Most CMake configuration under compiler-rt/lib/*/tests have almost-the-same-but-not-quite functions of the form add_X_[unit]tests for compiling and running the tests. Much of the logic is duplicated with minor variations across different sub-folders. This can harm productivity for multiple reasons: For newcomers, resulting CMake files are very large, hard to understand, and hide the intention of the code. Changes for enabling certain architectures end up being unnecessarily large, as they get duplicated across multiple folders. Adding new sub-projects requires more effort than it should, as a developer has to again copy-n-paste the configuration, and it's not even clear from which sub-project it should be copy-n-pasted. With this change the logic of compile-and-generate-a-set-of-tests is extracted into a function, which hopefully makes writing and reading CMake much easier. Differential Revision: https://reviews.llvm.org/D36116 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310971 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-08[winasan] Fix hotpatching ntdll!strcpy for Win10 creators editionReid Kleckner
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
2017-08-08Reuse interception_linux for NetBSDKamil Rytarowski
Summary: Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, filcab Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36321 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310351 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-04Add NetBSD support in interception.hKamil Rytarowski
Summary: Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, filcab, vitalybuka Reviewed By: vitalybuka Subscribers: llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36323 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310140 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-01[sanitizer_common] Fuchsia support for interceptorsVitaly Buka
Summary: Actually Fuchsia non-support for interceptors. Fuchsia doesn't use interceptors in the common sense at all. Almost all system library functions don't need interception at all, because the system libraries are just themselves compiled with sanitizers enabled and have specific hook interfaces where needed to inform the sanitizer runtime about thread lifetimes and the like. For the few functions that do get intercepted, they don't use a generic mechanism like dlsym with RTLD_NEXT to find the underlying system library function. Instead, they use specific extra symbol names published by the system library (e.g. __unsanitized_memcpy). Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc, filcab Reviewed By: filcab Subscribers: kubamracek, phosek, filcab, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36028 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309745 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-28[sanitizers] Sanitizer tests CMake clean up: try #2George Karpenkov
This patch addresses two issues: Most of the time, hacks with `if/else` in order to get support for multi-configuration builds are superfluous. The variable `CMAKE_CFG_INTDIR` was created precisely for this purpose: it expands to `.` on all single-configuration builds, and to a configuration name otherwise. The `if/else` hacks for the library name generation should also not be done, as CMake has `TARGET_FILE` generator expression precisely for this purpose, as it expands to the exact filename of the resulting target. Differential Revision: https://reviews.llvm.org/D35952 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309341 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27Revert "[sanitizers] Sanitizer tests CMake clean up"George Karpenkov
This reverts commit 0ab44db2aa1cd3710355ad79b04f954ce68c0b3a. Fails on some bots, reverting until I can fix it. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309318 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27[sanitizers] Sanitizer tests CMake clean upGeorge Karpenkov
This patch addresses two issues: Most of the time, hacks with `if/else` in order to get support for multi-configuration builds are superfluous. The variable `CMAKE_CFG_INTDIR` was created precisely for this purpose: it expands to `.` on all single-configuration builds, and to a configuration name otherwise. The `if/else` hacks for the library name generation should also not be done, as CMake has `TARGET_FILE` generator expression precisely for this purpose, as it expands to the exact filename of the resulting target. Differential Revision: https://reviews.llvm.org/D35952 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309306 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16[WinASan] Fix hotpatching new Win 10 build 1703 x64 strnlen prologueReid Kleckner
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
2017-01-30[interception] Check for export table's size before referring to its elements.Marcos Pividori
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
2017-01-22Revert "[interception] Check for export table's size before referring to its ↵Marcos Pividori
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
2017-01-22[interception] Check for export table's size before referring to its elements.Marcos Pividori
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
2016-11-15[asan] Don't assert that a target is within 2GB on 32-bit WindowsReid Kleckner
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
2016-09-30[compiler-rt] Fix interception of crt atoll on win10 CRT.Etienne Bergeron
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
2016-09-28[compiler-rt] Fix interception of multiple defined symbols.Etienne Bergeron
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
2016-09-15[compiler-rt] Do not introduce __sanitizer namespace globallyAnna Zaks
The definitions in sanitizer_common may conflict with definitions from system headers because: The runtime includes the system headers after the project headers (as per LLVM coding guidelines). lib/sanitizer_common/sanitizer_internal_defs.h pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with: using namespace __sanitizer; // NOLINT This patch solves the problem by introducing the namespace only within the sanitizer namespaces as proposed by Dmitry. Differential Revision: https://reviews.llvm.org/D21947 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281657 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-14[interception] Avoid duplicate declaration of isdigit in testJonas Hahnfeld
Differential Revision: https://reviews.llvm.org/D24504 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281486 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-03[compilter-rt] Try to fix correctly rL277560Etienne Bergeron
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
2016-08-03[compiler-rt] Fix broken interception unittestEtienne Bergeron
Summary: This patch is fixing a broken unittest which make the win64 bot failing. The bug was introduce here: https://reviews.llvm.org/D23046 The interception code is not the same in 32-bit and in 64-bit. The added unittest can only be patched on 32-bits. Reviewers: rnk Subscribers: llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23099 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@277560 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02[compiler-rt] Add more interception patterns.Etienne Bergeron
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
2016-08-02[asan] Intercept RtlRaiseException instead of kernel32!RaiseExceptionReid Kleckner
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
2016-07-31[compiler-rt] Add support for interception redirect exports.Etienne Bergeron
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
2016-07-28Fix broken build botEtienne Bergeron
The address resolution is ussing RTLD_NEXT and not RTLD_DEFAULT. Which means &func may not be equivalent to dlsym("func"). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276951 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-27[compiler-rt] Fix warnings in interception codeEtienne Bergeron
Summary: This patch is re-introducing the code to fix the dynamic hooking on windows and to fix a compiler warning on Apple. Related patches: * https://reviews.llvm.org/D22641 * https://reviews.llvm.org/D22610 * https://reviews.llvm.org/rL276311 * https://reviews.llvm.org/rL276490 Both architecture are using different techniques to hook on library functions (memchr, strcpy,...). On Apple, the function is not dynamically hooked and the symbol always points to a valid function (i.e. can't be null). The REAL macro returns the symbol. On windows, the function is dynamically patch and the REAL(...) function may or may not be null. It depend on whether or not the function was hooked correctly. Also, on windows memcpy and memmove are the same. ``` #if !defined(__APPLE__) [...] # define REAL(x) __interception::PTR_TO_REAL(x) # define ASSIGN_REAL(dst, src) REAL(dst) = REAL(src) [...] #else // __APPLE__ [...] # define REAL(x) x # define ASSIGN_REAL(x, y) [...] #endif // __APPLE__ Reviewers: rnk Subscribers: kcc, hans, kubabrecka, llvm-commits, bruno, chrisha Differential Revision: https://reviews.llvm.org/D22758 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276885 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22Revert "fix https://reviews.llvm.org/D22610" and "[compiler-rt] Fix ↵Bruno Cardoso Lopes
memmove/memcpy overlap detection on windows" This currently fails ~500 tests on Darwin: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/20456/ This reverts commit 4cfee0dff1facb8fa2827d25c5943bfef96d1a8f and dbd91205d578cb61ab77be06087e9f65ba8a7ec8. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276490 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21[compiler-rt] Add support for relative offset adjustment in interceptionEtienne Bergeron
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
2016-07-21fix https://reviews.llvm.org/D22610Etienne Bergeron
AppleClang can't compile the assignment expression. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276311 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18[interception] Remove extra whitespace to appease linters (NFC)Vedant Kumar
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
2016-07-18[compiler-rt] Fix incorrect handling of indirect load.Etienne Bergeron
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
2016-07-18[compiler-rt] Allow trampoline allocation further and 1 gig.Etienne Bergeron
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
2016-07-15[compiler-rt] Fix incorrect handling of indirect load.Etienne Bergeron
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
2016-07-15TestCase null_deref was failing in Win64:Etienne Bergeron
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
2016-07-14[compiler-rt] Add more assembly patterns for interceptionEtienne Bergeron
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
2016-07-12[asan] Fix interception unittest on Windows64.Etienne Bergeron
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
2016-07-12[compiler-rt] Enhance function padding detection for function interceptionEtienne Bergeron
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
2016-07-12fix incorrect constant (from http://reviews.llvm.org/D22111)Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275136 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11missing modifications for http://reviews.llvm.org/D21952Etienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275124 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11[compiler-rt] Refactor the interception code on windows.Etienne Bergeron
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
2016-07-11remove empty linesEtienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275112 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07[compiler-rt] Enhance unittest coverage for lib interceptionEtienne Bergeron
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
2016-07-06Fix cmake generation on Apple for interception unittestsEtienne Bergeron
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274671 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06[compiler-rt] Disable interception tests on AppleEtienne Bergeron
Summary: The CMake generation is not working on Apple. This patch is disabling the generation until it's fixed. Reviewers: rnk Subscribers: tberghammer, chrisha, danalbert, llvm-commits, srhines Differential Revision: http://reviews.llvm.org/D22066 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274667 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06[compilter-rt] Add unittests for interception libraryEtienne Bergeron
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
2016-06-20Add missing decoding patterns toRoundUpToInstrBoundaryEtienne Bergeron
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