Commit Graph

610 Commits

Author SHA1 Message Date
Evgeniy Stepanov 86a4d2c32b [sanitizer] Intercept fgetpwent / fgetgrent.
These interceptors require deep unpoisoning of return values.
While at it, we do the same for all other pw/gr interceptors to
reduce dependency on libc implementation details.

llvm-svn: 205004
2014-03-28 13:03:55 +00:00
Evgeniy Stepanov 74e77756ef [sanitizer] Intercept getpwent/getgrent.
llvm-svn: 205000
2014-03-28 10:56:07 +00:00
Evgeniy Stepanov 89602651e8 [msan] Implement __msan_set_death_callback.
llvm-svn: 204926
2014-03-27 14:04:58 +00:00
Evgeniy Stepanov 9dcd5a353a [msan] Intercept several malloc-related functions.
llvm-svn: 204923
2014-03-27 13:29:29 +00:00
Rafael Espindola 5e46070516 Avoid aliases to weak aliases in interceptors.
The interceptors had code that after macro expansion ended up looking like

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("memalign")));

That is,
* __interceptor_memalign is a function
* memalign is a weak alias to __interceptor_memalign
* __interceptor___libc_memalign is an alias to memalign

Both gcc and clang produce assembly that look like

__interceptor_memalign:
...
        .weak   memalign
memalign = __interceptor_memalign
        .globl  __interceptor___libc_memalign
__interceptor___libc_memalign = memalign

What it means in the end is that we have 3 symbols pointing to the
same position in the file, one of which is weak:

     8: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor_memalign
     9: 0000000000000000     1 FUNC    WEAK   DEFAULT    1 memalign
    10: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor___libc_memalign

In particular, note that __interceptor___libc_memalign will always
point to __interceptor_memalign, even if we do link in a strong symbol
for memalign. In fact, the above code produces exactly the same binary
as

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("__interceptor_memalign")));

If nothing else, this patch makes it more obvious what is going on.

llvm-svn: 204823
2014-03-26 15:48:59 +00:00
Evgeniy Stepanov 1382fabd97 [msan] Enable SelectPartial test.
Fixed in r204716.

llvm-svn: 204717
2014-03-25 13:09:14 +00:00
Evgeniy Stepanov 517ff05ffb [msan] Fix compiler warning in msan_test.cc.
llvm-svn: 204708
2014-03-25 10:03:39 +00:00
Evgeniy Stepanov 90384ad60e [msan] A disabled test for inexact "select" instrumentation.
llvm-svn: 204707
2014-03-25 09:36:15 +00:00
Alexey Samsonov c41ca6d31a [CMake] Rename the variable
llvm-svn: 204602
2014-03-24 13:29:20 +00:00
Alexey Samsonov 1847401332 [CMake] Respect CMAKE_CXX_FLAGS in custom clang_compile commands
llvm-svn: 204593
2014-03-24 09:42:12 +00:00
Alexey Samsonov 8c956460d3 Make MSan unittest -Werror=sign-compare clean
llvm-svn: 204592
2014-03-24 09:41:11 +00:00
Sergey Matveev fa76f3b3a5 [MSan] Add __msan_unpoison_string() to the public interface.
Using __msan_unpoison() on null-terminated strings is awkward because
strlen() can't be called on a poisoned string. This case warrants a special
interface function.

llvm-svn: 204448
2014-03-21 10:12:17 +00:00
Alexander Potapenko 1296436cbf [libsanitizer] Introduce flag descriptions.
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.

llvm-svn: 204339
2014-03-20 12:52:52 +00:00
Alexey Samsonov 17703c1092 [CMake] Build sanitizer unit tests with -std=c++11
llvm-svn: 204234
2014-03-19 13:57:33 +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 9fa9a49853 [msan] Test for aggregates passing through ellipsis.
llvm-svn: 203795
2014-03-13 13:18:15 +00:00
Alexey Samsonov 32956d651a [CMake] Make append_if semantics similar to those used in LLVM
llvm-svn: 203773
2014-03-13 09:31:36 +00:00
Evgeniy Stepanov 72a9d25060 [sanitizer] Simplify interceptors with user callbacks.
Get rid of the context argument in UNPOISON_PARAM and INITIALIZE_RANGE.
Get rid of all the thread-local contexts in interceptors.

llvm-svn: 203119
2014-03-06 13:26:09 +00:00
Alexey Samsonov 6dece3c99f Add common interceptors for memchr/memrchr
llvm-svn: 202972
2014-03-05 13:25:32 +00:00
Alexey Samsonov d964e7cd81 [CMake] Test for libdl and libpthread presence
llvm-svn: 202847
2014-03-04 13:28:21 +00:00
Evgeniy Stepanov f7abc8dff6 [msan] Tests for X86 SIMD bitshift intrinsic support.
llvm-svn: 202713
2014-03-03 13:52:36 +00:00
Joerg Sonnenberger 9d09e2fe90 Reapply r201910. MSVC gets __func__ defined explicitly, even though it
can't build anything here.

llvm-svn: 202297
2014-02-26 20:33:22 +00:00
Kostya Serebryany cf5d8e4f29 AdjustStackSizeLinux() is used in Lsan, Tsan and Msan non-Linux-specific code so it seems it should have more generic name and moved to a common scope.
Renamed to AdjustStackSize.
Patch by Viktor Kutuzov.

llvm-svn: 202011
2014-02-24 08:53:26 +00:00
Reid Kleckner 324eee45a7 Revert "Replace __FUNCTION__ with __func__, the latter being standard C99/C++11."
This reverts commit r201910.

While __func__ may be standard in C++11, it was only recently added to
MSVC in 2013 CTP, and LLVM supports MSVC 2012.  __FUNCTION__ may not be
standard, but it's *very* portable.

llvm-svn: 201916
2014-02-22 00:37:45 +00:00
Joerg Sonnenberger b15779f307 Replace __FUNCTION__ with __func__, the latter being standard C99/C++11.
llvm-svn: 201910
2014-02-21 23:55:15 +00:00
Alexey Samsonov 11705b2f10 [CMake] break dependency between unit tests and runtimes in standalone build
llvm-svn: 201778
2014-02-20 12:03:56 +00:00
Alexey Samsonov cd8535a96d [CMake] Introduce COMPILER_RT_INCLUDE_TESTS option
llvm-svn: 201666
2014-02-19 11:18:47 +00:00
Alexey Samsonov 63a4af7346 [CMake] Add top-level target for each compiler-rt library, and add 'compiler-rt' target encompassing them all.
llvm-svn: 201556
2014-02-18 09:33:45 +00:00
Alexey Samsonov 878a9a5de2 [CMake] Check for -fPIE and -ffreestanding flags for consistency
llvm-svn: 201549
2014-02-18 08:07:09 +00:00
Alexey Samsonov b73db72a17 [CMake] Simplify setting compile flag disabling RTTI
llvm-svn: 201547
2014-02-18 07:52:40 +00:00
Alexey Samsonov 8434e60f7e Move MSan lit-tests under test/msan
llvm-svn: 201412
2014-02-14 13:02:58 +00:00
Evgeniy Stepanov a21280307f [sanitizer] Fix getpwuid_r (and similar) interceptors missing one of the arguments.
llvm-svn: 201410
2014-02-14 12:32:15 +00:00
Evgeniy Stepanov 05938a23f5 [sanitizer] Use mmap to zero-fill large shadow regions.
This is covered by existing ASan test.
This does not change anything for TSan by default (but provides a flag to 
change the threshold size).
Based on a patch by florent.bruneau here:
  https://code.google.com/p/address-sanitizer/issues/detail?id=256

llvm-svn: 201400
2014-02-14 11:41:26 +00:00
Alexey Samsonov 81a2b466e9 Move shared configs for lit test suites to test/ and unittests/ directories
llvm-svn: 201399
2014-02-14 11:00:07 +00:00
Evgeniy Stepanov fb74ea80dc [msan] Replicate mmap-below-shadow check in mmap64 interceptor.
llvm-svn: 201397
2014-02-14 09:49:29 +00:00
Evgeniy Stepanov 769d46f373 [sanitizer] Use system unwinder in signal handlers on Android.
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.

llvm-svn: 201151
2014-02-11 13:38:57 +00:00
Evgeniy Stepanov 791a7e1603 [msan] Return EINVAL instead of crashing from mmap of an invalid address.
llvm-svn: 201074
2014-02-10 09:37:03 +00:00
Nick Lewycky af2064f7ab Add throw() specifiers to more redeclarations of operator delete and operator delete[].
llvm-svn: 201016
2014-02-08 01:42:08 +00:00
Sergey Matveev 4a03fa4f60 [sanitizer] Intercept if_indextoname() and if_nametoindex().
llvm-svn: 200945
2014-02-06 20:39:33 +00:00
Sergey Matveev 544d07f861 [sanitizer] One does not simply intercept getifaddrs().
Upgrade the interceptor, and attempt to fix the Android build.

llvm-svn: 200936
2014-02-06 18:48:23 +00:00
Sergey Matveev 07802a090a [sanitizer] Intercept getifaddrs().
llvm-svn: 200926
2014-02-06 17:42:36 +00:00
Sergey Matveev 0c62992d6e [sanitizer] Intercept getresuid and getresgid.
llvm-svn: 200925
2014-02-06 15:12:56 +00:00
Sergey Matveev c5c84a1d86 [sanitizer] Implement ioctl decoding.
When an unknown ioctl is encountered, try to guess the parameter size from the
request id.

llvm-svn: 200872
2014-02-05 19:35:24 +00:00
Evgeniy Stepanov 04e841c047 [msan] Fix a typo.
Spotted by Keno Fischer.

llvm-svn: 200682
2014-02-03 07:27:01 +00:00
Sergey Matveev c18b36625e [sanitizer] Partial revert of recent ioctl changes.
Some build environments are missing the required headers.
This reverts r200544, r200547, r200551. This does not revert the change that
introduced READWRITE ioctl type.

llvm-svn: 200567
2014-01-31 19:19:45 +00:00
Sergey Matveev dffda4cfec [sanitizer] Attempt to fix Android build.
llvm-svn: 200547
2014-01-31 14:28:32 +00:00
Sergey Matveev 6b3397546e [sanitizer] Support most ioctls from /usr/include/sound/.
llvm-svn: 200544
2014-01-31 14:02:21 +00:00
Alexander Potapenko d5802fe548 Make signal-related functions use __sanitizer_* structures instead of __sanitizer_kernel_* ones.
Also rename internal_sigaction() into internal_sigaction_norestorer(), as this function doesn't fully
implement the sigaction() functionality on Linux.

This change is a part of refactoring intended to have common signal handling behavior in all tools.

llvm-svn: 200535
2014-01-31 11:29:51 +00:00
Sergey Matveev be68311660 [msan] Intercept *getxattr and *listxattr.
llvm-svn: 200464
2014-01-30 12:21:12 +00:00
Sergey Matveev 1394f2da85 [msan] Rewrite strto* interceptors and add a few more.
Express the strto* interceptors though macros. This removes a lot of
duplicate code and fixes a couple of copypasto bugs (where "res" was declared of
a different type than the actual return type). Also, add a few more interceptors
for strto*_l.

llvm-svn: 200316
2014-01-28 13:45:58 +00:00
Evgeniy Stepanov 0b09c623c1 [msan] Replace assert() with GTest ASSERT_* in msan_test.
llvm-svn: 200293
2014-01-28 08:51:39 +00:00
Evgeniy Stepanov 067f54718f [msan] Disable mmap outside of application address range.
llvm-svn: 200200
2014-01-27 09:12:22 +00:00
Kostya Serebryany e402b431c0 [msan] add __libc_memalign interceptor; add a regression test for the existing bug with dtls support in msan
llvm-svn: 199980
2014-01-24 09:14:11 +00:00
Evgeniy Stepanov b1fa81047a [msan] Fix GCC warnings.
warning: ISO C99 requires rest arguments to be used [enabled by default]
 INTERCEPTOR(char *, dlerror) {

warning: invoking macro INTERCEPTOR argument 3: empty macro arguments are undefined in ISO C90 and ISO C++98 [enabled by default]
llvm-svn: 199873
2014-01-23 08:43:12 +00:00
Alexey Samsonov 00cd273c46 Sanitize printf functions.
Intercept and sanitize arguments passed to printf functions in ASan and TSan
(don't do this in MSan for now). The checks are controlled by runtime flag
(off by default for now).

Patch http://llvm-reviews.chandlerc.com/D2480 by Yuri Gribov!

llvm-svn: 199729
2014-01-21 11:58:33 +00:00
Evgeniy Stepanov 3ee789cbbb [msan] Temporarily disable two tests that are failing with new glibc.
llvm-svn: 198919
2014-01-10 07:34:16 +00:00
Alexey Samsonov 6322e036aa [Sanitizer] Replace Symbolizer::IsAvailable and Symbolizer::IsExternalAvailable with Symbolizer::CanReturnFileLineInfo.
Remove now redundant checks in symbolizer initialization in TSan and MSan.

llvm-svn: 198000
2013-12-25 07:09:44 +00:00
Evgeniy Stepanov 09021e02bc [msan] Add missing visibility attribute to MSan new/delete interceptors.
llvm-svn: 197809
2013-12-20 13:18:07 +00:00
Evgeniy Stepanov 42cebb00da [sanitizer] Use the new sanitizer_interception.h header in all interceptors.
llvm-svn: 197808
2013-12-20 13:17:31 +00:00
Evgeniy Stepanov 66297cac72 [msan] Wrap indirect calls to REAL(x) in interceptors.
llvm-svn: 197806
2013-12-20 12:20:15 +00:00
Evgeniy Stepanov 61628196e4 [msan] Replace wrap_indirect_calls runtime flag with an interface method.
llvm-svn: 197799
2013-12-20 11:05:19 +00:00
Alexey Samsonov f2c7659cf8 [ASan] Get rid of ASan-specific functions for printing stack traces
llvm-svn: 197672
2013-12-19 11:25:05 +00:00
Evgeniy Stepanov a164bf5e89 [msan] Disable DynamoRio detection.
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).

llvm-svn: 197568
2013-12-18 13:25:45 +00:00
Evgeniy Stepanov cb98c5f6f0 [msan] Relax gethostbyname_r test condition.
Apparently, its return value depends on the glibc version.

llvm-svn: 197390
2013-12-16 15:01:31 +00:00
Evgeniy Stepanov 43fc44007d [msan] Fix gethostbyname_r and similar interceptors.
*h_errno is written not on success, but on failure.
In fact, it seems like it can be written even when return value signals
success, so we just unpoison it in all cases.

llvm-svn: 197383
2013-12-16 13:24:33 +00:00
Evgeniy Stepanov 3158ec4002 [msan] Fix strncat interceptor, add missing tests.
llvm-svn: 197244
2013-12-13 16:31:59 +00:00
Evgeniy Stepanov 879c552dd9 [msan] Wrap indirect calls from sanitizer rtl when running under DR.
llvm-svn: 197226
2013-12-13 13:13:46 +00:00
Evgeniy Stepanov c8ccef49cc [msan] Add a check for recursive __msan_init.
llvm-svn: 197218
2013-12-13 09:11:14 +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
Evgeniy Stepanov 67bbf967b0 [msan] Allow strlen() (and similar functions) of shadow memory.
llvm-svn: 196572
2013-12-06 09:19:07 +00:00
Alexey Samsonov 2d42b1d693 Run TSan/MSan lit tests only on 64-bit platforms
llvm-svn: 196501
2013-12-05 12:53:36 +00:00
Sergey Matveev 9be70fbda9 [sanitizer] Introduce VReport and VPrintf macros and use them in sanitizer code.
Instead of "if (common_flags()->verbosity) Report(...)" we now have macros.

llvm-svn: 196497
2013-12-05 12:04:51 +00:00
Evgeniy Stepanov c0378e72d1 [sanitizer] Intercept textdomain.
Patch by Alexander Taran.

llvm-svn: 196098
2013-12-02 13:43:26 +00:00
Evgeniy Stepanov b56c5cd95e [sanitizer] Intercept times.
llvm-svn: 195918
2013-11-28 14:41:22 +00:00
Evgeniy Stepanov 9c1f8323ae [sanitizer] Intercept iconv.
llvm-svn: 195917
2013-11-28 14:14:48 +00:00
Evgeniy Stepanov b76b687628 [sanitizer] Intercept __xpg_strerror_r.
llvm-svn: 195839
2013-11-27 12:29:10 +00:00
Dmitry Vyukov 7bd319cc08 tsan: fix flags parsing
- running_on_valgrind was not parsed in some contexts
- refactor code a bit
- add comprehensive tests for flags parsing

llvm-svn: 195831
2013-11-27 09:54:10 +00:00
Dmitry Vyukov ee882ba4a1 tsan: support synchronization by means of linux aio
http://llvm-reviews.chandlerc.com/D2269

llvm-svn: 195830
2013-11-27 09:10:47 +00:00
Evgeniy Stepanov 1bdf5c93e1 [msan] Test for r195349.
llvm-svn: 195350
2013-11-21 12:01:07 +00:00
Evgeniy Stepanov 0958ecca7e [msan] Tweak io_submit syscall hook.
llvm-svn: 195246
2013-11-20 13:04:23 +00:00
Evgeniy Stepanov 584fd96e9e [msan] Unpoison memory that is returned to the OS and flush its shadow.
llvm-svn: 195244
2013-11-20 12:51:14 +00:00
Evgeniy Stepanov bfb2016c83 [msan] Fix origin tracking in unaligned load/store.
llvm-svn: 195130
2013-11-19 14:47:56 +00:00
Evgeniy Stepanov 5912fa4c4b [msan] A test for r194697.
llvm-svn: 194699
2013-11-14 12:31:18 +00:00
Alexey Samsonov 6345150992 [Sanitizer] Specify a default value for each common runtime flag
llvm-svn: 194479
2013-11-12 13:59:08 +00:00
Evgeniy Stepanov 5a29068b97 [msan] One more test for r194374.
llvm-svn: 194375
2013-11-11 13:38:24 +00:00
Evgeniy Stepanov b69699eb58 [sanitizer] Warn if interception fails.
This includes a clang-format pass over common interceptors.

llvm-svn: 194372
2013-11-11 11:28:30 +00:00
Evgeniy Stepanov bfdb9b2ec6 [msan] Sanity check for non-PIE.
llvm-svn: 194370
2013-11-11 09:27:20 +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 1c8c3fe4b4 [msan] Fix a very unfortunate typo in origin copying.
It was causing randomly missing origins.

llvm-svn: 194036
2013-11-05 01:24:38 +00:00
Evgeniy Stepanov a6b5eec757 [sanitizer] Intercept strptime.
llvm-svn: 193903
2013-11-02 01:01:35 +00:00
Evgeniy Stepanov 365bd0c88c [msan] Intercept memccpy.
llvm-svn: 193897
2013-11-01 23:49:48 +00:00
Alexey Samsonov 5dc6cff06a [Sanitizer] Unify summary reporting across all sanitizers.
This change unifies the summary printing across sanitizers:
now each tool uses specific version of ReportErrorSummary() method,
which deals with symbolization of the top frame and formatting a
summary message. This change modifies the summary line for ASan+LSan mode:
now the summary mentions "AddressSanitizer" instead of "LeakSanitizer".

llvm-svn: 193864
2013-11-01 17:02:14 +00:00
Evgeniy Stepanov 170d70be68 [msan] Check that address is an app region before printing shadow.
llvm-svn: 193863
2013-11-01 15:53:25 +00:00
Evgeniy Stepanov 2335879ff1 [sanitizer] Enhance io_submti syscall handler.
llvm-svn: 193848
2013-11-01 01:20:39 +00:00
Alexey Samsonov 4708c5912b Consistently use StackTrace::PrintStack in ASan, LSan and MSan
llvm-svn: 193834
2013-11-01 00:19:46 +00:00
Alexey Samsonov 627e2c0dd7 [Sanitizer] Add Symbolizer::AddHooks() and use it in TSan and MSan.
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

llvm-svn: 193807
2013-10-31 21:44:07 +00:00
Evgeniy Stepanov 13322c6eda [msan] Intercept dlerror.
llvm-svn: 193760
2013-10-31 16:58:44 +00:00
Evgeniy Stepanov a7add488ae [msan] Disable mlock/mlockall to work around a linux kernel bug.
The same logic is present in ASan and TSan.

llvm-svn: 193755
2013-10-31 15:51:22 +00:00
Evgeniy Stepanov 1cb37c4ee5 [sanitizer] Intercept getline, getdelim.
llvm-svn: 193730
2013-10-31 01:17:41 +00:00
Evgeniy Stepanov 0bd1f00ec6 [sanitizer] Intercept drand48_r, lrand48_r.
llvm-svn: 193655
2013-10-29 22:25:27 +00:00
Evgeniy Stepanov bf60342d47 [sanitizer] Intercept sincos, remquo, lgamma, lgamma_r.
llvm-svn: 193645
2013-10-29 19:49:35 +00:00
Evgeniy Stepanov 477f8b73a5 [sanitizer] Ptrace syscall handler.
llvm-svn: 193633
2013-10-29 17:59:45 +00:00
Dmitry Vyukov 3e8432ee6c tsan/asan: support pthread_setname_np to set thread names
llvm-svn: 193602
2013-10-29 10:30:39 +00:00
Alexey Samsonov a687d2593f [Sanitizer] Simplify StackTrace::PrintStack interface: prefer common flags to turn on/off the symbolization
llvm-svn: 193587
2013-10-29 05:31:25 +00:00
Evgeniy Stepanov 451c8de2d8 [msan] Intercept shmat.
llvm-svn: 193581
2013-10-29 02:48:49 +00:00
Evgeniy Stepanov d828208713 [msan] Fix a typo and enable poison_in_free flag.
llvm-svn: 193529
2013-10-28 18:53:37 +00:00
Dmitry Vyukov cf7259c094 asan/msan: separate different report blocks with new lines
this makes the reports consistent with tsan, and much more readable.

llvm-svn: 193520
2013-10-28 13:05:32 +00:00
Peter Collingbourne 791e65dcfb Overhaul the symbolizer interface.
This moves away from creating the symbolizer object and initializing the
external symbolizer as separate steps.  Those steps now always take place
together.

Sanitizers with a legacy requirement to specify their own symbolizer path
should use InitSymbolizer to initialize the symbolizer with the desired
path, and GetSymbolizer to access the symbolizer.  Sanitizers with no
such requirement (e.g. UBSan) can use GetOrInitSymbolizer with no need for
initialization.

The symbolizer interface has been made thread-safe (as far as I can
tell) by protecting its member functions with mutexes.

Finally, the symbolizer interface no longer relies on weak externals, the
introduction of which was probably a mistake on my part.

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

llvm-svn: 193448
2013-10-25 23:03:29 +00:00
Evgeniy Stepanov 94042e1ff2 [sanitizer] Intercept tmpnam, tmpnam_r, tempnam.
llvm-svn: 193415
2013-10-25 15:51:48 +00:00
Evgeniy Stepanov 2acb2470f9 [sanitizer] Remove pthread_attr_getstackaddr interceptor.
The function is deprecated.

llvm-svn: 193409
2013-10-25 14:27:00 +00:00
Evgeniy Stepanov 07507ffab4 [msan] Zerofill initstate_r buffer in random_r test.
llvm-svn: 193406
2013-10-25 13:03:20 +00:00
Evgeniy Stepanov c2b6cb0747 [sanitizer] Intercept pthread_attr_get*.
llvm-svn: 193405
2013-10-25 13:01:31 +00:00
Evgeniy Stepanov ced9fede02 [msan] Separate access and origin blocks in msan reports with an extra whiteline.
llvm-svn: 193401
2013-10-25 11:17:54 +00:00
Evgeniy Stepanov be9cdbb58c [sanitizer] Intercept random_r.
llvm-svn: 193396
2013-10-25 08:58:13 +00:00
Evgeniy Stepanov f312b480e2 [sanitizer] Intercept shmctl.
llvm-svn: 193348
2013-10-24 14:47:34 +00:00
Evgeniy Stepanov 7edb87a92c [msan] Unpoison errno in common interceptors.
llvm-svn: 193343
2013-10-24 13:20:34 +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 f2fd459a5b [msan] Change wording in the invalid origin message.
llvm-svn: 193335
2013-10-24 11:52:48 +00:00
Evgeniy Stepanov 3e6064f9d2 [sanitizer] Intercept ether_* functions.
llvm-svn: 193241
2013-10-23 13:57:47 +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 0229c09d43 [sanitizer] Intercept initgroups.
llvm-svn: 193158
2013-10-22 12:24:48 +00:00
Evgeniy Stepanov 3cb9df042e [sanitizer] Move statfs/fstatfs to common interceptors and add statvfs/fstatvfs.
llvm-svn: 192965
2013-10-18 11:14:16 +00:00
Evgeniy Stepanov 70d5abfba2 [sanitizer] Intercept getmntent, getmntent_r.
llvm-svn: 192959
2013-10-18 09:41:43 +00:00
Evgeniy Stepanov 4bbf273173 [sanitizer] Fix unpoisoning of msghdr::msg_name in recvmsg interceptor.
llvm-svn: 192886
2013-10-17 11:32:30 +00:00
Alexey Samsonov bc7c87a8cb [Sanitizer] Move pthread_cond_signal and pthread_cond_broadcast to common interceptors
llvm-svn: 192876
2013-10-17 09:24:03 +00:00
Evgeniy Stepanov 8df08225e5 [msan] Handle origins in __sanitizer_unaligned_(load|store)*.
llvm-svn: 192776
2013-10-16 08:25:13 +00:00
Alexey Samsonov edecc38395 Make some pthread_mutex_* and pthread_cond_* interceptors common.
Reviewers: eugenis, dvyukov

Reviewed By: dvyukov

CC: llvm-commits

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

llvm-svn: 192774
2013-10-16 08:20:31 +00:00
Dmitry Vyukov 7502a3a90c tsan: use verbosity flag in sanitizer_common code directly
now it's available from common_flags()

llvm-svn: 192705
2013-10-15 14:12:26 +00:00
Dmitry Vyukov 52ca74ec61 tsan: move verbosity flag to CommonFlags
llvm-svn: 192701
2013-10-15 13:28:51 +00:00
Evgeniy Stepanov 7a2bbc30a2 [msan] Remove CallocOverflow test.
This behaviour depends on MSAN_OPTIONS.
All interesting combinations are covered by lit_tests/allocator_returns_null.cc.

llvm-svn: 192691
2013-10-15 12:20:16 +00:00
Evgeniy Stepanov 113c646c56 [msan] Implement allocator_may_return_null=1 in MemorySanitizer.
llvm-svn: 192687
2013-10-15 11:33:48 +00:00
Evgeniy Stepanov 251d1e5d21 [msan] Test for r192599.
llvm-svn: 192600
2013-10-14 15:17:05 +00:00
Evgeniy Stepanov 7d7768e032 [msan] Remove a long-outdated comment.
llvm-svn: 192592
2013-10-14 13:30:40 +00:00
Evgeniy Stepanov 7aacd9c172 [msan] Intercept strto(d|f|ld)_l and glibc-specific __strto(d|f|ld)_l.
llvm-svn: 192583
2013-10-14 11:52:40 +00:00
Evgeniy Stepanov 054d533d8d [msan] Regression test for r192575.
llvm-svn: 192577
2013-10-14 09:53:39 +00:00
Alexey Samsonov 9d8385453b [Sanitizer] Simplify StackTrace::FastUnwindStack interface and fix a bug with one-frame stack traces
llvm-svn: 192428
2013-10-11 09:58:30 +00:00
Alexey Samsonov f2b811a618 Refactor the usage of strip_path_prefix option and make it more consistent across sanitizers
llvm-svn: 191943
2013-10-04 08:55:03 +00:00
Dmitry Vyukov 19a1302046 asan/msan: fix "unused function 'OnExit'" warning
llvm-svn: 191904
2013-10-03 15:43:59 +00:00
Dmitry Vyukov fdfb2ade8f asan/msan/tsan: move _exit interceptor to common interceptors
llvm-svn: 191903
2013-10-03 15:22:29 +00:00
Dmitry Vyukov 83ebd022d7 tsan: fix false positive in localtime()
llvm-svn: 191899
2013-10-03 14:12:09 +00:00
Evgeniy Stepanov c907a60ffb [sanitizer] Fix localtime and gmtime interceptors to clean tm->tm_zone.
llvm-svn: 191827
2013-10-02 14:30:03 +00:00
Dmitry Vyukov af335eddfe msan: fix compiler warnings about unused variables
llvm-svn: 191821
2013-10-02 14:02:08 +00:00
Evgeniy Stepanov 01781722b6 [sanitizer] Intercept backtrace, backtrace_symbols.
llvm-svn: 191516
2013-09-27 12:40:23 +00:00
Evgeniy Stepanov 022235cf04 [msan] Unpoison argument shadow for C++ module destructors.
Fixes PR17377.

llvm-svn: 191508
2013-09-27 11:32:21 +00:00
Evgeniy Stepanov 8f27f6b549 [sanitizer] A bunch of libc interceptors.
sigwait
sigwaitinfo
sigtimedwait
sigemptyset
sigfillset
sigpending
sigprocmask

llvm-svn: 191374
2013-09-25 14:47:43 +00:00
Evgeniy Stepanov 2761ee0409 [sanitizer] Intercept wordexp.
llvm-svn: 191305
2013-09-24 14:38:22 +00:00
Evgeniy Stepanov 46901f613b [msan] Test for atomic handling in MSan.
llvm-svn: 191288
2013-09-24 11:21:16 +00:00
Evgeniy Stepanov ce72b2c20b [msan] Fix a WTF in r191196.
llvm-svn: 191197
2013-09-23 13:34:26 +00:00
Evgeniy Stepanov f497bfee76 [msan] Allow nested symbolizer and loader scopes.
llvm-svn: 191196
2013-09-23 13:26:31 +00:00
Alexey Samsonov 786ee9b1ad [MSan] Fix -Wempty-body warning
llvm-svn: 190994
2013-09-19 08:35:16 +00:00
Evgeniy Stepanov 08d649c024 [msan] Check return value of main: compiler-rt tests.
llvm-svn: 190783
2013-09-16 13:25:26 +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 0da35401ce [msan] Add source file:line to stack origin reports.
Test.

llvm-svn: 190690
2013-09-13 12:55:07 +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
Evgeniy Stepanov 9be91e970e [msan] Intercept tzset.
llvm-svn: 190682
2013-09-13 11:27:38 +00:00
Alexey Samsonov 7a36e6126b [Sanitizer] Refactor symbolization interface: use class instead of several functions. Move some code around to get rid of extra source files
llvm-svn: 190410
2013-09-10 14:36:16 +00:00
Evgeniy Stepanov df96e863de [msan] bool -> int to make msan_interface.h C-compatible.
llvm-svn: 190402
2013-09-10 11:04:37 +00:00
Evgeniy Stepanov 842fa3f80d [msan] Intercept fstatat / fstatat64.
llvm-svn: 190306
2013-09-09 13:40:41 +00:00
Evgeniy Stepanov 5c1035e7fa [sanitizer] A bunch of linux system call handlers.
llvm-svn: 190157
2013-09-06 14:20:01 +00:00
Kostya Serebryany 6c5b034d7b [msan] make calloc crash instead of returning 0 on overflow (controlled by the allocator_may_return_null flag)
llvm-svn: 190132
2013-09-06 10:58:55 +00:00
Sergey Matveev b9d34443f2 [lsan] Colorize LSan reports.
llvm-svn: 189804
2013-09-03 13:31:03 +00:00
Alexey Samsonov 5b5c99d219 ASan, LSan, MSan: try to find llvm-symbolizer binary in PATH if it is not provided. Now we don't need to explicitly set the location of llvm-symbolizer in lit test configs.
llvm-svn: 189801
2013-09-03 13:22:51 +00:00
Evgeniy Stepanov 499d480be5 [msan] Another regression test for r189786.
llvm-svn: 189787
2013-09-03 10:08:14 +00:00
Evgeniy Stepanov f9ddb43975 [msan] A regression test for r189785.
llvm-svn: 189786
2013-09-03 10:05:45 +00:00
Evgeniy Stepanov e3eaa7bb35 [msan] Intercept memalign, valloc, pvalloc.
PR17039

llvm-svn: 189750
2013-09-02 09:24:53 +00:00
Alexey Samsonov ef643ce471 [sanitizer] fix code style
llvm-svn: 189474
2013-08-28 11:26:09 +00:00
Evgeniy Stepanov 4f961de94e [msan] Remove extra backup/restore calls.
llvm-svn: 189461
2013-08-28 09:17:47 +00:00
Alexey Samsonov 0803953cea Generate list of symbols exported from sanitizer runtimes only on 64-bit Unix
llvm-svn: 189454
2013-08-28 08:07:04 +00:00
Alexey Samsonov acab30e927 Properly generate lists of exported symbols for sanitizer runtimes
This change adds a Python script that is invoked for
the just-built sanitizer runtime to generate the list of exported symbols
passed to the linker. By default, it contains interceptors and sanitizer
interface functions, but can be extended with tool-specific lists.

llvm-svn: 189356
2013-08-27 15:08:02 +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 bb25af5f7b [msan] Fix a data race in signal/sigaction interceptors.
llvm-svn: 189342
2013-08-27 11:34:05 +00:00
Evgeniy Stepanov 82185980c4 [msan] A test for ppoll() interceptor.
llvm-svn: 189339
2013-08-27 11:10:20 +00:00
Evgeniy Stepanov a40a058ff1 [sanitizer] Simplify sigaction and sigset_t handling.
llvm-svn: 189338
2013-08-27 11:10:04 +00:00
Evgeniy Stepanov 0d13c707d5 [msan] Extend VAArgTLSOverwrite test.
This test now covers LLVM r189104.

llvm-svn: 189105
2013-08-23 12:13:18 +00:00
Dmitry Vyukov 97f0eae0a5 tsan/msan: add halt_on_error flag
If halt_on_error==true, program terminates after reporting first error.

llvm-svn: 188279
2013-08-13 15:33:00 +00:00
Timur Iskhodzhanov eee13914e2 Define SANITIZER_INTERFACE_ATTRIBUTE on Windows and fix all the places where SANITIZER_INTERFACE_ATTRIBUTE or SANITIZER_ATTRIBUTE_WEAK are used
llvm-svn: 188261
2013-08-13 11:42:45 +00:00
Evgeniy Stepanov 64cace0687 [sanitizer] Intercept poll/ppoll.
llvm-svn: 188177
2013-08-12 13:19:53 +00:00
Evgeniy Stepanov 98c39a184e [sanitizer] Intercept getgroups.
llvm-svn: 188167
2013-08-12 11:01:40 +00:00
Daniel Dunbar bc5dbc435e [tests] Update to use lit_config and lit package, as appropriate.
llvm-svn: 188116
2013-08-09 22:14:01 +00:00
Evgeniy Stepanov 564215d949 [sanitizer] Intercept scandir/scandir64.
llvm-svn: 187982
2013-08-08 13:57:15 +00:00
Evgeniy Stepanov 233455cba8 [sanitizer] Intercept strerror and strerror_r.
llvm-svn: 187978
2013-08-08 11:44:05 +00:00
Evgeniy Stepanov 7ea4795ed3 [sanitizer] ASan/MSan tests for r187967.
r187967: Disable inlining between sanitized and non-sanitized functions.
llvm-svn: 187971
2013-08-08 09:23:19 +00:00
Evgeniy Stepanov 04b7bff1fe [sanitizer] Intercept sched_getaffinity.
Re-applying with a more reliable test case.

llvm-svn: 187876
2013-08-07 09:10:16 +00:00
David Blaikie 787e2b6499 Revert "[sanitizer] Intercept sched_getaffinity."
This reverts commit r187788.

The test case is unreliable (as the test may be run in a situation in
which it has no affinity with cpu0). This can be recommitted with a more
reliable test - possibly using CPU_COUNT != 0 instead (I wasn't entirely
sure that a process was guaranteed to have at least one affinity, though
it seems reasonable, or I'd have made the change myself).

llvm-svn: 187841
2013-08-07 00:37:26 +00:00
Evgeniy Stepanov 03c0281a17 [sanitizer] Fix NULL arg handling in setitimer/getitimer interceptors.
llvm-svn: 187789
2013-08-06 09:54:33 +00:00
Evgeniy Stepanov 9f05e5e533 [sanitizer] Intercept sched_getaffinity.
llvm-svn: 187788
2013-08-06 09:29:01 +00:00
Evgeniy Stepanov 44b77c26e4 [msan] Allocator statistics interface and malloc hooks.
llvm-svn: 187653
2013-08-02 14:26:58 +00:00
Evgeniy Stepanov 90daaf9132 [msan] Fix unused function warning in the tests.
llvm-svn: 187648
2013-08-02 09:09:02 +00:00
Evgeniy Stepanov 5dbedf6c2a [msan] Intercept setenv, putenv.
llvm-svn: 187575
2013-08-01 11:14:14 +00:00
Evgeniy Stepanov 1ea380f693 [msan] Fix msan tests with pipefail option.
llvm-svn: 187485
2013-07-31 09:14:55 +00:00
Evgeniy Stepanov 9fbd981f99 [sanitizer] read() syscall hook.
llvm-svn: 187414
2013-07-30 13:04:43 +00:00
Evgeniy Stepanov 807e131261 [msan] Intercept pthread_join.
llvm-svn: 187413
2013-07-30 12:54:34 +00:00
Evgeniy Stepanov da9fd25603 [msan] Intercept confstr.
llvm-svn: 187412
2013-07-30 12:46:59 +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
Chandler Carruth d45abe12a6 Turn off pipefail on msan tests to match the other sanitizers until
someone can go through and update the RUN lines appropriately for the
new pipefail behavior.

llvm-svn: 187298
2013-07-27 10:30:39 +00:00
Hans Wennborg 2e304b6ffd Use --driver-mode=g++ instead of -ccc-cxx; required after Clang r186605
llvm-svn: 186607
2013-07-18 20:48:50 +00:00
Alexey Samsonov 9916aa2d95 [Sanitizer] move strcpy and strncpy to common interceptors
llvm-svn: 186408
2013-07-16 12:51:53 +00:00
Timur Iskhodzhanov d7eb67774e Fix check_lint warnings in sanitizers' runtime libraries
llvm-svn: 186328
2013-07-15 16:11:39 +00:00
Alexey Samsonov fde429ba69 [Sanitizer] Revert some parts of r186109 related to mbstowcs-and-friends interceptors
llvm-svn: 186155
2013-07-12 11:59:58 +00:00
Evgeniy Stepanov 9240838655 [sanitizer] More checks in mbstowcs-like interceptors.
llvm-svn: 186004
2013-07-10 14:17:46 +00:00
Evgeniy Stepanov 123fdb3413 [sanitizer] Fix handling of edge cases in mbstowcs-like interceptors.
llvm-svn: 186002
2013-07-10 14:01:51 +00:00
Evgeniy Stepanov 7160fb6511 [sanitizer] Update glob64 interceptor to handle GLOB_ALTDIRFUNC as well.
llvm-svn: 185935
2013-07-09 12:34:25 +00:00
Evgeniy Stepanov faba61a7bc [sanitizer] Support GLOB_ALTDIRFUNC in glob interceptor.
llvm-svn: 185932
2013-07-09 12:07:59 +00:00
Evgeniy Stepanov 77ef78a0a5 [sanitizer] Intercept realpath and canonicalize_file_name.
Handle realpath(path, NULL) form.

llvm-svn: 185921
2013-07-09 09:53:37 +00:00
Evgeniy Stepanov f7f252d025 [sanitizer] Syscall handlers for clock_gettime and clock_getres.
llvm-svn: 185913
2013-07-09 08:54:59 +00:00
Evgeniy Stepanov 628d727749 [msan] Intercept pthread_key_create.
llvm-svn: 185693
2013-07-05 12:31:07 +00:00
Evgeniy Stepanov 717e0cd2a7 [sanitizer] Intercept tcgetattr.
llvm-svn: 185626
2013-07-04 14:03:31 +00:00
Evgeniy Stepanov db615c186f [sanitizer] More interceptors.
bcopy
strtoimax, strtoumax
mbstowcs, mbsrtowcs, mbsnrtowcs
wcstombs, wcsrtombs, wcsnrtombs

llvm-svn: 185624
2013-07-04 13:19:41 +00:00
Evgeniy Stepanov aa23bd83e5 [msan] Intercept mempcpy, wmempcpy.
llvm-svn: 185431
2013-07-02 14:49:24 +00:00
Evgeniy Stepanov 69a387e6ae [sanitizer] Fix GLOB_NOMATCH behaviour and refactor the interceptor a bit.
llvm-svn: 185428
2013-07-02 14:08:52 +00:00
Evgeniy Stepanov 165d759a6a [sanitizer] Intercept mbtowc, mbrtowc, get_current_dir_name.
Move getcwd to common interceptors.

llvm-svn: 185424
2013-07-02 13:34:44 +00:00
Evgeniy Stepanov 1df4dfe87a [sanitizer] Intercept setlocale.
llvm-svn: 185416
2013-07-02 09:23:45 +00:00
Evgeniy Stepanov 654688bed5 [msan] Intercept stpcpy.
llvm-svn: 185340
2013-07-01 15:19:37 +00:00
Evgeniy Stepanov 8a4e24ea8b [sanitizer] Intercept getnameinfo.
llvm-svn: 185338
2013-07-01 13:51:31 +00:00
Alexey Samsonov e71f37c1cd Define the path to llvm-symbolizer tool in a common config to reduce copy-paste
llvm-svn: 185286
2013-06-30 14:47:38 +00:00
Evgeniy Stepanov dec0f76c14 [sanitizer] Intercept ptrace.
llvm-svn: 185142
2013-06-28 11:02:43 +00:00
Evgeniy Stepanov f5cae53057 [msan] Optionally disable 2 tests (dlopen & gethostbyname).
llvm-svn: 185076
2013-06-27 13:21:00 +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
Evgeniy Stepanov 06d6c25141 [sanitizer] readdir and readdir_r interceptors.
llvm-svn: 184950
2013-06-26 15:00:53 +00:00
Evgeniy Stepanov 982d56abb8 [sanitizer] Move log_path to common flag and use it in MSan.
llvm-svn: 184836
2013-06-25 13:50:44 +00:00
Evgeniy Stepanov 60d964d4f2 [sanitizer] Intercept sysinfo.
llvm-svn: 184739
2013-06-24 14:25:33 +00:00
Evgeniy Stepanov 02a7460d12 [sanitizer] Intercept inet_aton.
llvm-svn: 184735
2013-06-24 13:56:14 +00:00
Evgeniy Stepanov 830550ce4c [msan] Unpoison param-tls in signal handler wrapper.
This an entry point from uninstrumented code.

llvm-svn: 184734
2013-06-24 13:48:42 +00:00
Evgeniy Stepanov 0e8053af08 [sanitizer] Intercept readv, preadv, writev, pwritev.
llvm-svn: 184717
2013-06-24 10:43:23 +00:00
Evgeniy Stepanov b58b72e151 [msan] Intercept (v)asprintf.
llvm-svn: 184545
2013-06-21 13:32:26 +00:00
Evgeniy Stepanov ae4e1ec4e6 [msan] Add keep_going runtime flag.
llvm-svn: 184542
2013-06-21 12:37:58 +00:00
Alexey Samsonov dd489a4e15 [MSan] don't add msan unit tests to check-msan command if libcxx is not checked out
llvm-svn: 183641
2013-06-10 09:09:40 +00:00
Evgeniy Stepanov cead69d4a3 [sanitizer] Handle SIOCGIFCONF ioctl.
llvm-svn: 183529
2013-06-07 15:49:38 +00:00
Evgeniy Stepanov 0b1f41b6f4 [sanitizer] ioctl interceptor.
ASan: disabled by default
MSan: enabled by default
TSan: disabled
llvm-svn: 183517
2013-06-07 13:00:47 +00:00
Alexey Samsonov f6630ecee9 Simplify lit configs for asan/lsan/msan unit tests
llvm-svn: 183410
2013-06-06 13:48:20 +00:00
Alexey Samsonov e3bf521b7c Remove a bunch of copy-paste: use common config for sanitizer lit/unit tests
llvm-svn: 183407
2013-06-06 13:28:37 +00:00
Evgeniy Stepanov 56050e8f69 [sanitizer] Fix __sanitizer_unaligned_* to work with unaligned data types.
llvm-svn: 183224
2013-06-04 13:49:10 +00:00
Evgeniy Stepanov 53c8c13bf1 [msan] Implement __sanitizer_unaligned_*.
llvm-svn: 183221
2013-06-04 13:08:36 +00:00
Evgeniy Stepanov 4717d2d494 [msan] Fix gcc build of msan runtime.
llvm-svn: 182999
2013-05-31 13:04:07 +00:00
Evgeniy Stepanov 96284becf4 [msan] Handle mixed track-origins and keep-going settings (compiler-rt part).
Before this change, each module defined a weak_odr global __msan_track_origins
with a value of 1 if origin tracking is enabled, 0 if disabled. If there are
modules with different values, any of them may win. If 0 wins, and there is at
least one module with 1, the program will most likely crash.

With this change, __msan_track_origins is only emitted if origin tracking is
on. Then runtime library detects if there is at least one module with origin
tracking, and enables runtime support for it.

llvm-svn: 182996
2013-05-31 12:04:08 +00:00
Evgeniy Stepanov 677003140c [sanitizer] Fix getaddrinfo interceptor to use the actual returned sockaddr size.
llvm-svn: 182852
2013-05-29 12:33:31 +00:00
Evgeniy Stepanov fc708db4c1 [sanitizer] Intercept getpeername.
llvm-svn: 182844
2013-05-29 11:49:25 +00:00
Evgeniy Stepanov a4d08c4e87 [sanitizer] Move TSan and MSan recvmsg interceptors to common.
llvm-svn: 182843
2013-05-29 11:30:00 +00:00
Evgeniy Stepanov f28217ad0e [sanitizer] modf/modff/modfl interceptors.
llvm-svn: 182838
2013-05-29 10:03:11 +00:00
Alexey Samsonov c30e2d6b3a Make InternalAlloc/InternalFree in sanitizer runtimes libc-free by switching to a custom allocator.
llvm-svn: 182836
2013-05-29 09:15:39 +00:00
Evgeniy Stepanov 08f662845d [sanitizer] Share TSan accept & accept4 interceptors with other sanitizers.
llvm-svn: 182835
2013-05-29 09:09:58 +00:00
Evgeniy Stepanov 40d7ed5d1e [sanitizer] Improve getaddrinfo interceptor.
llvm-svn: 182775
2013-05-28 14:34:37 +00:00
Evgeniy Stepanov dd0780f81c [msan] Change report header to be more alike to ASan and TSan.
llvm-svn: 182774
2013-05-28 14:27:30 +00:00
Alexey Samsonov 9c2bcf8c15 Improve support for compiler-rt tests in CMake build.
Now compiler-rt tests run correctly if compiler-rt is checked out into
arbitrary directory (not necessarily projects/compiler-rt).
Patch by Greg Fitzgerald!

llvm-svn: 182726
2013-05-27 09:35:24 +00:00
Evgeniy Stepanov a343d1d881 [msan] Fix line >80 chars.
llvm-svn: 182578
2013-05-23 11:51:47 +00:00
Evgeniy Stepanov b978627cb8 [sanitizer] Intercept getsockopt.
llvm-svn: 182574
2013-05-23 11:38:08 +00:00
Evgeniy Stepanov ab25369d04 [sanitizer] Interceptors for gethostbyname and friends.
llvm-svn: 182573
2013-05-23 11:10:23 +00:00
Evgeniy Stepanov 97aea34b54 [msan] Intercept getsockname.
llvm-svn: 182475
2013-05-22 13:46:22 +00:00
Evgeniy Stepanov bfd2122b20 [msan] getaddrinfo & nested interceptor support.
Multiple connected changes:
- Ignore reads from nested interceptors.
- Check shadow on reads from common interceptors.
- getaddrinfo interceptor.

llvm-svn: 182466
2013-05-22 12:50:26 +00:00
Alexey Samsonov b99085b0b8 [MSan] Add empty default blacklist for MSan
llvm-svn: 182382
2013-05-21 13:55:56 +00:00
Evgeniy Stepanov 1d2f22825d [msan] Replace GetArgv hack with something that is slightly better.
llvm-svn: 182359
2013-05-21 08:56:22 +00:00
Evgeniy Stepanov 970be35808 [sanitizer] Intercept pthread_getschedparam.
llvm-svn: 182353
2013-05-21 08:12:08 +00:00
Peter Collingbourne 6d4a7d3723 [nolibc] Begin moving sanitizer_common's libc-dependent code to a separate library
Introduce a new object library, RTSanitizerCommonLibc, which will contain
the subset of sanitizer_common with libc dependencies. RTSanitizerCommon
contains the remainder of sanitizer_common, and is intended to have no
libc dependencies. Begin moving code to RTSanitizerCommonLibc, starting
with sanitizer_common.cc, whose libc-dependent portion is moved to
sanitizer_common_libcdep.cc, the first member of the new library.

This split affects the CMake build only.  The makefile build continues
to produce the full sanitizer_common library.

llvm-svn: 182118
2013-05-17 16:17:19 +00:00
Evgeniy Stepanov ff6728f2f8 [msan] Unpoison dlpi_name in dl_iterate_phdr interceptor.
llvm-svn: 182093
2013-05-17 12:51:13 +00:00
Evgeniy Stepanov 87c6ec7cfe [msan] Intercept dl_iterate_phdr.
llvm-svn: 182004
2013-05-16 13:00:25 +00:00
Evgeniy Stepanov f1efb256f6 Add sanitizer syscall hooks to the tool's export lists.
llvm-svn: 181790
2013-05-14 13:55:21 +00:00
Sergey Matveev 6eff11e714 [msan] Common flags in MSan.
llvm-svn: 181194
2013-05-06 13:15:14 +00:00
Evgeniy Stepanov 44b75efab4 [sanitizer] Intercept inet_pton and inet_ntop.
llvm-svn: 180107
2013-04-23 14:05:15 +00:00
Alexey Samsonov 34093f0de8 [MSan] Make a few interface functions accept 'const void *' instead of 'void*'
llvm-svn: 180102
2013-04-23 13:34:19 +00:00
Evgeniy Stepanov 455abf4872 [msan] Unpoison the result of posix_memalign.
llvm-svn: 180101
2013-04-23 13:27:36 +00:00
Evgeniy Stepanov 3076ba0a08 [sanitizer] Intercept getgrnam{_r}, getgrgid{_r}.
llvm-svn: 180091
2013-04-23 12:01:20 +00:00
Evgeniy Stepanov 0cd7cf8217 [msan] Allow clock_getres(, 0).
llvm-svn: 180090
2013-04-23 11:48:31 +00:00
Evgeniy Stepanov d1dae90bf2 [msan] Fix gcc build of msan_test.
llvm-svn: 179594
2013-04-16 14:09:47 +00:00
Evgeniy Stepanov b0d786798c [msan] Fix sigaction test.
Restore SIGPROF handler to the original state after the test.

llvm-svn: 179524
2013-04-15 13:35:05 +00:00
Evgeniy Stepanov 7332acac4c [msan] Really disable replacement new and delete.
llvm-svn: 179522
2013-04-15 12:41:52 +00:00
Alexey Samsonov e48866969e [MSan] Demangle function name in description of stack origin
llvm-svn: 179368
2013-04-12 07:27:30 +00:00
Alexey Samsonov 1a345ad502 [MSan] don't build tests with -fPIE/-pie, as these flags are implied by -fsanitize=memory now
llvm-svn: 179366
2013-04-12 07:14:04 +00:00
Alexey Samsonov 9f3938e271 Explicitly list all sanitizer headers in CMake build rules. Make sure sanitizer lit_tests depend on fresh headers.
llvm-svn: 179293
2013-04-11 15:49:52 +00:00
Evgeniy Stepanov f5523116e9 [sanitizer] Syscall hooks.
Pre- and post- hooks for linux syscalls. Not wired into anything, but exposed
through public interface.

llvm-svn: 179288
2013-04-11 14:37:04 +00:00
Evgeniy Stepanov 460067823b [sanitizer] Interceptors for wait*.
llvm-svn: 179096
2013-04-09 14:34:59 +00:00
Evgeniy Stepanov 69967c2835 [msan] Intercept glob() with tests.
llvm-svn: 179091
2013-04-09 11:35:13 +00:00
Evgeniy Stepanov b4eac2f810 [msan] Interceptors for pipe2 and socketpair.
llvm-svn: 179022
2013-04-08 13:45:12 +00:00
Evgeniy Stepanov 7ba7207f1d [msan] Intercept time().
llvm-svn: 179002
2013-04-08 08:25:22 +00:00
Kostya Serebryany 5b4267f7e7 [sanitizer] found a bug by code inspection: CHECK(a=b) instead of CHECK(a==b). Was puzzled why lint did not catch it. Turns out this check was disabled for asan source. fix all cases and enable the check
llvm-svn: 178872
2013-04-05 14:40:25 +00:00
Evgeniy Stepanov e7a7a9b972 [msan] Fix sigaction interceptor.
llvm-svn: 178868
2013-04-05 12:58:07 +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 7948c648bf [msan] A runtime option to disable wrapping of signal handlers.
llvm-svn: 178865
2013-04-05 11:59:16 +00:00
Alexey Samsonov 734aab4066 [Sanitizer] Use a common mutex to prevent mixing reports from different sanitizers. This fixes PR15516
llvm-svn: 178853
2013-04-05 07:30:29 +00:00
Evgeniy Stepanov 7b0e132551 [sanitizer] Use ucontext_t instead of "struct ucontext".
Fixes Mac build.

llvm-svn: 178755
2013-04-04 09:03:56 +00:00
Evgeniy Stepanov 1f8b3538b4 [msan] Unpoison siginfo_t and ucontext_t in signal handlers.
Add wrappers for all user signal handlers to unpoison the handler's arguments.

llvm-svn: 178754
2013-04-04 08:22:52 +00:00
Kostya Serebryany c3525ce6ac [sanitizer] while doing fast unwinding make sure that the frame pointer is aligned; fix lint
llvm-svn: 178747
2013-04-04 06:52:40 +00:00
Evgeniy Stepanov f8213b4eb3 [sanitizer] More interceptors.
getpwnam, getpwuid, getpwnam_r, getpwuid_r, clock_getres, clock_gettime,
clock_settime, getitimer, setitimer, sigaction (MSan).

llvm-svn: 178465
2013-04-01 14:47:21 +00:00
Alexander Potapenko f8109dd0f8 [libsanitizer] Unmapping the old cache partially invalidates the memory layout, so add
a flag to skip cache update for cases when that's unacceptable (e.g. lsan).

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178000
2013-03-26 10:34:37 +00:00
Richard Smith c91e327cba Build and install .syms files alongside sanitizer runtimes. These are used to
specify which symbols are exported to DSOs when the sanitizer is statically
linked into a binary.

llvm-svn: 177784
2013-03-23 00:31:07 +00:00
Evgeniy Stepanov ecbf64648f [msan] Handle dlopen() failure in dlopen interceptor.
llvm-svn: 177728
2013-03-22 11:59:49 +00:00
Evgeniy Stepanov 93a842bd1f [msan] Move test main and gtest include to separate files.
llvm-svn: 177718
2013-03-22 09:01:26 +00:00
Evgeniy Stepanov bfe9df221d [msan] Place dlopen in an anon namespace.
llvm-svn: 177716
2013-03-22 08:49:36 +00:00
Evgeniy Stepanov 0af672326a [sanitizer] Replace more platform checks with SANITIZER_ constants.
llvm-svn: 177400
2013-03-19 14:33:38 +00:00
Evgeniy Stepanov b4a218db34 [sanitizer] Don't adjust the size of the user-allocated stack.
Moved this code to sanitizer_common.

llvm-svn: 177383
2013-03-19 09:30:52 +00:00
Evgeniy Stepanov c6bce93591 [msan] Intercept readdir64.
llvm-svn: 177065
2013-03-14 12:49:23 +00:00
Evgeniy Stepanov 4062a396c7 [msan] Fix a typo in test.
llvm-svn: 177059
2013-03-14 11:58:13 +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
Evgeniy Stepanov 231894a902 [sanitizer] Intercept frexp and friends.
llvm-svn: 177056
2013-03-14 11:34:39 +00:00
Evgeniy Stepanov ead6cf7c72 [msan] Intercept __strdup, strndup, __strndup.
llvm-svn: 177052
2013-03-14 11:10:36 +00:00
Evgeniy Stepanov 96f82f8ac3 [sanitizer] Fix lint.
llvm-svn: 176943
2013-03-13 10:20:35 +00:00
Alexey Samsonov d7ab381f53 [Sanitizer] Build ASan, TSan and MSan runtimes with -fno-rtti.
llvm-svn: 176940
2013-03-13 09:18:30 +00:00
Evgeniy Stepanov 98f5ea0dba [msan] Increase stack size as required.
Adjust stack size in pthread_attr_t when the app-requested size does not fit MSan TLS.

llvm-svn: 176939
2013-03-13 09:01:40 +00:00
Alexey Samsonov 06d3aa4884 [Sanitizer] Change MemoryMappingLayout methods to also report memory protection flags (for future use in leak checker). Patch by Sergey Matveev.
llvm-svn: 176931
2013-03-13 06:51:02 +00:00