Commit Graph

27 Commits

Author SHA1 Message Date
Evgeniy Stepanov 89602651e8 [msan] Implement __msan_set_death_callback.
llvm-svn: 204926
2014-03-27 14:04:58 +00:00
Evgeniy Stepanov 412d973980 [msan] Origin tracking with history, compiler-rt part.
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.

llvm-svn: 204152
2014-03-18 13:45:19 +00:00
Evgeniy Stepanov 86d8fb5ba1 [msan] Clean stack and TLS shadow on thread exit.
llvm-svn: 197156
2013-12-12 13:48:47 +00:00
Evgeniy Stepanov cd07898cf8 [msan] Get stack limits with pthread_create interceptor.
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
  

llvm-svn: 197026
2013-12-11 10:55:42 +00:00
Alexey Samsonov b3d939902a [Sanitizer] Make StackTrace::Unwind the only public way to unwind a stack trace.
llvm-svn: 194196
2013-11-07 07:28:33 +00:00
Evgeniy Stepanov d280ee48e8 [msan] Fix invalid origin copying.
Origin copying may destroy valid origin info. This is caused by
__msan_copy_origin widening the address range to the nearest 4-byte aligned
addresses both on the left and on the right. If the target buffer is
uninitialized and the source is fully initialized, this will result in
overriding valid origin of target buffer with stale (possibly 0) origin of the
source buffer.

With this change the widened origin is copied only if corresponding shadow
values are non zero.

llvm-svn: 193338
2013-10-24 11:56:03 +00:00
Evgeniy Stepanov 2794c47243 [msan] Drain allocator cache when leaving thread.
llvm-svn: 193163
2013-10-22 14:31:30 +00:00
Evgeniy Stepanov 65562f5281 [msan] Fix origin of deallocated memory.
MSan poisons deallocated memory but it used to give it an invalid origin value,
resulting in confusing reports. This change associates deallocation stack trace
with such memory.

Note that MSan does not have quarantine, and use-after-free detection is very
limited.

llvm-svn: 190781
2013-09-16 11:03:31 +00:00
Evgeniy Stepanov ac5ac34cf7 [msan] Add source file:line to stack origin reports.
Runtime library part.

llvm-svn: 190686
2013-09-13 12:49:13 +00:00
Alexey Samsonov ef643ce471 [sanitizer] fix code style
llvm-svn: 189474
2013-08-28 11:26:09 +00:00
Evgeniy Stepanov cb22c67a21 [msan] Save/restore va_arg_overflow_tls in signal handlers.
llvm-svn: 189351
2013-08-27 14:08:15 +00:00
Evgeniy Stepanov c41798152f [msan] Unpoison all TLS shadow when leaving a signal handler.
llvm-svn: 189343
2013-08-27 12:59:39 +00:00
Evgeniy Stepanov 44b77c26e4 [msan] Allocator statistics interface and malloc hooks.
llvm-svn: 187653
2013-08-02 14:26:58 +00:00
Peter Collingbourne 9058c07c95 Move UnpoisonMappedDSO to sanitizer_common.
This is so DFSan will be able to use it.

Differential Revision: http://llvm-reviews.chandlerc.com/D1206

llvm-svn: 187372
2013-07-29 19:09:49 +00:00
Alexey Samsonov ed4594b76a [MSan] Rename __msan_unpoision_param to __msan::UnpoisonParam - it shouldn't be in interface
llvm-svn: 185062
2013-06-27 07:50:56 +00:00
Sergey Matveev 6eff11e714 [msan] Common flags in MSan.
llvm-svn: 181194
2013-05-06 13:15:14 +00:00
Evgeniy Stepanov c7af878a01 [msan] Conditionally disable new() and delete() wrappers.
To be used with static libstdc++.

llvm-svn: 178866
2013-04-05 12:03:47 +00:00
Evgeniy Stepanov fe0199ea54 [msan] Options for switching between fast and cfi unwinders in run time.
Does not change default behavior.

llvm-svn: 177057
2013-03-14 11:47:03 +00:00
Reid Kleckner c9d382b5a4 [msan] intercept dlopen and clear shadow for it
Summary:
The loader does not call mmap() through the PLT because it has to
bootstrap the process before libc is present.  Hooking dlopen() isn't
enough either because the loader runs module initializers before
returning, and they could run arbitrary msan instrumented code.

If msandr is present, then we can intercept the mmaps from dlopen at the
syscall layer and clear the shadow there.  If msandr is missing, we
clear the shadow after dlopen() and hope any initializers are trivial.

Reviewers: eugenis

CC: kcc, llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D509

llvm-svn: 176818
2013-03-11 18:07:42 +00:00
Reid Kleckner 063dfe3244 [msan] Block reports from interceptors during _Unwind_Backtrace
Summary:
I'm hitting a big recursive report from:
  uninit on strlen ->
  __msan::PrintWarningWithOrigin() ->
  __msan::GetStackTrace() ->
  __sanitizer::StackTrace::SlowUnwindStack() ->
  _Unwind_Backtrace() ->
  ... libgcc calls ->
  uninit on strlen() ->
  ... repeats

Reviewers: eugenis

Differential Revision: http://llvm-reviews.chandlerc.com/D497

llvm-svn: 176555
2013-03-06 16:11:58 +00:00
Evgeniy Stepanov 76dc3a81ea [msan] Use slow stack unwinder in UMR reports.
llvm-svn: 175510
2013-02-19 12:43:18 +00:00
Kostya Serebryany ec87e785a3 [msan] don't check shadow inside interceptors if we are inside symbolizer; add weak function __msan_default_options that overrides default options
llvm-svn: 175040
2013-02-13 07:19:47 +00:00
Evgeniy Stepanov eac7f934f0 [msan] Cleanup public interface header.
Moved everything users are not supposed to use to a private interface header.
Documented all public interfaces. Made them safe to use even if built without
MemorySanitizer.

llvm-svn: 173800
2013-01-29 14:33:29 +00:00
Evgeniy Stepanov 9b52ce94db [msan] Set program exit code in keep-going mode.
llvm-svn: 172057
2013-01-10 11:17:55 +00:00
Evgeniy Stepanov 367dc64563 [msan] Refactor report printing.
llvm-svn: 171105
2012-12-26 09:32:05 +00:00
Evgeniy Stepanov 6722716d78 [msan] Fix header comments.
llvm-svn: 171059
2012-12-25 11:53:51 +00:00
Evgeniy Stepanov c5033786ba [msan] MemorySanitizer runtime.
Initial commit of the MemorySanitizer runtime library.

llvm-svn: 169858
2012-12-11 12:27:27 +00:00