Commit Graph

89 Commits

Author SHA1 Message Date
Alexey Samsonov 1dc928e1b1 [ASan] remove -fsanitize=init-order from lit tests as now it's implied by -fsanitize=address
llvm-svn: 177064
2013-03-14 12:43:03 +00:00
Alexey Samsonov 963be1ddd8 [ASan] turn off checking initialization order in ASan runtime by default. Instead, it should be turned on by default in the compiler
llvm-svn: 177058
2013-03-14 11:49:40 +00:00
Alexander Potapenko f1c48eb509 [ASan] Add the memcmp_strict flag (1 by default) that controls the behavior of accessibility checks in memcmp.
1: memcmp(p1, p2, n) always checks n bytes
0: memcmp checks up to n bytes depending on whether the memory contents differ.

llvm-svn: 176256
2013-02-28 14:09:30 +00:00
Kostya Serebryany abebb57272 [asan] bump kMidMemEnd to 0x4fffffffffULL since in rare cases prelink uses addresses higher than 0x3fffffffff
llvm-svn: 176250
2013-02-28 12:28:37 +00:00
Kostya Serebryany c8ac15a66b [asan] use the new attribute syntax (no_address_safety_analysis => no_sanitize_address)
llvm-svn: 176077
2013-02-26 07:01:06 +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
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
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
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
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
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
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
Alexander Potapenko c5ba5ef3c5 [ASan] When re-executing the process on OS X, make sure we update the existing DYLD_INSERT_LIBRARIES correctly.
Previously ASan used to hang in an exec loop, because it failed to overwrite the env var value
(see https://code.google.com/p/address-sanitizer/issues/detail?id=159).

llvm-svn: 175059
2013-02-13 17:52:55 +00:00
Evgeniy Stepanov 9f9d79f3ad [sanitizer] Fix line numbers in a sanitizer lit test.
llvm-svn: 174861
2013-02-11 07:19:24 +00:00
Evgeniy Stepanov 0b805cc75c [asan] Fix off-by-one in AddrIsAtRight.
llvm-svn: 174710
2013-02-08 12:59:42 +00:00
Alexander Potapenko 4fb43438d9 [ASan] Enable the new and delete wrappers on Darwin.
Also fix large_func_test.cc, which got broken when we switched to allocator2: the OOB access was too far from the original allocation, so ASan decided to describe the next one.

llvm-svn: 174626
2013-02-07 15:33:56 +00:00
Evgeniy Stepanov 1bc7298c44 [asan] Fix nonsensical reports of partial right OOB.
In case of partial right OOB, ASan was reporting
  X is located 0 bytes to the right of [A, B)
where X was actually inside [A, B).

With this change, ASan will report B as the error address in such case.

llvm-svn: 174373
2013-02-05 14:32:03 +00:00
Alexey Samsonov a0c0da8f51 [ASan] Split ASan interface header into private and public parts. Add a test that makes sure users can include interface header
llvm-svn: 174058
2013-01-31 13:46:14 +00:00
Alexey Samsonov 0d92533b29 Use LLVM_BUILD_TYPE instead of CMAKE_BUILD_TYPE in compiler-rt unit tests to match the behavior of llvm unittests
llvm-svn: 173926
2013-01-30 12:18:49 +00:00
Alexey Samsonov 49a32c1d08 [Sanitizer] update style checker script and fix namespace style warnings
llvm-svn: 173910
2013-01-30 07:45:58 +00:00
Dmitry Vyukov 73b12d7132 asan: fix the test
llvm-svn: 173786
2013-01-29 09:59:53 +00:00
Alexey Samsonov 1e63b08575 ASan: add output test for -fsanitize-address-zero-based-shadow option on Linux
llvm-svn: 173146
2013-01-22 10:45:20 +00:00
Alexander Potapenko 0c92557fcb [ASan] Fix the path to ASan interface in interface_symbols_linux.c
llvm-svn: 173140
2013-01-22 10:13:37 +00:00
Alexander Potapenko 5ef0f677ae [ASan] Moved interface_symbols.c to lit_tests/Linux.
We already have Darwin-specific version of this test.

llvm-svn: 173136
2013-01-22 09:22:10 +00:00
Alexander Potapenko cae42d23a6 [ASan] Use dylib interposition to hook memory allocation in the dynamic runtime.
This CL drastically simplifies the way we're hooking the memory allocation routines in ASan on Mac by using dylib interposition to replace the main malloc_zone_* functions. This allows us to avoid replacing the default CFAllocator and drop the CF dependency at all.

Committing this patch will result in the static runtime being broken. A follow-up CL will switch ASan to use the dynamic runtime library.

llvm-svn: 173134
2013-01-22 09:14:54 +00:00
Alexey Samsonov 3292fde911 Temporary disable test added in r172828 as it seems to be flaky on the buildbots
llvm-svn: 172976
2013-01-20 13:41:26 +00:00
Alexander Potapenko b4ba995366 [ASan] Fix the log_path option to use different log files for parent and child processes after fork().
llvm-svn: 172828
2013-01-18 16:44:27 +00:00
Alexey Samsonov f96bfd8849 Make ASan and TSan tests a bit less brittle with @LINE FileCheck macro
llvm-svn: 171181
2012-12-28 08:38:09 +00:00
Alexey Samsonov c20f5d2246 Define COMPILER_RT_CAN_EXECUTE_TESTS variable on platforms where we can produce working binaries and use it in build rules for sanitizers tests
llvm-svn: 171160
2012-12-27 13:19:23 +00:00
Kostya Serebryany 4a0d946a43 [asan] relax asan/lit_tests/malloc_delete_mismatch.cc to make it pass on Mac 10.7 (where extra frames creep in between malloc and main)
llvm-svn: 171145
2012-12-27 07:40:24 +00:00
Alexey Samsonov d66b12b701 [ASan] Teach ASan to print demangled function name when describing stack frame
llvm-svn: 171112
2012-12-26 14:44:46 +00:00
Alexander Potapenko 47a03a2ebe [ASan] Fix another FileCheck pattern to be c++filt-proof.
llvm-svn: 170878
2012-12-21 10:48:30 +00:00
Kostya Serebryany 3674c6b13b [asan] add a flag alloc_dealloc_mismatch (off by default for now) which finds malloc/delete, new/free, new/delete[], etc mismatches
llvm-svn: 170869
2012-12-21 08:53:59 +00:00
Alexander Potapenko 5e9e51874e [ASan] Make the FileCheck pattern more c++filt-resistant.
This test didn't pass for me locally because of "T0's stack" being converted to "T0'short stack" by c++filt.
Strange enough this doesn't show up on our bots.

llvm-svn: 170690
2012-12-20 13:17:49 +00:00
Kostya Serebryany bb69879d09 [asan] pop the internal stack frames in SlowUnwindStack, extend the test to check this
llvm-svn: 170124
2012-12-13 12:31:55 +00:00
Kostya Serebryany 704c1cb23a [asan] extend overflow-in-qsort.cc to check both unwind kinds. One more test for SlowUnwind. Move both to Linux dir (no slow unwind on Mac)
llvm-svn: 170122
2012-12-13 11:47:49 +00:00
Alexey Samsonov 78ba6c1b37 [ASan] Allow leading underscore in function name to please output tests on Mac
llvm-svn: 170121
2012-12-13 11:11:28 +00:00
Kostya Serebryany ad81738822 [asan] add asan/lit_tests/overflow-in-qsort.cc (not fully working yet)
llvm-svn: 170111
2012-12-13 08:05:03 +00:00
Alexey Samsonov f0e638c6df ASan: fix interface-symbols test on Mac by explicitly listing all weak functions
llvm-svn: 169660
2012-12-08 01:12:12 +00:00
Alexey Samsonov 5aa36def74 ASan: use new option -fsanitize-blacklist in output tests
llvm-svn: 169646
2012-12-07 22:21:21 +00:00
Alexey Samsonov a0e4706fe6 ASan: change the strategy we use for installing malloc/free/symbolization 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.
llvm-svn: 169641
2012-12-07 22:01:28 +00:00
Alexey Samsonov 45b6edbd1d ASan: add new interface functions - __asan_(un)poison_stack_memory. Calls to these functions are inserted by the instrumentation pass in use-after-scope mode
llvm-svn: 169201
2012-12-04 01:38:15 +00:00
Alexey Samsonov b90501d7da [ASan] use brand new -fsanitize= values for init-order/use-after-return ASan output tests
llvm-svn: 168951
2012-11-29 22:56:01 +00:00
Alexey Samsonov 1a05424ee0 [ASan] move swapcontext_test to Linux-specific tests
llvm-svn: 168513
2012-11-23 11:20:54 +00:00
Alexey Samsonov 0d7755ccb5 [ASan] Add interceptor for swapcontext to fight with false positives in some of its use cases.
llvm-svn: 168508
2012-11-23 09:46:34 +00:00