summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/esan/esan_interceptors.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove esan.Nico Weber2019-03-111-512/+0
| | | | | | | | | | | It hasn't seen active development in years, and it hasn't reached a state where it was useful. Remove the code until someone is interested in working on it again. Differential Revision: https://reviews.llvm.org/D59133 llvm-svn: 355862
* [Sanitizer] Add interceptor for pthread_sigmaskPavel Labath2019-02-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: pthread_sigmask is just like sigprocmask, except that its behavior in multithreaded programs is explicitly specified. Sanitizers were lacking a common interceptor for pthread_sigmask (although some specific sanitizers defined custom version), which lead to false positives (at least in msan) when using this function. The interceptor implementation, and its test are based on the equivalent code for sigprocmask. Reviewers: eugenis, vitalybuka Subscribers: kubamracek, delcypher, jfb, jdoerfert, llvm-commits, #sanitizers Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D58382 llvm-svn: 354874
* 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. llvm-svn: 351636
* [Esan] Port cache frag to FreeBSDDavid Carlier2018-10-041-3/+7
| | | | | | | | | | | | Data involving struct accesses accounting work (plan to support only efficiency-cache-frag flag in the frontend side). Reviewers: krytarowski, vitalybuka, jfb Reviewed By : vitalybuka Differential Revision: https://reviews.llvm.org/D52608 llvm-svn: 343812
* [sanitizer] Add fgets, fputs and puts into sanitizer_commonPeter Wu2018-06-111-10/+0
| | | | | | | | | | | | | | | Summary: Add fgets, fputs and puts to sanitizer_common. This adds ASAN coverage for these functions, extends MSAN support from fgets to fputs/puts and extends TSAN support from puts to fputs. Fixes: https://github.com/google/sanitizers/issues/952 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D46545 llvm-svn: 334450
* [sanitizer] Move mmap interceptors into sanitizer_commonVitaly Buka2018-03-071-41/+9
| | | | | | | | | | Reviewers: devnexen, krytarowski, eugenis Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D44125 llvm-svn: 326851
* Add NetBSD syscall hooks skeleton in sanitizersKamil Rytarowski2018-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implement the skeleton of NetBSD syscall hooks for use with sanitizers. Add a script that generates the rules to handle syscalls on NetBSD: generate_netbsd_syscalls.awk. It has been written in NetBSD awk(1) (patched nawk) and is compatible with gawk. Generate lib/sanitizer_common/sanitizer_platform_limits_netbsd.h that is a public header for applications, and included as: <sanitizer_common/sanitizer_platform_limits_netbsd.h>. Generate sanitizer_syscalls_netbsd.inc that defines all the syscall rules for NetBSD. This file is modeled after the Linux specific file: sanitizer_common_syscalls.inc. Start recognizing NetBSD syscalls with existing sanitizers: ASan, ESan, HWASan, TSan, MSan. Sponsored by <The NetBSD Foundation> Reviewers: joerg, vitalybuka, kcc, dvyukov, eugenis Reviewed By: vitalybuka Subscribers: hintonda, kubamracek, mgorny, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D42048 llvm-svn: 325206
* [asan] Recommit of r301904: Add strndup/__strndup interceptorsPierre Gousseau2017-05-111-0/+2
| | | | | | | | | Fix undeclared __interceptor_malloc in esan_interceptors.cc Fix undeclared strnlen on OSX Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 302781
* [sanitizer] Move fread and fwrite interceptors to sanitizer_commonMaxim Ostapenko2017-03-301-14/+0
| | | | | | | | {M, T, E}San have fread and fwrite interceptors, let's move them to sanitizer_common to enable ASan checks as well. Differential Revision: https://reviews.llvm.org/D31456 llvm-svn: 299061
* [esan] Fix ESan test failure on Debian Sid botQin Zhao2016-10-071-1/+1
| | | | | | | | | | | | Summary: Increase early allocation buffer size. Reviewers: bruening Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D25380 llvm-svn: 283598
* [esan] Fix ESan test failure on Debian Sid botQin Zhao2016-10-031-14/+28
| | | | | | | | | | | | | | Summary: Handles early allocation from dlsym by allocating memory from a local static buffer. Reviewers: bruening Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D25193 llvm-svn: 283139
* [esan|wset] Ensure SIGSEGV is not blockedDerek Bruening2016-07-061-0/+39
| | | | | | | | | | | | | | | | | | | | Summary: Adds interception of sigprocmask and pthread_sigmask to esan so that the working set tool can prevent SIGSEGV from being blocked. A blocked SIGSEGV results in crashes due to our lazy shadow page allocation scheme. Adds new sanitizer helper functions internal_sigemptyset and internal_sigismember. Adds a test to workingset-signal-posix.cpp. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D22063 llvm-svn: 274672
* [esan] Use internal_mmap during initializationDerek Bruening2016-06-161-0/+6
| | | | | | | | | Fixes another interceptor issue where an app with a static tcmalloc library that prevents our early-calloc handling from triggering yet does not have a static mmap crashes in our mmap interceptor. The solution is to call internal_mmap when REAL(mmap) is not yet set up. llvm-svn: 272870
* [sanitizer][esan] Add internal_sigaction_syscallDerek Bruening2016-06-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: Adds a version of sigaction that uses a raw system call, to avoid circular dependencies and support calling sigaction prior to setting up interceptors. The new sigaction relies on an assembly sigreturn routine for its restorer, which is Linux x86_64-only for now. Uses the new sigaction to initialize the working set tool's shadow fault handler prior to libc interceptor being set up. This is required to support instrumentation invoked during interceptor setup, which happens with an instrumented tcmalloc or other allocator compiled with esan. Adds a test that emulates an instrumented allocator. Reviewers: aizatsky Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D21083 llvm-svn: 272676
* Revert r272591, http://lab.llvm.org:8011/builders/clang-x64-ninja-win7 has ↵Nico Weber2016-06-141-6/+0
| | | | | | been broken since this landed. llvm-svn: 272659
* [sanitizer][esan] Add internal_sigaction_syscallDerek Bruening2016-06-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: Adds a version of sigaction that uses a raw system call, to avoid circular dependencies and support calling sigaction prior to setting up interceptors. The new sigaction relies on an assembly sigreturn routine for its restorer, which is Linux x86_64-only for now. Uses the new sigaction to initialize the working set tool's shadow fault handler prior to libc interceptor being set up. This is required to support instrumentation invoked during interceptor setup, which happens with an instrumented tcmalloc or other allocator compiled with esan. Adds a test that emulates an instrumented allocator. Reviewers: aizatsky Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D21083 llvm-svn: 272591
* Revert "[sanitizer][esan] Add internal_sigaction_syscall"Derek Bruening2016-06-131-6/+0
| | | | | | | | This reverts commit r272553. The iOS build fails to link. llvm-svn: 272557
* [sanitizer][esan] Add internal_sigaction_syscallDerek Bruening2016-06-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: Adds a version of sigaction that uses a raw system call, to avoid circular dependencies and support calling sigaction prior to setting up interceptors. The new sigaction relies on an assembly sigreturn routine for its restorer, which is Linux x86_64-only for now. Uses the new sigaction to initialize the working set tool's shadow fault handler prior to libc interceptor being set up. This is required to support instrumentation invoked during interceptor setup, which happens with an instrumented tcmalloc or other allocator compiled with esan. Adds a test that emulates an instrumented allocator. Reviewers: aizatsky Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D21083 llvm-svn: 272553
* [esan] Intercept calloc to avoid deadlocks with tcmallocDerek Bruening2016-06-081-2/+52
| | | | | | | | | | | | | | | | | | Summary: When tcmalloc initializes before esan, esan's initialization ends up calling back into tcmalloc due to the calloc done by dlsym. This results in a deadlock. We avoid this by special-casing this single allocation. Intercepting calloc also gives us the opportunity to act on its zeroing as stores by the application. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D21086 llvm-svn: 272076
* [esan] Initialize runtime during early interceptorsDerek Bruening2016-06-031-0/+9
| | | | | | | | | | | | | | | | | Summary: Adds initialization of esan's runtime library during any early interceptors that are sometimes called prior to the official __esan_init() invocation (we see this with apps using tcmalloc). Adds handling of interceptors called during interceptor initialization. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D20976 llvm-svn: 271744
* [esan] Ensure internal_sigaction() bypasses interceptorsDerek Bruening2016-06-031-0/+11
| | | | | | | | | | | | | | | | | | | | | | | Summary: Implements real_sigaction() which it turns out is required for internal_sigaction() to bypass the libc interceptors. Without real_sigaction(), our internal_sigaction() calls during init happen to work due to the EsanDuringInit check in COMMON_INTERCEPTOR_ENTER (though even here it does not feel right for an "internal_" call to go through the interceptor). The real problem is when we call internal_sigaction() after we're initialized, which only happens on an unhandled SIGSEGV for which the app has no handler: then we'll spin in an infinite loop as our attempts to remove our own handler repeatedly fail. It's not easy to add a test for that, unfortunately. Reviewers: aizatsky Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D20832 llvm-svn: 271626
* [esan] Intercept and chain signal handlersDerek Bruening2016-05-311-0/+40
| | | | | | | | | | | | | | | | | | Summary: In preparation for fault-based shadow memory iteration, we add support for our own signal handler by adding app signal handler interception as well as chaining for SIGSEGV. This is done in a simple manner: we do not honor the app's alternate stack nor any sigaction flags for SIGSEGV. Adds a new test of transparency in app signal handling. Reviewers: aizatsky Subscribers: filcab, kubabrecka, vitalybuka, zhaoqin, kcc, eugenis, llvm-commits Differential Revision: http://reviews.llvm.org/D20577 llvm-svn: 271272
* [esan] Add handling of large stack size rlimitsDerek Bruening2016-05-281-39/+4
| | | | | | | | | | | | | | | | | | | | | Summary: Adds detection of large stack size rlimits (over 1 TB or unlimited), which results in an mmap location that our shadow mapping does not support. We re-exec the application in this situation. Adds a test of this behavior. Adds general detection of mmap regions outside of our app regions. In the future we want to try to adaptively handle these but for now we abort. Moves the existing Linux-specific mmap code into a platform-specific file where the new rlimit code lives. Reviewers: eugenis Subscribers: vitalybuka, zhaoqin, kcc, aizatsky, llvm-commits, kubabrecka Differential Revision: http://reviews.llvm.org/D20745 llvm-svn: 271079
* [sanitizer] Move *stat to the common interceptorsEvgeniy Stepanov2016-05-111-71/+0
| | | | | | | | | | | Adds *stat to the common interceptors. Removes the now-duplicate *stat interceptor from msan/tsan/esan. This adds *stat to asan, which previously did not intercept it. Patch by Qin Zhao. llvm-svn: 269223
* [esan] EfficiencySanitizer shadow memoryDerek Bruening2016-05-111-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds shadow memory mapping support common to all tools to the new Efficiencysanitizer ("esan") family of tools. This includes: + Shadow memory layout and mapping support for 64-bit Linux for any power-of-2 scale-down (1x, 2x, 4x, 8x, 16x, etc.) that ensures that shadow(shadow(address)) does not overlap shadow or application memory. + Mmap interception to ensure the application does not map on top of our shadow memory. + Init-time sanity checks for shadow regions. + A test of the mmap conflict mechanism. Reviewers: aizatsky, filcab Subscribers: filcab, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, zhaoqin Differential Revision: http://reviews.llvm.org/D19921 llvm-svn: 269198
* [sanitizer] Move stat/__xstat to the common interceptorsMike Aizatsky2016-05-031-18/+0
| | | | | | | | | | | | | | | | | | Summary: Adds stat/__xstat to the common interceptors. Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan. This adds stat/__xstat to asan, which previously did not intercept it. Resubmit of http://reviews.llvm.org/D19875 with win build fixes. Reviewers: aizatsky, eugenis Subscribers: tberghammer, llvm-commits, danalbert, vitalybuka, bruening, srhines, kubabrecka, kcc Differential Revision: http://reviews.llvm.org/D19890 llvm-svn: 268466
* Revert "[sanitizer] Move stat/__xstat to the common interceptors"Mike Aizatsky2016-05-031-0/+18
| | | | | | | | This reverts commit 268440 because it breaks the windows bot. http://lab.llvm.org:8011/builders/sanitizer-windows/builds/21425/steps/build%20compiler-rt/logs/stdio llvm-svn: 268448
* [sanitizer] Move stat/__xstat to the common interceptorsMike Aizatsky2016-05-031-18/+0
| | | | | | | | | | | | | | | | Summary: Adds stat/__xstat to the common interceptors. Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan. This adds stat/__xstat to asan, which previously did not intercept it. Reviewers: aizatsky, eugenis Subscribers: tberghammer, danalbert, srhines, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, bruening Differential Revision: http://reviews.llvm.org/D19875 llvm-svn: 268440
* [esan] Use do-while rather than braces for empty interceptorsDerek Bruening2016-05-031-28/+129
| | | | | | | | | | | | | | | Summary: Replaces {} with a do..while sequence in esan's empty interceptors to allow natural use with a trailing semicolon. The sequence uses each argument to avoid warnings. Reviewers: filcab Subscribers: kubabrecka, llvm-commits, zhaoqin Differential Revision: http://reviews.llvm.org/D19832 llvm-svn: 268426
* [sanitizers] Get the proper symbol version when long double transition is ↵Marcin Koscielnicki2016-04-271-0/+2
| | | | | | | | | | | | | | | | | involved. On linux, some architectures had an ABI transition from 64-bit long double (ie. same as double) to 128-bit long double. On those, glibc symbols involving long doubles come in two versions, and we need to pass the correct one to dlvsym when intercepting them. A few more functions we intercept are also versioned (all printf, scanf, strtold variants), but there's no need to fix these, as the REAL() versions are never called. Differential Revision: http://reviews.llvm.org/D19555 llvm-svn: 267794
* [esan] Fix uninitialized warning from interception contextDerek Bruening2016-04-251-0/+2
| | | | | | | | The interception context is not used by esan, but the compiler complains about it being uninitialized all the same. We set it to null to avoid the warning. llvm-svn: 267376
* [esan] EfficiencySanitizer libc interceptorsDerek Bruening2016-04-231-0/+338
Summary: Adds libc interceptors to the runtime library for the new EfficiencySanitizer ("esan") family of tools. The interceptors cover the memory operations in most common library calls and will be shared among all esan tools. Reviewers: aizatsky Subscribers: zhaoqin, tberghammer, danalbert, srhines, llvm-commits, vitalybuka, eugenis, kcc Differential Revision: http://reviews.llvm.org/D19411 llvm-svn: 267293
OpenPOWER on IntegriCloud