Commit Graph

1925 Commits

Author SHA1 Message Date
Alexey Samsonov b2ac280f96 [Sanitizer] fix signed/unsigned compare warnings in sanitizer_stacktrace_test. Build sanitizer_common tests with -Werror as we use predictable just-built Clang for building them
llvm-svn: 176014
2013-02-25 09:00:03 +00:00
Alexey Samsonov 85f0a7e644 [TSan] Add interceptor for malloc_usable_size()
llvm-svn: 176013
2013-02-25 08:43:10 +00:00
Alexey Samsonov 10bccda948 [TSan] remove temporary build directory in 'make clean' command
llvm-svn: 176012
2013-02-25 08:32:02 +00:00
Richard Smith 0404ec8396 ubsan: Runtime handlers for array indexing checks.
llvm-svn: 175948
2013-02-23 02:40:07 +00:00
Reid Kleckner e1596856ec [Sanitizer] Add a test for the fast unwinder
Summary:
The test sets up fake x86-style fp+retaddr frames, since that's all the
unwinder works with.

Reviewers: kcc

CC: eugenis

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

llvm-svn: 175893
2013-02-22 15:10:16 +00:00
Evgeniy Stepanov 3065014026 [msan] MSanDR: initial commit.
MSanDR is a DynamoRio-based tool that handles uninstrumented libraries and
dynamically generated code for MSan.

llvm-svn: 175883
2013-02-22 09:34:19 +00:00
Kostya Serebryany 1d63d13ce2 [asan] move the .preinit_array hack into a separate file (added used attribute)
llvm-svn: 175871
2013-02-22 07:51:26 +00:00
Alexander Potapenko 97781c4dd0 [ASan] temporarily disable alloc_dealloc_mismatch on Mac, since the previous commit caused error reports in gTest.
llvm-svn: 175766
2013-02-21 17:12:21 +00:00
Alexander Potapenko a47c6ee286 [ASan] Make sure operator new/delete and friends are intercepted on OS X.
Because the interceptors will reside in a dylib, not the main executable, we can't just declare them,
but must use the interposition machinery.
Fix the test expectations in large_func_test.cc affected by the change.
This CL should make our Mac buildbots green.

llvm-svn: 175763
2013-02-21 16:54:09 +00:00
Alexander Potapenko 1615f193eb [ASan] Declare CreateThread as extern "C" to fix the Windows build.
llvm-svn: 175760
2013-02-21 15:32:50 +00:00
Alexander Potapenko 8dbcb98c52 [ASan] Revert the incorrect macro on Linux.
llvm-svn: 175745
2013-02-21 15:15:43 +00:00
Alexander Potapenko b8135a8a6b [ASan] Put several function prototypes back under #ifdef _WIN32 to fix the Windows build.
llvm-svn: 175743
2013-02-21 15:10:03 +00:00
Alexander Potapenko e8ba1c851a [ASan] Refactoring: nuke the redundant function declarations in asan_intercepted_functions.h
that had been used on OS X only.
The INTERCEPTOR() macro on OS X is now responsible for declaring the wrapped function, the wrapper and the
pair of pointers to them in __DATA,__interposition section. Thus adding an interceptor requires editing a single file now.

llvm-svn: 175740
2013-02-21 14:41:16 +00:00
Evgeniy Stepanov 57d6f737e6 [sanitizer] Add MSan to Makefile-based build rules.
llvm-svn: 175737
2013-02-21 13:55:54 +00:00
Kostya Serebryany ab5be26af5 [asan] speedup by more than 2x handling of the small memset/memcpy/etc calls
llvm-svn: 175728
2013-02-21 07:07:39 +00:00
Reid Kleckner 15f2d1f4be [Sanitizer] Try to fix infinite loop in frame pointer unwinder
Using > instead of >= ensures that each frame deref makes progress and
that we eventually terminate.

Issue: https://code.google.com/p/address-sanitizer/issues/detail?id=162
llvm-svn: 175661
2013-02-20 20:29:48 +00:00
Alexey Samsonov 7dc2b2f07d [ASan] revert part of r175631 that looks like accidental commit
llvm-svn: 175655
2013-02-20 19:55:47 +00:00
Alexander Potapenko 70b01558f1 [ASan] Delete asan/dynamic dir and temporarily move the interposers declarations to asan_intercepted_functions.h
Now that we have only one dependency on asan_intercepted_functions.h, we can unite that code with the interceptors declarations in asan_interceptors.cc and get rid of asan_intercepted_functions.h

llvm-svn: 175631
2013-02-20 15:46:02 +00:00
Alexander Potapenko 56821acc79 [ASan] Make isoc99_*scanf intercepted on Linux only. Those are unavailable on Darwin.
llvm-svn: 175629
2013-02-20 15:27:58 +00:00
Kostya Serebryany 7b989859a8 [asan] move preinit_test to Linux since on Mac __asan_init is called from ld-preload-ed runtime
llvm-svn: 175625
2013-02-20 15:10:22 +00:00
Kostya Serebryany d8c29210e5 [asan] on linux, run __asan_init from .preinit_array (even earlier than before)
llvm-svn: 175623
2013-02-20 14:28:08 +00:00
Alexey Samsonov aadd1f2ad6 [Sanitizer] use raw syscall instead of _exit() function on Linux
llvm-svn: 175622
2013-02-20 13:54:32 +00:00
Kostya Serebryany ac05bc0556 [asan] add a lit test for invoke-with-no-return instrumentation
llvm-svn: 175618
2013-02-20 12:37:22 +00:00
Evgeniy Stepanov ec1d286111 [sanitizer] Fix lint.
llvm-svn: 175615
2013-02-20 11:06:07 +00:00
Kostya Serebryany 8381ef2035 [asan] add test throw_call_test (broken with -static-libstdc++)
llvm-svn: 175614
2013-02-20 10:43:05 +00:00
Evgeniy Stepanov 2e50efd484 [sanitizer] Fix FileOps test on Android.
llvm-svn: 175515
2013-02-19 15:01:05 +00:00
Kostya Serebryany 96401c9da9 [asan] don't run the long double test if long double is the same as double
llvm-svn: 175514
2013-02-19 13:43:44 +00:00
Evgeniy Stepanov 477e88ee9e [sanitizer] Slightly lower allocator test memory consumption.
This way it fits on a random 1G device.

llvm-svn: 175513
2013-02-19 13:38:27 +00:00
Alexey Samsonov 0b07c63e07 [ASan] Allow ASan default runtime options be overriden at compile time by providing ASAN_DEFAULT_OPTIONS macro
llvm-svn: 175512
2013-02-19 13:14:48 +00:00
Alexey Samsonov 99b81b4bbe [Sanitizer] Allow runtime flags be separated by colon as well as space
llvm-svn: 175511
2013-02-19 13:03:37 +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 9f298da9bd [asan] instrument memory accesses with unusual sizes
This patch makes asan instrument memory accesses with unusual sizes (e.g. 5 bytes or 10 bytes), e.g. long double or
packed structures.
Instrumentation is done with two 1-byte checks
(first and last bytes) and if the error is found
__asan_report_load_n(addr, real_size) or
__asan_report_store_n(addr, real_size)
is called.

asan-rt part

Also fix lint.

llvm-svn: 175508
2013-02-19 11:30:25 +00:00
Evgeniy Stepanov adaca58526 [msan] Fix ReExec on linux.
execle(argv[0], ...) is wrong, because argv[0] may contain a PATH-resolvable
program name. Execute /proc/self/exe instead.

llvm-svn: 175504
2013-02-19 11:09:29 +00:00
Evgeniy Stepanov 3e2e32c618 [sanitizer] Fix Android build.
llvm-svn: 175503
2013-02-19 11:06:41 +00:00
Evgeniy Stepanov ea61d08185 [sanitizer] Add interceptors for localtime and friends.
llvm-svn: 175499
2013-02-19 09:19:16 +00:00
Kostya Serebryany 3e62fe8c23 [tsan] use our own GetEnv instead of libc's getenv
llvm-svn: 175498
2013-02-19 08:19:13 +00:00
Kostya Serebryany 776f3bba96 [asan] enable asan_prelink_test when gold is the default linker (gold and bfd linker have different flag syntax)
llvm-svn: 175431
2013-02-18 08:37:49 +00:00
Kostya Serebryany 15e9c852c0 [asan] added flag -d|--demangle to asan_symbolize.py, makes addr2line/llvm-symbolizer demangle the functions names
llvm-svn: 175429
2013-02-18 08:02:16 +00:00
Alexey Samsonov 9211bd33ec [Sanitizer] Make temporary filename depend on user ID
llvm-svn: 175424
2013-02-18 07:17:12 +00:00
Alexey Samsonov 4544d1fa3d [ASan] make variables unsigned to silence warnings - attempt 2
llvm-svn: 175285
2013-02-15 19:22:49 +00:00
Alexey Samsonov f6d7379def [ASan] make variable unsigned to silence the warning
llvm-svn: 175284
2013-02-15 19:02:32 +00:00
Alexander Potapenko 3182c3e441 [ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=159
MaybeReexec() does now a tricky job to manage DYLD_INSERT_LIBRARIES in a safe way.

Because we're using library interposition, it's critical for an instrumented app
to be executed with the runtime library present in DYLD_INSERT_LIBRARIES list.
Therefore if it's initially missing in that list, we append the runtime library name
to the value of DYLD_INSERT_LIBRARIES and then exec() ourselves.

On the other hand, some of the apps exec()ed by our program may not want to have
ASan runtime library preloaded, so we remove the runtime library from the
DYLD_INSERT_LIBRARIES if it's already there.

Users may want to preload other libraries using DYLD_INSERT_LIBRARIES, so we preserve those.

llvm-svn: 175276
2013-02-15 16:10:49 +00:00
Kostya Serebryany fd61b6f0c8 [asan] make asan work with 7fff8000 offset and prelink
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.

llvm-svn: 175263
2013-02-15 12:00:24 +00:00
Evgeniy Stepanov 2a25bfe06a [sanitizer] Get full argv and envp on glibc.
/proc/$PID/cmdline is clipped to 4Kb.
Locate argv and envp on the main thread stack.

llvm-svn: 175163
2013-02-14 14:40:03 +00:00
Alexander Potapenko 594d99588b [ASan] Fixed the wrong placement of #include
llvm-svn: 175157
2013-02-14 12:37:17 +00:00
Alexander Potapenko 6ad3589964 [ASan] Remove the 'alarm' script which isn't present on OS X by default.
The test may hang now if a regression occurs.

llvm-svn: 175155
2013-02-14 12:18:07 +00:00
Dmitry Vyukov 965a10e07c tsan: fix bug in suppression reading (suppressions from file were discarded)
llvm-svn: 175153
2013-02-14 11:03:45 +00:00
Evgeniy Stepanov 763b2981b4 [sanitizer] Raise argv limit for ReExec.
We are still limited by /proc/*/cmdline size (4Kb max on Linux!).

llvm-svn: 175145
2013-02-14 08:22:06 +00:00
Kostya Serebryany dd0ab08b6e [asan] use short path for sanitizer_common/tests/sanitizer_test_utils.h, add -I sanitizer_common/tests to asan/tests/CMakeLists.txt
llvm-svn: 175142
2013-02-14 08:12:26 +00:00
Kostya Serebryany 039fa75e4d [asan] fix x32 build (H.J. Lu)
llvm-svn: 175140
2013-02-14 08:05:55 +00:00