summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/interception
Commit message (Collapse)AuthorAgeFilesLines
* Fix check-interception link error in compiler-rt debug modeReid Kleckner2019-10-101-1/+4
| | | | llvm-svn: 374472
* [compiler-rt] Remove some cpplint filtersVitaly Buka2019-09-121-4/+4
| | | | llvm-svn: 371704
* Remove NOLINTs from compiler-rtVitaly Buka2019-09-111-2/+2
| | | | llvm-svn: 371687
* compiler-rt: Rename .cc file in lib/{interception/tests,safestack} to .cppNico Weber2019-08-014-7/+7
| | | | | | Like r367463, but for interception/tests and safestack. llvm-svn: 367560
* compiler-rt: Rename .cc files in lib/interception to .cpp.Nico Weber2019-07-315-8/+8
| | | | | | | | | | | 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. llvm-svn: 367456
* Fix asan infinite loop on undefined symbolSerge Guelton2019-07-201-2/+7
| | | | | | | | | | | | Fix llvm#39641 Recommit of r366413 Differential Revision: https://reviews.llvm.org/D63877 > llvm-svn: 366632 llvm-svn: 366638
* Revert "Fix asan infinite loop on undefined symbol"Serge Guelton2019-07-201-7/+2
| | | | | | | | This reverts commit cbd28cd05bb11e9d76d71c6cc2d38d89dbb1fe1a. Buildbot fail: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/22434/steps/64-bit%20check-asan-dynamic/ llvm-svn: 366634
* Fix asan infinite loop on undefined symbolSerge Guelton2019-07-201-2/+7
| | | | | | | | | | Fix llvm#39641 Recommit of r366413 Differential Revision: https://reviews.llvm.org/D63877 llvm-svn: 366632
* Revert "Fix asan infinite loop on undefined symbol"Matthew Voss2019-07-191-7/+2
| | | | | | | | This reverts commit 8e46275488ca453a24964cb26be0736172ad1db8. This was failing on sanitizer-x86_64-linux and our internal CI. llvm-svn: 366618
* Fix asan infinite loop on undefined symbolSerge Guelton2019-07-191-2/+7
| | | | | | | | | | Fix llvm#39641 Recommit of r366413 Differential Revision: https://reviews.llvm.org/D63877 llvm-svn: 366588
* Revert "Fix asan infinite loop on undefined symbol"Matthew Voss2019-07-181-7/+2
| | | | | | | | | | | This reverts commit 63719119c78ca965b5d80e5c20fcfe81ba28f896. The tests in this commit were failing on a Linux sanitizer bot and our internal CI. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/22401/steps/test%20standalone%20compiler-rt%20with%20symbolizer/logs/stdio llvm-svn: 366472
* Fix asan infinite loop on undefined symbolSerge Guelton2019-07-181-2/+7
| | | | | | | | Fix llvm#39641 Differential Revision: https://reviews.llvm.org/D63877 llvm-svn: 366413
* [compiler-rt][tests] Propagate COMPILER_RT_UNITTEST_LINK_FLAGSHubert Tong2019-05-011-0/+3
| | | | | | | | | | | | | | | | | | | | `COMPILER_RT_UNITTEST_LINK_FLAGS` is dropped in many places, unlike `COMPILER_RT_UNITTEST_CFLAGS`. This patch attempts to remove that inconsistency. Previously reviewed as part of D58951. Reviewers: sfertile, peter.smith, pzheng, phosek, Hahnfeld, nemanjai, jasonliu Reviewed By: sfertile Subscribers: jsji, kubamracek, dberris, mgorny, delcypher, jdoerfert, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D60143 llvm-svn: 359733
* [Sanitizer] Reland "Cleanup INTERCEPT_FUNCTION macro"Julian Lettner2019-05-013-29/+35
| | | | | | | | | | | | | | | | | | | | | | On Linux both version of the INTERCEPT_FUNCTION macro now return true when interception was successful. Adapt and cleanup some usages. Also note that `&(func) == &WRAP(func)` is a link-time property, but we do a runtime check. Tested on Linux and macOS. Previous attempt reverted by: 5642c3feb03d020dc06a62e3dc54f3206a97a391 This attempt to bring order to the interceptor macro goes the other direction and aligns the Linux implementation with the way things are done on Windows. Reviewed By: vitalybuka, rnk Differential Revision: https://reviews.llvm.org/D61358 llvm-svn: 359725
* Revert r359325 "[NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION ↵Reid Kleckner2019-04-303-4/+27
| | | | | | | | | | | | | | | to void" Changing INTERCEPT_FUNCTION to return void is not functionally correct. IMO the best way to communicate failure or success of interception is with a return value, not some external address comparison. This change was also creating link errors for _except_handler4_common, which is exported from ucrtbase.dll in 32-bit Windows. Also revert dependent changes r359362 and r359466. llvm-svn: 359611
* [NFC][Sanitizer] Remove GetRealFunctionAddress and replace usagesJulian Lettner2019-04-273-29/+4
| | | | | | | | Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D61205 llvm-svn: 359362
* [Sanitizer] Fix testJulian Lettner2019-04-261-0/+2
| | | | | | | I broke the build, panicked and applied the wrong fix in my previous commit. The ASSERT was obsolete, but not the call INTERCEPT_FUNCTION. llvm-svn: 359336
* [Sanitizer] Fix compliation error in testJulian Lettner2019-04-261-2/+0
| | | | | | | Remove obsolete assert. I missed this in my previous patch: https://reviews.llvm.org/D61145 llvm-svn: 359335
* [NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to voidJulian Lettner2019-04-261-4/+6
| | | | | | | | | | | | This temporary change tells us about all the places where the return value of the INTERCEPT_FUNCTION macro is actually used. In the next patch I will cleanup the macro and remove GetRealFuncAddress. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D61145 llvm-svn: 359325
* [NFC][Sanitizer] Extract GetFuncAddr from GetRealFunctionAddressJulian Lettner2019-04-253-9/+20
| | | | | | | | | | | | | | Summary: Hopefully, this will enable cleanup/removal of GetRealFunctionAddress in follow-up commits. Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61110 llvm-svn: 359213
* [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 llvm-svn: 357725
* [hwasan, asan] Intercept vfork.Evgeniy Stepanov2019-02-271-2/+8
| | | | | | | | | | | | | | | Summary: Intercept vfork on arm, aarch64, i386 and x86_64. Reviewers: pcc, vitalybuka Subscribers: kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58533 llvm-svn: 355030
* Commit macro intended to be included in r353483.Reid Kleckner2019-02-071-1/+1
| | | | llvm-svn: 353484
* [compiler rt] Win64 GetInstructionSize additional register MOV + stack ↵Reid Kleckner2019-02-072-2/+27
| | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 353483
* [safestack] Fix NetBSD buildVitaly Buka2019-01-221-4/+15
| | | | llvm-svn: 351771
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1911-44/+33
| | | | | | | | | | | | | | | | | 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. llvm-svn: 351636
* Make compiler-rt CMakeLists.txt formatting a bit more like LLVM's usual ↵Nico Weber2019-01-161-2/+4
| | | | | | formatting llvm-svn: 351363
* [interception] Switch to _type suffix instead of _f, NFC.Kuba Mracek2018-10-222-2/+2
| | | | | | | | Some Darwin functions have pairs like dispatch_apply and dispatch_apply_f so the added _f to interceptor types causes a clash. Let's add _type suffix instead. Differential Revision: https://reviews.llvm.org/D53167 llvm-svn: 344954
* [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 llvm-svn: 342649
* Introduce new type for inteceptors UINTMAX_TKamil Rytarowski2018-08-291-0/+1
| | | | | | | | | | | | | | | | | | | | | Summary: The UINTMAX_T type will be used in new interceptors. While there, correct the type of strtoumax(3) from INTMAX_T to UINTMAX_T. Original patch from Yang Zheng. Reviewers: vitalybuka, kcc, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, tomsun.0.7, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D51106 llvm-svn: 340907
* [CMake] Add compiler-rt header files to the list of sources for targetsDan Liew2018-07-101-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when building with an IDE so that header files show up in the UI. This massively improves the development workflow in IDEs. To implement this a new function `compiler_rt_process_sources(...)` has been added that adds header files to the list of sources when the generator is an IDE. For non-IDE generators (e.g. Ninja/Makefile) no changes are made to the list of source files. The function can be passed a list of headers via the `ADDITIONAL_HEADERS` argument. For each runtime library a list of explicit header files has been added and passed via `ADDITIONAL_HEADERS`. For `tsan` and `sanitizer_common` a list of headers was already present but it was stale and has been updated to reflect the current state of the source tree. The original version of this patch used file globbing (`*.{h,inc,def}`) to find the headers but the approach was changed due to this being a CMake anti-pattern (if the list of headers changes CMake won't automatically re-generate if globbing is used). The LLVM repo contains a similar function named `llvm_process_sources()` but we don't use it here for several reasons: * It depends on the `LLVM_ENABLE_OPTION` cache variable which is not set in standalone compiler-rt builds. * We would have to `include(LLVMProcessSources)` which I'd like to avoid because it would include a bunch of stuff we don't need. Differential Revision: https://reviews.llvm.org/D48422 llvm-svn: 336663
* [sanitizer] Trivial portion of the port to Myriad RTEMSWalter Lee2018-05-181-3/+12
| | | | | | | | | | | | | | | | | | | | | This commit contains the trivial portion of the port of ASan to Myriad RTEMS. - Whitelist platform in sanitizer_platform.h, ubsan_platform.h - Turn off general interception - Use memset for FastPoisonShadow - Define interception wrappers - Set errno symbol correctly - Enable ASAN_LOW_MEMORY - Enable preinit array - Disable slow unwinding - Use fuchsia offline symbolizer - Disable common code for: InitializeShadowMemory, CreateMainThread, AsanThread::ThreadStart, StartReportDeadlySignal, MaybeReportNonExecRegion. Differential Revision: https://reviews.llvm.org/D46454 llvm-svn: 332681
* [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 llvm-svn: 332095
* [sanitizer] Remove unneeded blank linesVitaly Buka2018-05-091-1/+0
| | | | llvm-svn: 331831
* [sanitizer] Update .clang-format in compiler-rtVitaly Buka2018-05-091-0/+2
| | | | | | Historically style is Google, but we never used AllowShortIfStatementsOnASingleLine. llvm-svn: 331829
* The OpenBSD UBsan port introduced two typos that broke the Solaris sanitizer ↵Rainer Orth2018-04-241-1/+1
| | | | | | | | | | build. The following patch restores it, will shortly commit as obvious. Differential Revision: https://reviews.llvm.org/D46006 llvm-svn: 330712
* OpenBSD Ubsan support / interceptionKamil Rytarowski2018-03-023-10/+10
| | | | | | | | | | | | | | | | Summary: Interception, enabling OpenBSD platform Patch by: David CARLIER Reviewers: krytarowski, vitalybuka, visa Reviewed By: vitalybuka Subscribers: srhines, fedor.sergeev, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D43893 llvm-svn: 326544
* [Sanitizers] Basic sanitizer Solaris support (PR 33274)Kamil Rytarowski2017-12-143-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is the first mostly working version of the Sanitizer port to 32-bit Solaris/x86. It is currently based on Solaris 11.4 Beta. This part was initially developed inside libsanitizer in the GCC tree and should apply to both. Subsequent parts will address changes to clang, the compiler-rt build system and testsuite. I'm not yet sure what the right patch granularity is: if it's profitable to split the patch up, I'd like to get guidance on how to do so. Most of the changes are probably straightforward with a few exceptions: * The Solaris syscall interface isn't stable, undocumented and can change within an OS release. The stable interface is the libc interface, which I'm using here, if possible using the internal _-prefixed names. * While the patch primarily target 32-bit x86, I've left a few sparc changes in. They cannot currently be used with clang due to a backend limitation, but have worked fine inside the gcc tree. * Some functions (e.g. largefile versions of functions like open64) only exist in 32-bit Solaris, so I've introduced a separate SANITIZER_SOLARIS32 to check for that. The patch (with the subsequent ones to be submitted shortly) was tested on i386-pc-solaris2.11. Only a few failures remain, some of them analyzed, some still TBD: AddressSanitizer-i386-sunos :: TestCases/Posix/concurrent_overflow.cc AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc AddressSanitizer-i386-sunos :: TestCases/log-path_test.cc AddressSanitizer-i386-sunos :: TestCases/malloc-no-intercept.c AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/concurrent_overflow.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/start-deactivated.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/default_options.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/log-path_test.cc AddressSanitizer-i386-sunos-dynamic :: TestCases/malloc-no-intercept.c SanitizerCommon-Unit :: ./Sanitizer-i386-Test/MemoryMappingLayout.DumpListOfModules SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerCommon.PthreadDestructorIterations Maybe this is good enough the get the ball rolling. Reviewers: kcc, alekseyshl Reviewed By: alekseyshl Subscribers: srhines, jyknight, kubamracek, krytarowski, fedor.sergeev, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D40898 llvm-svn: 320740
* [Sanitizers] Use SANITIZER_* macros in lib/interceptionKamil Rytarowski2017-12-068-45/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 319906
* sanitizer_common: Try looking up symbols with RTLD_DEFAULT if RTLD_NEXT does ↵Peter Collingbourne2017-11-101-0/+8
| | | | | | | | | | | | | | 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 llvm-svn: 317930
* [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 llvm-svn: 316929
* [asan] Add more x86 prologue decodings to handle x64 VC 2017 CRTReid Kleckner2017-10-241-0/+3
| | | | | | Fixes atoi and strtol interception. llvm-svn: 316482
* [cmake] [interception] Remove duplicate gtest from test COMPILE_DEPSMichal Gorny2017-10-121-1/+1
| | | | | | | | | | | | | 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 llvm-svn: 315605
* [Fuchsia] Magenta -> ZirconPetr Hosek2017-09-131-1/+1
| | | | | | | | | | Fuchsia's lowest API layer has been renamed from Magenta to Zircon. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D37770 llvm-svn: 313106
* [sanitizers CMake] NFC Refactor the logic for compiling and generating testsGeorge Karpenkov2017-08-151-27/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 310971
* [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 llvm-svn: 310419
* Reuse interception_linux for NetBSDKamil Rytarowski2017-08-082-5/+12
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 310351
* Add NetBSD support in interception.hKamil Rytarowski2017-08-041-3/+3
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 310140
* [sanitizer_common] Fuchsia support for interceptorsVitaly Buka2017-08-011-7/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 309745
* [sanitizers] Sanitizer tests CMake clean up: try #2George Karpenkov2017-07-281-15/+2
| | | | | | | | | | | | | | | | | 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 llvm-svn: 309341
OpenPOWER on IntegriCloud