summaryrefslogtreecommitdiff
path: root/lib/asan/asan_internal.h
AgeCommit message (Collapse)Author
2016-03-28[asan] Add runtime support for __asan_(un)register_image_globalsRyan Govostes
This change introduces routines that register and unregister all instrumented globals in a loaded executable image. These routines are only implemented on Darwin, where globals metadata is expected to be placed in the __DATA,__asan_globals section. Review: http://reviews.llvm.org/D16841 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@264644 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-02[asan] Add iOS support.Anna Zaks
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259451 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03[tsan] Use re-exec method to enable interceptors on older versions of OS XKuba Brecka
In AddressSanitizer, we have the MaybeReexec method to detect when we're running without DYLD_INSERT_LIBRARIES (in which case interceptors don't work) and re-execute with the environment variable set. On OS X 10.11+, this is no longer necessary, but to have ThreadSanitizer supported on older versions of OS X, let's use the same method as well. This patch moves the implementation from `asan/` into `sanitizer_common/`. Differential Revision: http://reviews.llvm.org/D15123 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254600 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-21[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across ↵Alexey Samsonov
all sanitizers. Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245734 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-06[sanitizer] 2-nd attempt. Add the flag handle_sigfpe that is default true to ↵Kostya Serebryany
handle SIGFPE crashes same as SIGSEV crashes, patch by Karl Skomski. This time the test is enabled only on x86-64 (it broke on ARM) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244234 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-06Revert "[sanitizer] Add the flag handle_sigfpe that is default true to ↵Renato Golin
handle SIGFPE crashes same as SIGSEV crashes, patch by Karl Skomski" This reverts commit r244136, it was breaking the ARM bots for too long. We should investigate it offline. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244210 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05[sanitizer] Add the flag handle_sigfpe that is default true to handle SIGFPE ↵Kostya Serebryany
crashes same as SIGSEV crashes, patch by Karl Skomski git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244136 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-21[asan] Remove AsanPlatformThreadInitReid Kleckner
Since the CoreFoundation allocator replacement was moved in r173134, all implementations of this function have been empty. Reviewers: samsonov Differential Revision: http://reviews.llvm.org/D11375 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@242811 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29Add descriptive names to sanitizer entries in /proc/self/maps. Helps debugging.Evgeniy Stepanov
This is done by creating a named shared memory region, unlinking it and setting up a private (i.e. copy-on-write) mapping of that instead of a regular anonymous mapping. I've experimented with regular (sparse) files, but they can not be scaled to the size of MSan shadow mapping, at least on Linux/X86_64 and ext3 fs. Controlled by a common flag, decorate_proc_maps, disabled by default. This patch has a few shortcomings: * not all mappings are annotated, especially in TSan. * our handling of memset() of shadow via mmap() puts small anonymous mappings inside larger named mappings, which looks ugly and can, in theory, hit the mapping number limit. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@238621 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-02asan: fix signal handling during stoptheworldDmitry Vyukov
The problem is that without SA_RESTORER flag, kernel ignores the handler. So tracer actually did not setup any handler. Add SA_RESTORER flag when setting up handlers. Add a test that causes SIGSEGV in stoptheworld callback. Move SignalContext from asan to sanitizer_common to print better diagnostics about signal in the tracer thread. http://reviews.llvm.org/D8005 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230978 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10Fix ASan's Noinst unit testsKuba Brecka
We currently skip all "Noinst" unit tests on OS X, which was probably caused when we removed the "allow_reexec" flag. The MaybeReexec function fails to re-execute when the runtime is linked statically, because there is no dylib to use. This patch adds an explicit DisableReexec function that is used from asan_noinst_test.cc and the runtime then doesn't try to re-execute. Reviewed at http://reviews.llvm.org/D7493 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228740 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21[asan] use MADV_NOHUGEPAGE for shadow to reduce the actual memory usageKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226636 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09Remove AsanInterceptsSignal in favor of (equivalent) IsDeadlySignal.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225556 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17[ASan] Move flag parsing logic to asan_flags.cc. NFC.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224450 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25[Asan] Pack signal context into a structureViktor Kutuzov
Differential Revision: http://reviews.llvm.org/D6148 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@222756 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-21[asan] Runtime support for asan-instrument-allocas which enables ↵Yury Gribov
instrumentation of variable-sized dynamic allocas. Patch by Max Ostapenko. Reviewed at http://reviews.llvm.org/D6055 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@222520 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-17[asan] the run-time part of intra-object-overflow detector ↵Kostya Serebryany
(-fsanitize-address-field-padding=1). Note that all of this is still experimental; don't use unless you are brave. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220013 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12[Sanitizer] Kill deprecated allocator interfaces in ASan, MSan and TSan in ↵Alexey Samsonov
favor of a unified interface in <sanitizer/allocator_interface.h>. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215469 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04[asan] introduce __asan_poison_cxx_array_cookie. This is asan-rt part of ↵Kostya Serebryany
PR19838 (Left OOB accesses on new[]-allocated arrays with array cookies are not detected). No tests yet. They will follow once I commit the clang part. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214711 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-25[Sanitizer] Introduce SANITIZER_CAN_USE_PREINIT_ARRAY definition and use it ↵Alexey Samsonov
across sanitizers. Get rid of ASAN_USE_PREINIT_ARRAY and LSAN_USE_PREINIT_ARRAY - just always use .preinit_array if it's available. This mode seems stable enough, and we've been relying on default values of these macro for a long time. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213980 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-07Generalize sanitizer allocator public interface.Alexey Samsonov
Introduce new public header <sanitizer/allocator_interface.h> and a set of functions __sanitizer_get_ownership(), __sanitizer_malloc_hook() etc. that will eventually replace their tool-specific equivalents (__asan_get_ownership(), __msan_get_ownership() etc.). Tool-specific functions are now deprecated and implemented as stubs redirecting to __sanitizer_ versions (which are implemented differently in each tool). Replace all uses of __xsan_ versions with __sanitizer_ versions in unit and lit tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212469 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06[asan] Make ReplaceSystemMalloc optional on Android.Evgeniy Stepanov
Don't fail if __libc_malloc_dispatch is missing; continue running with normal linux interceptors instead. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210322 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15Fix typosAlp Toker
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208841 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-12[ASan] Split static ASan runtime in two parts: asan and asan_cxx.Alexey Samsonov
asan_cxx containts replacements for new/delete operators, and should only be linked in C++ mode. We plan to start building this part with exception support to make new more standard-compliant. See https://code.google.com/p/address-sanitizer/issues/detail?id=295 for more details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208609 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-12[asan] define ASAN_DYNAMIC=1 if PIC is definedKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208530 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-01[ASan] Optional support for dynamic ASan runtime on Linux.Alexey Samsonov
Based on http://llvm-reviews.chandlerc.com/D3042 by Yuri Gribov! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205308 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31[asan] Read extra flags from a system property on activation on Android.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200550 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31[ASan] Move the SIGSEGV/SIGBUS handling to sanitizer_commonAlexander Potapenko
This change is a part of refactoring intended to have common signal handling behavior in all tools. This particular CL moves InstallSignalHandlers() into sanitizer_common (making it InstallDeadlySignalHandlers()), but doesn't enable default signal handlers for any tool other than ASan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200542 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28[ASan] Move the sigaltstack() bits to sanitizer_common.Alexander Potapenko
This change is a part of refactoring intended to have common signal handling behavior in all tools. Note that this particular change doesn't enable use_sigaltstack support in every tool. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200310 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28[ASan] Move the signal handling-related flags to sanitizer_common.Alexander Potapenko
This change is a part of refactoring intended to have common signal handling behavior in all tools. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200295 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16[asan] Implement delayed activation of AddressSanitizerEvgeniy Stepanov
This change adds ASAN_OPTIONS=start_deactivated=1 flag. When present, ASan will start in "deactivated" mode, with no heap poisoning, no quarantine, no stack trace gathering, and minimal redzones. All this features come back when __asan_init is called for the constructor of an instrumented library. The primary use case for this feature is Android. Code itself is not Android-specific, and this patch includes a Linux test for it. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199377 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-16[asan] Nuke ASAN_FLEXIBLE_MAPPING_AND_OFFSET.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@199370 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19[asan] new shadow poison magic for contiguous-container-buffer-overflow, ↵Kostya Serebryany
addressed Alexey Samsonov's comments for r195011 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195117 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-14[asan] Improve thread lifetime tracking on POSIX systems.Sergey Matveev
Call AsanThread::Destroy() from a late-running TSD destructor. Previously we called it before any user-registered TSD destructors, which caused false positives in LeakSanitizer. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192585 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-24Disable init-order checking before destructors are run.Alexey Samsonov
We don't want to report initialization-order bugs when a destructor of a global variable accesses dynamically initialized global from another (not necessarily initialized) module. We do this by intercepting __cxa_atexit and registrering our own callback that unpoisons shadow for all dynamically initialized global variables. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182637 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03[ASan] Kill the remainders of platform defines in favor of SANITIZER_ definesAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178629 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-28[ASan] Speed-up initialization-order checking: create and use fast versions ↵Alexey Samsonov
of PoisonShadow functions, store copies of __asan_global descriptors in a vector instead of list of pointers. This gives 3x speedup on both benchmarks and real binaries with lots of globals. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178239 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] More renamed macros.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177401 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-19[sanitizer] Move ASan platform macros to sanitizer_common and rename them ↵Evgeniy Stepanov
appropriately. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177397 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20[asan] on linux, run __asan_init from .preinit_array (even earlier than before)Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175623 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-15[asan] make asan work with 7fff8000 offset and prelinkKostya Serebryany
When prelink is installed in the system, prelink-ed libraries map between 0x003000000000 and 0x004000000000 thus occupying the shadow Gap, so we need so split the address space even further, like this: || [0x10007fff8000, 0x7fffffffffff] || HighMem || || [0x02008fff7000, 0x10007fff7fff] || HighShadow || || [0x004000000000, 0x02008fff6fff] || ShadowGap3 || || [0x003000000000, 0x003fffffffff] || MidMem || || [0x00087fff8000, 0x002fffffffff] || ShadowGap2 || || [0x00067fff8000, 0x00087fff7fff] || MidShadow || || [0x00008fff7000, 0x00067fff7fff] || ShadowGap || || [0x00007fff8000, 0x00008fff6fff] || LowShadow || || [0x000000000000, 0x00007fff7fff] || LowMem || Do it only if necessary. Also added a bit of profiling code to make sure that the mapping code is efficient. Added a lit test to simulate prelink-ed libraries. Unfortunately, this test does not work with binutils-gold linker. If gold is the default linker the test silently passes. Also replaced __has_feature(address_sanitizer) with __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) in two places. Patch partially by Jakub Jelinek. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175263 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31[ASan] Split ASan interface header into private and public parts. Add a test ↵Alexey Samsonov
that makes sure users can include interface header git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174058 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17[ASan] minor changes to swapcontext handling: don't clear shadow memory if ↵Alexey Samsonov
context stack is too large git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172727 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-25[asan] properly define ASAN_LOW_MEMORY. Due to a mistake it has been always ↵Kostya Serebryany
true causing redzone and quarantine sizes to be smaller than it was some time before (and out of sync with the documentation). Also make one test less greedy git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171052 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-07ASan: change the strategy we use for installing malloc/free/symbolization ↵Alexey Samsonov
hooks on Linux: don't provide a default no-op implementations for hooks in runtime, and optionally call hooks if they are provided by the user. Don't force weak interface functions into runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169641 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04ASan: add new interface functions - __asan_(un)poison_stack_memory. Calls to ↵Alexey Samsonov
these functions are inserted by the instrumentation pass in use-after-scope mode git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@169201 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-23[ASan] Add interceptor for swapcontext to fight with false positives in some ↵Alexey Samsonov
of its use cases. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168508 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15[ASan] Revert r168040 and r168043 and take a cleaner solution suggested by ↵Alexander Potapenko
Kostya: return the known frame name for fake stack instead of looking it up. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168046 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15[ASan] Poison the leftmost shadow byte with a special value so that we can findAlexander Potapenko
the beginning of the fake frame when reporting an use-after-return error. Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=126 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168040 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-03Set ASAN_NEEDS_SEGV=0 on Android only.Alexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165120 91177308-0d34-0410-b5e6-96231b3b80d8