Commit Graph

118 Commits

Author SHA1 Message Date
Alexey Samsonov 21cb74318c [ASan] Kill the remainders of platform defines in favor of SANITIZER_ defines
llvm-svn: 178629
2013-04-03 07:29:53 +00:00
Alexey Samsonov a88c60b085 [ASan] Speed-up initialization-order checking: create and use fast versions of PoisonShadow functions, store copies of __asan_global descriptors in a vector instead of list of pointers. This gives 3x speedup on both benchmarks and real binaries with lots of globals.
llvm-svn: 178239
2013-03-28 15:42:43 +00:00
Evgeniy Stepanov 95eaa21637 [sanitizer] More renamed macros.
llvm-svn: 177401
2013-03-19 14:54:17 +00:00
Evgeniy Stepanov d3b56605f1 [sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.
llvm-svn: 177397
2013-03-19 13:54:41 +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 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
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 4f1885a109 [ASan] minor changes to swapcontext handling: don't clear shadow memory if context stack is too large
llvm-svn: 172727
2013-01-17 15:45:28 +00:00
Kostya Serebryany 181f504d82 [asan] properly define ASAN_LOW_MEMORY. Due to a mistake it has been always true causing redzone and quarantine sizes to be smaller than it was some time before (and out of sync with the documentation). Also make one test less greedy
llvm-svn: 171052
2012-12-25 07:17:17 +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 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
Alexander Potapenko bcc00a4174 [ASan] Revert r168040 and r168043 and take a cleaner solution suggested by Kostya: return the known frame name for fake stack instead of looking it up.
llvm-svn: 168046
2012-11-15 15:24:42 +00:00
Alexander Potapenko b34db9e883 [ASan] Poison the leftmost shadow byte with a special value so that we can find
the beginning of the fake frame when reporting an use-after-return error.
Fixes http://code.google.com/p/address-sanitizer/issues/detail?id=126

llvm-svn: 168040
2012-11-15 13:40:44 +00:00
Alexander Potapenko 0f0a50da56 Set ASAN_NEEDS_SEGV=0 on Android only.
llvm-svn: 165120
2012-10-03 15:09:17 +00:00
Alexey Samsonov e29c6731aa [Sanitizer/ASan] Simplify the code that prints and symbolizes stack traces. Fall back to module+offset if user-provided symbolizer failed. Use weak function __asan_symbolize instead of __asan_set_symbolize_callback in ASan interface, so that we're able to symbolize reports for errors that happen before the main() is called, for example, during module initialization.
llvm-svn: 165000
2012-10-02 12:11:17 +00:00
Evgeniy Stepanov 9792396a06 [asan] Change defaults for Android target.
This way building without -DASAN_* in CFLAGS produces working binaries.

llvm-svn: 164816
2012-09-28 10:07:53 +00:00
Kostya Serebryany 66a37f3aef [asan] one more fix for windows build
llvm-svn: 162762
2012-08-28 15:25:07 +00:00
Kostya Serebryany 7575968aa4 [asan] actually move StackTrace to sanitizer_common
llvm-svn: 162757
2012-08-28 14:11:57 +00:00
Kostya Serebryany 6b0d775229 [asan] some renaming before we move StackTrace into sanitizer_common
llvm-svn: 162747
2012-08-28 11:54:30 +00:00
Kostya Serebryany bb6f165952 [asan] get rid of AsanPrintf in favor of Printf from sanitizer_common
llvm-svn: 162746
2012-08-28 11:34:40 +00:00
Evgeniy Stepanov be01398612 A few tweaks for building ASanRT against Android NDK.
llvm-svn: 162666
2012-08-27 11:15:55 +00:00
Alexey Samsonov dc8d1f1039 [Sanitizer] move low-level (mmap-based) allocator to sanitizer_common
llvm-svn: 162663
2012-08-27 09:30:58 +00:00
Alexander Potapenko fefc1e989c If the program is linked to a dynamic ASan runtime which is not present in DYLD_INSERT_LIBRARIES
(which, in turn, is required for our interceptors to take effect), re-exec the program with
DYLD_INSERT_LIBRARIES set.

llvm-svn: 162547
2012-08-24 09:22:05 +00:00
Alexey Samsonov a85b6b8154 [ASan] get rid of ASAN_USE_EXTERNAL_SYMBOLIZER compiler def in favor of __asan_set_symbolize_callback interface function. Now the user doesn't have to recompile ASan runtime to provide its own symbolizer
llvm-svn: 162358
2012-08-22 13:31:37 +00:00
Kostya Serebryany 676bcdb838 [asan] run-time part of the initialization order checker. Patch by Reid Watson with some bits from kcc. The sub-pass is off by default for now. On simple tests it works fine.
llvm-svn: 162278
2012-08-21 14:10:25 +00:00
Alexey Samsonov 4ce12349d6 [ASan] move some functions that describe addresses to asan_report.cc
llvm-svn: 161571
2012-08-09 09:06:52 +00:00
Alexander Potapenko 51e6488b31 Intercept CFAllocator for each thread in the program.
Test that child threads use the ASan allocator, that allocated memory can be passed to another thread and deallocated on it.
This should fix http://code.google.com/p/address-sanitizer/issues/detail?id=81

llvm-svn: 160630
2012-07-23 14:07:58 +00:00
Alexey Samsonov 9f666ea6ca [ASan] move flags description to separate header, add comments about them.
llvm-svn: 159985
2012-07-10 07:41:27 +00:00
Alexey Samsonov 2467ca5010 [ASan] cleanup: remove dead flag
llvm-svn: 159934
2012-07-09 15:11:28 +00:00
Alexey Samsonov 34efb8e9b9 [ASan] Use common flags parsing machinery.
llvm-svn: 159933
2012-07-09 14:36:04 +00:00
Alexander Potapenko 1bde28b464 Factor the common code out of cf_free and mz_free.
Introduce the mac_ignore_invalid_free flag (0 by default) which makes both cf_free and mz_free ignore invalid free invocations and leak memory.

llvm-svn: 158885
2012-06-21 01:01:20 +00:00
Alexey Samsonov 156958dd0c [Sanitizer] move all the rest re-implementations of libc functions from ASan runtime to common sanitizer runtime
llvm-svn: 158519
2012-06-15 13:09:52 +00:00
Alexey Samsonov 40e5128412 [Sanitizer] move ShadowRangeIsAvailable and several defines to common runtime
llvm-svn: 158499
2012-06-15 07:29:14 +00:00
Alexey Samsonov e4a889866d [Sanitizer] move atomic ops, min/max and sort to commnon runtime
llvm-svn: 158496
2012-06-15 07:00:31 +00:00
Alexey Samsonov 70afb91636 [Sanitizer] move more portability wrappers to common runtime: sleep, _exit, abort, atexit, pthread_self
llvm-svn: 158493
2012-06-15 06:37:34 +00:00
Alexey Samsonov ae1e171b72 [Sanitizer] move DumpProcessMap and DisableCoreDumper to common runtime
llvm-svn: 158490
2012-06-15 06:08:19 +00:00
Alexey Samsonov c70d1086f6 [Sanitizer] move rest of mmap routines to common sanitizer runtime
llvm-svn: 158452
2012-06-14 14:42:58 +00:00
Alexey Samsonov 0c53a38abb [Sanitizer] move portable GetEnv to common sanitizer runtime
llvm-svn: 158451
2012-06-14 14:07:21 +00:00
Alexey Samsonov fe44fbd750 [Sanitizer] Move ReadFileToBuffer to sanitizer_common.
llvm-svn: 158138
2012-06-07 05:38:26 +00:00
Alexey Samsonov 40d5b772e5 [Sanitizer] Switch to common mmap/munmap routines in ASan run-time.
llvm-svn: 158078
2012-06-06 16:15:07 +00:00
Alexey Samsonov e95e29c2ac [Sanitizer] Make UNIMPLEMENTED macro common.
llvm-svn: 158077
2012-06-06 15:47:40 +00:00
Alexey Samsonov e428779dbf [Sanitizer] Use common CHECK machinery. Currently each tool has to define its own CheckFailed function.
llvm-svn: 158075
2012-06-06 15:22:20 +00:00
Kostya Serebryany 53b74ac256 [asan] start compacting the allocator header, the goal is to make it 16 bytes w/o losing any information
llvm-svn: 158072
2012-06-06 14:46:38 +00:00
Alexey Samsonov d323f4e78e [Sanitizer] Remove __attribute__((format))
llvm-svn: 158070
2012-06-06 13:58:39 +00:00
Alexey Samsonov 51ae983718 [Sanitizer]: Introduce a common internal printf function. For now, also use tool-specific wrappers TsanPrintf (its output is controlled by TSan flags) and AsanPrintf (which copies its results to the ASan-private buffer). Supported formats: %[z]{d,u,x}, %s, %p. Re-write all format strings in TSan according to this format (this should have no effect on 64-bit platforms).
llvm-svn: 158065
2012-06-06 13:11:29 +00:00
Alexey Samsonov ee07290628 [Sanitizer] Move more functions/constants to sanitizer_common.
llvm-svn: 158056
2012-06-06 09:26:25 +00:00
Alexey Samsonov c4b201308b [ASan] Use __sanitizer::Die() in ASan runtime.
llvm-svn: 158051
2012-06-06 07:02:44 +00:00
Alexey Samsonov 5bbf8290a7 [Sanitizer] rename sanitizer_defs.h to sanitizer_internal_defs.h
llvm-svn: 158001
2012-06-05 14:25:27 +00:00
Alexey Samsonov 8602c65719 [Sanitizer] remove using namespace __sanitizer lines
llvm-svn: 157999
2012-06-05 14:05:09 +00:00