Kostya Serebryany
f694ab1f18
[asan] provide better reports for cases where memcpy/etc get negative size parameter. Also fix a typo found by Tetsuo Kiso
...
llvm-svn: 206158
2014-04-14 09:50:52 +00:00
Alexander Potapenko
7caa0b9e36
[ASan] Fix a thinko spotted by Evgeniy Stepanov: use REAL(memcpy) on non-OSX systems.
...
llvm-svn: 204794
2014-03-26 11:18:25 +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
Evgeniy Stepanov
f79669a323
[asan] Enable signal and sigaction interceptors on Android.
...
Fixes AddressSanitizer.SignalTest breakage.
llvm-svn: 201330
2014-02-13 14:33:24 +00:00
Kostya Serebryany
9ebd483017
[sanitizer] hide two functions in the __sanitizer namespace to avoid exporting them (gold complained)
...
llvm-svn: 200844
2014-02-05 15:06:32 +00:00
Alexander Potapenko
789e3e1b7c
[ASan] Move the SIGSEGV/SIGBUS handling to sanitizer_common
...
This change is a part of refactoring intended to have common signal handling behavior in all tools.
This particular CL moves InstallSignalHandlers() into sanitizer_common (making it InstallDeadlySignalHandlers()), but doesn't enable default signal handlers for any tool other than ASan.
llvm-svn: 200542
2014-01-31 13:10:07 +00:00
Alexander Potapenko
cf4bef3161
[ASan] Move the signal handling-related flags to sanitizer_common.
...
This change is a part of refactoring intended to have common signal handling behavior in all tools.
llvm-svn: 200295
2014-01-28 09:28:57 +00:00
Evgeniy Stepanov
364bfdf4c9
[asan] Fix a bunch of style issues.
...
llvm-svn: 199380
2014-01-16 13:17:13 +00:00
Evgeniy Stepanov
c61623b170
[asan] Implement delayed activation of AddressSanitizer
...
This change adds ASAN_OPTIONS=start_deactivated=1 flag. When present, ASan will
start in "deactivated" mode, with no heap poisoning, no quarantine, no stack
trace gathering, and minimal redzones. All this features come back when
__asan_init is called for the constructor of an instrumented library.
The primary use case for this feature is Android. Code itself is not
Android-specific, and this patch includes a Linux test for it.
llvm-svn: 199377
2014-01-16 12:31:50 +00:00
Alexander Potapenko
c87794d055
[ASan] Delete asan_intercepted_functions.h, move the code into asan_interceptors.h
...
Fixes https://code.google.com/p/address-sanitizer/issues/detail?id=188 .
llvm-svn: 198048
2013-12-26 15:34:31 +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
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
Dmitry Vyukov
2e7e5801a7
asan: disable pthread_setname_np interceptor
...
it does not work anyway and can cause significant slowdown
llvm-svn: 194711
2013-11-14 16:48:22 +00:00
Alexander Potapenko
fa82ba91f9
[ASan] Don't call __asan_init() from certain interceptors on Darwin.
...
Fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58994 , which hadn't
manifested in LLVM because libclang_rt.asan_osx_dynamic.dylib used to depend on
the Foundation framework.
Without that dependency some interceptors may be called from the system
libraries before libSystem_initializer() is called, which lead to assertion
failures in sanitizer_mac.cc (_NSGetEnviron() returns NULL).
To fix the problem we fall back to the original functions in the common
libsanitizer interceptors and the __cxa_atexit() interceptor on Darwin.
This patch also prints a better error message in the case _NSGetEnviron()
returns NULL.
llvm-svn: 194573
2013-11-13 13:34:53 +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
987f59b5c3
[asan] Bypass pthread_attr_getdetachstate interceptor in compiler_rt code.
...
llvm-svn: 194369
2013-11-11 08:56:49 +00:00
Evgeniy Stepanov
7d24620b6d
[asan] Fix build.
...
llvm-svn: 193635
2013-10-29 18:29:39 +00:00
Evgeniy Stepanov
02839ced75
[sanitizer] Fix build warnings.
...
llvm-svn: 193634
2013-10-29 18:24:06 +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
Evgeniy Stepanov
c2b6cb0747
[sanitizer] Intercept pthread_attr_get*.
...
llvm-svn: 193405
2013-10-25 13:01:31 +00:00
Dmitry Vyukov
52ca74ec61
tsan: move verbosity flag to CommonFlags
...
llvm-svn: 192701
2013-10-15 13:28:51 +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
Alexander Potapenko
6c49695e7a
[ASan] Remove a complex multiline comment that baffles lint.
...
That comment is repeated in another function below.
llvm-svn: 191085
2013-09-20 11:33:14 +00:00
Alexander Potapenko
7be1a632b2
[ASan] Enforce the memmove semantics for both memcpy() and memmove() interceptors on Darwin.
...
Due to bugs in the interposition of resolver functions on 10.7 and 10.8 both memcpy() and memmove()
were previously intercepted by INTERCEPTOR(memcpy), which led to false positives and crashes (see http://llvm.org/bugs/show_bug.cgi?id=16362 )
We choose to use a memmove-like function in both cases. This effectively disables the overlap checks in memcpy(), but the overlaps
aren't possible in practice, because memcpy() and memmove() are the same function on Darwin.
Once the interposition is fixed in 10.9, we'll need to revisit this issue, see https://code.google.com/p/address-sanitizer/issues/detail?id=226
llvm-svn: 191081
2013-09-20 10:56:34 +00:00
Reid Kleckner
0071525492
asan: Add a wcslen interceptor mirroring strlen
...
Tested on Linux, since I can't build the tests on Windows yet.
llvm-svn: 190022
2013-09-05 01:13:49 +00:00
Evgeniy Stepanov
64cace0687
[sanitizer] Intercept poll/ppoll.
...
llvm-svn: 188177
2013-08-12 13:19:53 +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
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
8495b84076
[asan] Fix windows build.
...
llvm-svn: 185917
2013-07-09 09:29:19 +00:00
Sergey Matveev
bdeff959a1
[lsan] Handle fork() correctly.
...
Update the main thread's os_id on every pthread_create, and before
initiating leak checking. This ensures that we have the correct os_id even if we
have forked after Init().
llvm-svn: 185815
2013-07-08 12:57:24 +00:00
Alexey Samsonov
4798a08df8
[ASan] try to fix Windows build
...
llvm-svn: 185345
2013-07-01 16:38:38 +00:00
Alexey Samsonov
9857ca2564
[ASan] Properly disable strict init-order checking when pthread_create is called
...
llvm-svn: 185342
2013-07-01 16:16:41 +00:00
Alexey Samsonov
8918140809
Hide mlock/munlock info message under verbosity flag.
...
llvm-svn: 185314
2013-07-01 08:25:29 +00:00
Evgeniy Stepanov
dec0f76c14
[sanitizer] Intercept ptrace.
...
llvm-svn: 185142
2013-06-28 11:02:43 +00:00
Alexey Samsonov
a9db3f9757
[ASan] reimplement strdup() interceptor to get nicer stack traces for memory chunks allocated there
...
llvm-svn: 184546
2013-06-21 14:41:59 +00:00
Alexander Potapenko
29b9fcf0a8
[ASan] Delete excessive 'extern "C"' around mlock* interceptors.
...
llvm-svn: 184294
2013-06-19 11:36:51 +00:00
Alexey Samsonov
f67191b4c3
[ASan] mark ioctl test as xfailing on darwin. remove redundant semicolons
...
llvm-svn: 183655
2013-06-10 14:17:08 +00:00
Alexander Potapenko
6af3fce55e
[ASan] An early return from InitializeAsanInterceptors() on Mac has been considered unobvious.
...
Remove it and replace ASAN_INTERCEPT_FUNC with a no-op if SANITIZER_MAC==1.
llvm-svn: 183524
2013-06-07 15:10:02 +00:00
Timur Iskhodzhanov
013da5cb37
Replaced 'bool .* = 0;' with '... = false;'
...
llvm-svn: 182868
2013-05-29 17:26:25 +00:00
Timur Iskhodzhanov
cc61eefd4b
Fix MSVC W3 compiler warnings
...
llvm-svn: 182857
2013-05-29 14:11:44 +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
Alexey Samsonov
646ec67e25
Disable init-order checking before destructors are run.
...
We don't want to report initialization-order bugs when a destructor of a global
variable accesses dynamically initialized global from another
(not necessarily initialized) module. We do this by intercepting __cxa_atexit and
registrering our own callback that unpoisons shadow for all dynamically initialized
global variables.
llvm-svn: 182637
2013-05-24 11:46:56 +00:00
Alexey Samsonov
5c38383205
[ASan] Add allow_user_segv_handler to let users override SEGV handler installed by ASan
...
llvm-svn: 180255
2013-04-25 10:52:15 +00:00
Alexey Samsonov
bcd32a9525
[ASan] Disable strict-init-order checker once we have more than one thread, as this mode is thread-hostile
...
llvm-svn: 180106
2013-04-23 13:57:35 +00:00
Evgeniy Stepanov
755eb32a39
[sanitizer] Add syscall handlers to ASan and TSan runtimes.
...
ASan checks addressability of syscall arguments. TSan does nothing for now.
llvm-svn: 179380
2013-04-12 14:57:03 +00:00
Evgeniy Stepanov
460067823b
[sanitizer] Interceptors for wait*.
...
llvm-svn: 179096
2013-04-09 14:34:59 +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