summaryrefslogtreecommitdiff
path: root/lib/msan/msan.cc
AgeCommit message (Collapse)Author
2014-10-26[Sanitizer] Make StackTrace a lightweight reference to array of PCs, andAlexey Samsonov
introduce a BufferedStackTrace class, which owns this array. Summary: This change splits __sanitizer::StackTrace class into a lightweight __sanitizer::StackTrace, which doesn't own array of PCs, and BufferedStackTrace, which owns it. This would allow us to simplify the interface of StackDepot, and eventually merge __sanitizer::StackTrace with __tsan::StackTrace. Test Plan: regression test suite. Reviewers: kcc, dvyukov Reviewed By: dvyukov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5985 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220635 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-22[msan] Handle param-tls overflow.Evgeniy Stepanov
ParamTLS (shadow for function arguments) is of limited size. This change makes all arguments that do not fit unpoisoned, and avoids writing past the end of a TLS buffer. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@220351 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03[msan] Fix origin_history_per_stack_limit=0 behavior.Evgeniy Stepanov
It disables the per-stack limit. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217030 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12[MSan] Disable coredump for 64-bit binaries.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215482 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-26[Sanitizer] Simplify Symbolizer creation interface.Alexey Samsonov
Get rid of Symbolizer::Init(path_to_external) in favor of thread-safe Symbolizer::GetOrInit(), and use the latter version everywhere. Implicitly depend on the value of external_symbolizer_path runtime flag instead of passing it around manually. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214005 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30[msan] Limit stack origin chain length.Evgeniy Stepanov
Stack origins were created with unlimited length by mistake. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212036 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27[msan] Add store_context_size= flag.Evgeniy Stepanov
A new flag to control stack trace size for store event (in track-origins=2 mode) independently of malloc_context_size. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211896 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-25[msan] Fix bad interaction between with-calls mode and chained origin tracking.Evgeniy Stepanov
Origin history should only be recorded for uninitialized values, because it is meaningless otherwise. This change moves __msan_chain_origin to the runtime library side and makes it conditional on the corresponding shadow value. Previous code was correct, but _very_ inefficient. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211700 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-25[msan] Fix false positive on dynamic tls.Evgeniy Stepanov
Use existing DTLS code in sanitizer_tls_get_addr.{h,cc} to unpoison DTLS blocks both on allocation and deallocation. https://code.google.com/p/memory-sanitizer/issues/detail?id=44 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211683 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24[msan] Print stats even on successful run with atexit=1.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@211574 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06[msan] Fix wrong endianness when printing shadow.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210335 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06[msan] Better diagnostic for invalid origin id.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@210331 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-26[MSan] Implement __sanitizer_print_stack_trace().Sergey Matveev
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21[msan] Implement MSAN_OPTIONS=print_stats=1.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209287 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21[msan] Chained origins re-design.Evgeniy Stepanov
Generalize StackDepot and create a new specialized instance of it to efficiently (i.e. without duplicating stack trace data) store the origin history tree. This reduces memory usage for chained origins roughly by an order of magnitude. Most importantly, this new design allows us to put two limits on stored history data (exposed in MSAN_OPTIONS) that help avoid exponential growth in used memory on certain workloads. See comments in lib/msan/msan_origin.h for more details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209284 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-08[msan] Switch to common printf interceptors.Evgeniy Stepanov
Format string parsing is disabled by default. This is not expected to meaningfully change the tool behavior. With this change, check_printf flag could be used to evaluate printf format string parsing in MSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208295 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-07[MSan] Fixup for r206983: MsanThread may be unavailable in signal handler: ↵Alexey Samsonov
signals may be raised while thread is being destroyed git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208250 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-07[msan] Fix __msan_check_mem_is_initialized and prettify its output.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208195 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30[msan] Prettify __msan_print_shadow.Evgeniy Stepanov
Makes __msan_print_shadow output much more readable, adds origin info. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207622 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23[msan] Disable chained origins in signal handlers.Evgeniy Stepanov
StackDepot is not async-signal-safe; storing a new origin to it can deadlock. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206983 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-18[msan] Add new MSan callbacks for instrumentation-with-calls mode.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206584 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-11[msan] mprotect() more memory to detect user code outside of application range.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@206028 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-04[msan] Introduce MsanThread. Move thread-local allocator cache out of TLS.Evgeniy Stepanov
This reduces .tbss from 109K down to almost nothing. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205618 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-02[msan] Kill __msan_print_param_shadow.Evgeniy Stepanov
It does not do what it's name says, and what it actually does is hard to describe, and is not useful at all. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205415 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-02[msan] Add __msan_check_mem_is_initialized.Evgeniy Stepanov
An assert()-like function that checks that a memory range is fully initialized. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205413 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-02[msan] Precise origin handling in __unaligned_(load|store)*.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205412 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-31[msan] Remove an extra top frame from track-origins=2 reports.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@205192 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27[msan] Implement __msan_set_death_callback.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204926 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-20[libsanitizer] Introduce flag descriptions.Alexander Potapenko
Extend ParseFlag to accept the |description| parameter, add dummy values for all existing flags. As the flags are parsed their descriptions are stored in a global linked list. The tool can later call __sanitizer::PrintFlagDescriptions() to dump all the flag names and their descriptions. Add the 'help' flag and make ASan, TSan and MSan print the flags if 'help' is set to 1. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204339 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-18[msan] Origin tracking with history, compiler-rt part.Evgeniy Stepanov
Compiler-rt part of MSan implementation of advanced origin tracking, when we record not only creation point, but all locations where an uninitialized value was stored to memory, too. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204152 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-11[sanitizer] Use system unwinder in signal handlers on Android.Evgeniy Stepanov
Because of the way Bionic sets up signal stack frames, libc unwinder is unable to step through it, resulting in broken SEGV stack traces. Luckily, libcorkscrew.so on Android implements an unwinder that can start with a signal context, thus sidestepping the issue. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201151 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-03[msan] Fix a typo.Evgeniy Stepanov
Spotted by Keno Fischer. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200682 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-25[Sanitizer] Replace Symbolizer::IsAvailable and ↵Alexey Samsonov
Symbolizer::IsExternalAvailable with Symbolizer::CanReturnFileLineInfo. Remove now redundant checks in symbolizer initialization in TSan and MSan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@198000 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-20[sanitizer] Use the new sanitizer_interception.h header in all interceptors.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197808 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-20[msan] Replace wrap_indirect_calls runtime flag with an interface method.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197799 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18[msan] Disable DynamoRio detection.Evgeniy Stepanov
This code is not robust enough and triggers when simply linking with libdynamorio.so, without any code translation at all. Disabling it is safe (i.e. we may unpoison too much memory and see false negatives, but never false positives). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197568 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13[msan] Wrap indirect calls from sanitizer rtl when running under DR.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197226 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-13[msan] Add a check for recursive __msan_init.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197218 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-12[msan] Clean stack and TLS shadow on thread exit.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197156 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-11[msan] Get stack limits with pthread_create interceptor.Evgeniy Stepanov
Before we did it lazily on the first stack unwind in the thread. It resulted in deadlock when the unwind was caused by memory allocation inside pthread_getattr_np: pthread_getattr_np <<< not reentable GetThreadStackTopAndBottom __interceptor_realloc pthread_getattr_np git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197026 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-06[msan] Allow strlen() (and similar functions) of shadow memory.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196572 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05[sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.Sergey Matveev
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@196497 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-27tsan: fix flags parsingDmitry Vyukov
- running_on_valgrind was not parsed in some contexts - refactor code a bit - add comprehensive tests for flags parsing git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195831 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19[msan] Fix origin tracking in unaligned load/store.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195130 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-12[Sanitizer] Specify a default value for each common runtime flagAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194479 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-11[sanitizer] Warn if interception fails.Evgeniy Stepanov
This includes a clang-format pass over common interceptors. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194372 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-07[Sanitizer] Make StackTrace::Unwind the only public way to unwind a stack trace.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194196 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-01[msan] Check that address is an app region before printing shadow.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193863 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31[Sanitizer] Add Symbolizer::AddHooks() and use it in TSan and MSan.Alexey Samsonov
Summary: TSan and MSan need to know if interceptor was called by the user code or by the symbolizer and use pre- and post-symbolization hooks for that. Make Symbolizer class responsible for calling these hooks instead. This would ensure the hooks are only called when necessary (during in-process symbolization, they are not needed for out-of-process) and save specific sanitizers from tracing all places in the code where symbolization will be performed. Reviewers: eugenis, dvyukov Reviewed By: eugenis CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2067 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193807 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-29[Sanitizer] Simplify StackTrace::PrintStack interface: prefer common flags ↵Alexey Samsonov
to turn on/off the symbolization git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193587 91177308-0d34-0410-b5e6-96231b3b80d8