summaryrefslogtreecommitdiff
path: root/lib/interception
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* missing modifications for http://reviews.llvm.org/D21952Etienne Bergeron2016-07-111-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275124 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Refactor the interception code on windows.Etienne Bergeron2016-07-113-340/+1079
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* remove empty linesEtienne Bergeron2016-07-111-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275112 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Enhance unittest coverage for lib interceptionEtienne Bergeron2016-07-072-24/+127
| | | | | | | | | | | | | | 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
* Fix cmake generation on Apple for interception unittestsEtienne Bergeron2016-07-061-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274671 91177308-0d34-0410-b5e6-96231b3b80d8
* [compiler-rt] Disable interception tests on AppleEtienne Bergeron2016-07-061-3/+1
| | | | | | | | | | | | | | | 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
* [compilter-rt] Add unittests for interception libraryEtienne Bergeron2016-07-066-1/+382
| | | | | | | | | | | | | | 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-242-8/+86
| | | | | | | | | | | | | | | | | | | | | | 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
* [cmake] Address Samsonov's post-commit review of r262723Filipe Cabecinhas2016-03-051-1/+1
| | | | | | | | | | Reviewers: samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17896 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262770 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove autoconf support for building runtime libraries.Chris Bieneman2016-01-261-23/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I am the punishment of God... If [autoconf] had not committed great sins, God would not have sent a punishment like me upon [it]." -Genghis Khan Reviewers: chandlerc, grosbach, bob.wilson, zaks.anna, kubabrecka, samsonov, echristo Subscribers: iains, llvm-commits Differential Revision: http://reviews.llvm.org/D16473 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@258863 91177308-0d34-0410-b5e6-96231b3b80d8
* Tell clang-format that (most) sanitizers are written using Google style guide.Alexey Samsonov2015-11-191-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253608 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
* [asan] Versioned interceptor for pthread_create.Evgeniy Stepanov2015-09-221-5/+5
| | | | | | | | | This fixes a crash in pthread_create on linux/i386 due to abi incompatibility between intercepted and non-intercepted functions. See the test case for more details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248325 91177308-0d34-0410-b5e6-96231b3b80d8
* [windows] Implement GetProcAddress internally to avoid initializing the CRTReid Kleckner2015-08-182-4/+59
| | | | | | | | | | | | | | | | | 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
* CMake: Stop using LLVM's custom parse_arguments. NFCFilipe Cabecinhas2015-06-191-1/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Use CMake's cmake_parse_arguments() instead. It's called in a slightly different way, but supports all our use cases. It's in CMake 2.8.8, which is our minimum supported version. CMake 3.0 doc (roughly the same. No direct link to 2.8.8 doc): http://www.cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html?highlight=cmake_parse_arguments Since I was already changing these calls, I changed ARCH and LIB into ARCHS and LIBS to make it more clear that they're lists of arguments. Reviewers: eugenis, samsonov, beanz Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10529 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@240120 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] Cleanup add_compiler_rt_object_library to be platform-agnosticChris Bieneman2015-06-101-15/+5
| | | | | | | | | | | | | | | | | Summary: This change takes darwin-specific goop that was scattered around CMakeLists files and spread between add_compiler_rt_object_library and add_compiler_rt_darwin_object_library and moves it all under add_compiler_rt_object_library. The goal of this is to try to push platform handling as low in the utility functions as possible. Reviewers: rnk, samsonov Reviewed By: rnk, samsonov Subscribers: rnk, rsmith, llvm-commits Differential Revision: http://reviews.llvm.org/D10250 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@239498 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
* [ASan] NFC: Factor out platform-specific interceptorsTimur Iskhodzhanov2015-03-161-1/+0
| | | | | | | | Reviewed at http://reviews.llvm.org/D8321 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@232377 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Remove support for building sanitizers from Makefile/autoconf build."Matthias Braun2015-02-171-0/+23
| | | | | | | | | This reverts commit r229556. Reverting this for now as internal apple builds rely on this functionality. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229585 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove support for building sanitizers from Makefile/autoconf build.Alexey Samsonov2015-02-171-23/+0
| | | | | | | | They autotools build has a number of missing features, supports less OS, architectures, build configurations, doesn't have any tests and is hard to support in sync with CMake build. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@229556 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Android build cleanup.Evgeniy Stepanov2014-09-291-4/+0
| | | | | | | | | | | | | * Detect Android toolchain target arch and set correct runtime library name. * Merged a lot of Android and non-Android code paths. * Android is only supported in standalone build of compiler-rt now. * Linking lsan-common in ASan-Android (makes lsan annotations work). * Relying on -fsanitize=address linker flag when building tests (again, unification with non-Android path). * Runtime library moved from lib/asan to lib/linux. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@218605 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-252-11/+44
| | | | 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-222-9/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216265 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan/Win] Remove one more reference to ↵Timur Iskhodzhanov2014-08-151-3/+1
| | | | | | __interception::GetRealFunctionAddress (follow-up to r215707) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215722 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan/Win] Remove old, unused and non-functional code that will be ↵Timur Iskhodzhanov2014-08-152-16/+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
* Make sanitizers' interceptors non-weak on FreeBSDViktor Kutuzov2014-07-101-0/+10
| | | | | | | Differential Revision: http://reviews.llvm.org/D4418 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212693 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sanitizer/interception Win] Break into the debugger on unknown instructionsTimur Iskhodzhanov2014-06-021-1/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210028 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan Win] Fix memset interception in DLLsTimur Iskhodzhanov2014-06-021-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210027 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan/Win] Use the new function interception approach to handle function ↵Timur Iskhodzhanov2014-05-221-3/+3
| | | | | | | | wrappers too; wrap strlen() in DLLs Reviewed at http://reviews.llvm.org/D3871 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209427 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan/Win] Refactor __interception::OverrideFunction a bit, allow the ↵Timur Iskhodzhanov2014-05-161-49/+72
| | | | | | | | orig_old_func parameter to be zero Reviewed at http://reviews.llvm.org/D3798 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208989 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Interception macros for sanitizers on FreeBSD; patch by Viktor ↵Kostya Serebryany2014-02-243-13/+14
| | | | | | Kutuzov git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202009 91177308-0d34-0410-b5e6-96231b3b80d8
* [CMake] Simplify setting compile flag disabling RTTIAlexey Samsonov2014-02-181-9/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201547 91177308-0d34-0410-b5e6-96231b3b80d8
* Move /FS to SANITIZER_COMMON_CFLAGSTimur Iskhodzhanov2014-01-301-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200485 91177308-0d34-0410-b5e6-96231b3b80d8
* Quick-fix a typoTimur Iskhodzhanov2014-01-301-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200483 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an /FS flag to the lib/interception CMake to make it buildable with ↵Timur Iskhodzhanov2014-01-301-1/+9
| | | | | | VS2013 too git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200482 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for more instruction prefixes so we can intercept functions in ↵Timur Iskhodzhanov2014-01-291-0/+22
| | | | | | the VS2013 RTL git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200366 91177308-0d34-0410-b5e6-96231b3b80d8
* [msan] Wrap indirect calls to REAL(x) in interceptors.Evgeniy Stepanov2013-12-201-5/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197806 91177308-0d34-0410-b5e6-96231b3b80d8
* PR16532: work around old GCC bug in interception_type_test.ccAlexey Samsonov2013-12-051-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196506 91177308-0d34-0410-b5e6-96231b3b80d8
* [sanitizer] Avoid needless use of stringification (#symver) in ↵Evgeniy Stepanov2013-11-121-1/+1
| | | | | | | | | INTERCEPT_FUNCTION_VER. This is a workaround for clang-format bug (PR17874). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194468 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASan] Add CMake configs for libclang_rt.asan_iossim_dynamic.dylib Alexander Potapenko2013-11-071-4/+6
| | | | | | | | | | | CMake changes to build the ASan runtime for the iOS simulator. This is a universal library targeting the same architectures as the OSX ASan runtime does, thus the iossim version can't live in the same universal libclang_rt.asan_osx_dynamic.dylib The difference between the OSX and iossim builds is in the -mios-simulator-version-min and -ios_simulator_version_min flags that tell Clang to compile and link iossim code. The iossim runtime can only be built on a machine with both Xcode and the iOS Simulator SDK installed. If xcodebuild -version -sdk iphonesimulator Path returns a nonempty path, it is used when compiling and linking the iossim runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194199 91177308-0d34-0410-b5e6-96231b3b80d8