summaryrefslogtreecommitdiff
path: root/lib/interception
AgeCommit message (Collapse)Author
2016-03-24[asan] Intercept all Heap* related imports from ucrtbase.dllReid Kleckner
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
2016-03-22[asan] Add ucrtbase.dll to the list of DLLs to interceptReid Kleckner
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
2016-03-22[asan] Add one more x86 encoding to the interceptor for strrchrReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264060 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] Update hotpatch code for VS 2015 memset implementationReid Kleckner
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
2016-03-05[cmake] Address Samsonov's post-commit review of r262723Filipe Cabecinhas
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
2016-01-26Remove autoconf support for building runtime libraries.Chris Bieneman
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
2015-11-19Tell clang-format that (most) sanitizers are written using Google style guide.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253608 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-29Sanitizer: define WIN32_LEAN_AND_MEANSaleem Abdulrasool
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
2015-09-22[asan] Versioned interceptor for pthread_create.Evgeniy Stepanov
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
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-06-19CMake: Stop using LLVM's custom parse_arguments. NFCFilipe Cabecinhas
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
2015-06-10[CMake] Cleanup add_compiler_rt_object_library to be platform-agnosticChris Bieneman
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
2015-03-17[ASan/Win] Fix a CHECK failure when an exception is thrown from a callback ↵Timur Iskhodzhanov
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
2015-03-16[ASan] NFC: Factor out platform-specific interceptorsTimur Iskhodzhanov
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
2015-02-17Revert "Remove support for building sanitizers from Makefile/autoconf build."Matthias Braun
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
2015-02-17Remove support for building sanitizers from Makefile/autoconf build.Alexey Samsonov
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
2014-09-29[sanitizer] Android build cleanup.Evgeniy Stepanov
* 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
2014-09-25Add support for intercepting functions from msvcr110.dllEhsan Akhgari
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
2014-08-25[ASan/Win] Intercept memory allocation functions in the MD CRTTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216382 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22[ASan/Win] Land the trivial bits of -MD RTL support (PR20214)Timur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216265 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15[ASan/Win] Remove one more reference to ↵Timur Iskhodzhanov
__interception::GetRealFunctionAddress (follow-up to r215707) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215722 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15[ASan/Win] Remove old, unused and non-functional code that will be ↵Timur Iskhodzhanov
re-written soon git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215707 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14Add support for intercepting thunks of the formEhsan Akhgari
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212979 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-10Make sanitizers' interceptors non-weak on FreeBSDViktor Kutuzov
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
2014-06-02[Sanitizer/interception Win] Break into the debugger on unknown instructionsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210028 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-02[ASan Win] Fix memset interception in DLLsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210027 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-22[ASan/Win] Use the new function interception approach to handle function ↵Timur Iskhodzhanov
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
2014-05-16[ASan/Win] Refactor __interception::OverrideFunction a bit, allow the ↵Timur Iskhodzhanov
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
2014-02-24[sanitizer] Interception macros for sanitizers on FreeBSD; patch by Viktor ↵Kostya Serebryany
Kutuzov git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202009 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-18[CMake] Simplify setting compile flag disabling RTTIAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201547 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30Move /FS to SANITIZER_COMMON_CFLAGSTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200485 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30Quick-fix a typoTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200483 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30Add an /FS flag to the lib/interception CMake to make it buildable with ↵Timur Iskhodzhanov
VS2013 too git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200482 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-29Add support for more instruction prefixes so we can intercept functions in ↵Timur Iskhodzhanov
the VS2013 RTL git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200366 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-20[msan] Wrap indirect calls to REAL(x) in interceptors.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197806 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05PR16532: work around old GCC bug in interception_type_test.ccAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196506 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-12[sanitizer] Avoid needless use of stringification (#symver) in ↵Evgeniy Stepanov
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
2013-11-07[ASan] Add CMake configs for libclang_rt.asan_iossim_dynamic.dylib Alexander Potapenko
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
2013-10-16Make some pthread_mutex_* and pthread_cond_* interceptors common.Alexey Samsonov
Reviewers: eugenis, dvyukov Reviewed By: dvyukov CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1937 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192774 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-19tsan: fix linking of tsan runtime into dynamic librariesDmitry Vyukov
versioned symbols can not be linked into dynamic library w/o linker script also simplifies code as side effect git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191056 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-10[ASan] Remove the explicit function prototypes for intercepted functions on ↵Timur Iskhodzhanov
Windows git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190411 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03tsan: fix linking when -ltsan is passed before -lpthreadDmitry Vyukov
libpthread is weird: /lib/x86_64-linux-gnu/libpthread.so.0:000000000000b9b0 T pthread_cond_init@@GLIBC_2.3.2 /lib/x86_64-linux-gnu/libpthread.so.0:000000000000c720 T pthread_cond_init@GLIBC_2.2.5 let's do it with @@ for now we can always introduce more macros parameters later git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189788 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03asan: fix android buildDmitry Vyukov
android does not have dlvsym git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189781 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-02tsan: properly intercept pthread_cond functionsDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189767 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-20[libsanitizer] Introduce INTERCEPTOR_WITH_SUFFIX which is to be used for ↵Alexander Potapenko
appending the __DARWIN_ALIAS() version suffixes to function names on Darwin. This should fix asan/lit_tests/wait.cc under ASan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182259 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-27add Linux syscall wrappers and ThreadLister to sanitizer_commonKostya Serebryany
ThreadLister is a Linux-specific class for obtaining the thread IDs of a process from procfs (/proc/<pid>/task/). It will be used by leak checking code. Also add several syscall wrappers which will be required by the same code that uses ThreadLister, but are not used in ThreadLister itself. Patch by Sergey Matveev git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176179 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-21[ASan] Refactoring: nuke the redundant function declarations in ↵Alexander Potapenko
asan_intercepted_functions.h that had been used on OS X only. The INTERCEPTOR() macro on OS X is now responsible for declaring the wrapped function, the wrapper and the pair of pointers to them in __DATA,__interposition section. Thus adding an interceptor requires editing a single file now. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175740 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14[asan] fix x32 build (H.J. Lu)Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175140 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-07[sanitizer] OFF_T on Mac is u64.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174600 91177308-0d34-0410-b5e6-96231b3b80d8