Commit Graph

1557 Commits

Author SHA1 Message Date
Kostya Serebryany c9855da6d9 [asan] the run-time part of intra-object-overflow detector (-fsanitize-address-field-padding=1). Note that all of this is still experimental; don't use unless you are brave.
llvm-svn: 220013
2014-10-17 01:22:37 +00:00
Kuba Brecka 14c0c5901d [compiler-rt] compiler-rt's CMake append_if function clashes with LLVM's, let's rename it to append_list_if
Doing s/append_if/append_list_if/, no functional change.

http://reviews.llvm.org/D5739

llvm-svn: 219860
2014-10-15 22:47:54 +00:00
Will Schmidt a286594237 [compiler-rt] Enable ASAN for powerpc64le-linux
Whitespace update for lint check by myself (Will).  Otherwise code and comments by Peter Bergner, as previously seen on llvm-commits. 

    The following patch gets ASAN somewhat working on powerpc64le-linux.
    It currently assumes the LE kernel uses 46-bit addressing, which is
    true, but it doesn't solve the case for BE where it may be 44 or
    46 bits.  That can be fixed with a follow on patch.
    
    There are some test suite fails even with this patch that I haven't had
    time to solve yet, but this is better than the state it is in now.
    The limited debugging of those test suite fails seems to show that the
    address map for 46-bit addressing has changed and so we'll need to
    modify the shadow memory location slightly.  Again, that can be fixed
    with a follow on patch.

llvm-svn: 219827
2014-10-15 18:34:04 +00:00
Renato Golin 8fcae0b35e Fix silly commit to disable test on ARM
llvm-svn: 219681
2014-10-14 12:32:47 +00:00
Renato Golin 3743568735 Disable failing ASAN LongJump test on ARM
Updated the URL to reflect information on the problem as well as build the
case for ARM. This seems to be a wider problem, not ARM or PPC specific.

llvm-svn: 219680
2014-10-14 12:24:28 +00:00
Evgeniy Stepanov f518a4e774 [asan] Add fast_unwind_on_check flag.
Allows to specify the unwinder to use for CHECK failures. Previous behaviour
was to use the "fatal" unwinder.
As compiler-rt is built without frame pointers, only the slow unwinder
really makes sense here, and it is the default.

llvm-svn: 219677
2014-10-14 09:36:24 +00:00
Evgeniy Stepanov faef77480d [asan] Minor tweak to asan_device_setup.
Add another wait-for-device which may fix a flaky setup error.
Fix output message.

llvm-svn: 219117
2014-10-06 12:45:39 +00:00
Evgeniy Stepanov 0b9109c803 [asan] Support Android/x86 in asan_device_setup.
llvm-svn: 218968
2014-10-03 08:57:11 +00:00
Alexey Samsonov 1b42bde30d [ASan] Don't use large stack buffer for local variable name in stack frame description
llvm-svn: 218827
2014-10-01 21:28:54 +00:00
Alexey Samsonov 0470e24780 [ASan] Make stack-buffer-overflow reports more robust
Summary:
Fix the function that gets stack frame description by address in
thread stack, so that it clearly indicates failures. Make this error non-fatal,
and print as much information as we can in this case. Make all errors in
ParseFrameDescription non-fatal.

Test Plan: check-asan testsuite

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5554

llvm-svn: 218819
2014-10-01 21:13:00 +00:00
Evgeniy Stepanov 0f7ab59adc [sanitizer] Add i686 arch to compiler-rt.
This is needed so we can produce -i686- named libraries for
x86 Android (which is i686-linux-android).

An alternative solution would be keeping the "i386" name internally and
tweaking the OUTPUT_NAME of compiler-rt libraries.

llvm-svn: 218761
2014-10-01 12:55:06 +00:00
Kostya Serebryany da9d495d03 [asan] add a test for array cookie if the operator new is defined inside the class (the cookie should not be poisoned in such case); update the related comment in asan_poisoning.cc
llvm-svn: 218620
2014-09-29 19:40:56 +00:00
Evgeniy Stepanov 9e922e7d24 [sanitizer] Android build cleanup.
* Detect Android toolchain target arch and set correct runtime library name.
* Merged a lot of Android and non-Android code paths.
* Android is only supported in standalone build of compiler-rt now.
* Linking lsan-common in ASan-Android (makes lsan annotations work).
* Relying on -fsanitize=address linker flag when building tests (again,
  unification with non-Android path).
* Runtime library moved from lib/asan to lib/linux.

llvm-svn: 218605
2014-09-29 13:18:55 +00:00
Evgeniy Stepanov 3f11c0d79c [asan] Fix SELinux setup on Android-K.
On pre-L devices SELinux is set up in such a way that zygote wrapper
has to be in system_file context, not zygote_exec.

llvm-svn: 218599
2014-09-29 09:48:13 +00:00
Kuba Brecka 7e38e429b7 [compiler-rt] recommit of r218481: ASan debugging API for report info extraction and locating addresses
Reviewed at http://reviews.llvm.org/D4527

Fixed a test case failure on 32-bit Linux, I did right shift on intptr_t, instead it should have been uintptr_t.

llvm-svn: 218538
2014-09-26 19:15:32 +00:00
Kuba Brecka db22cd1721 [compiler-rt] revert r218481 due to test failure on sanitizer-x86_64-linux
llvm-svn: 218501
2014-09-26 05:25:37 +00:00
Kuba Brecka e37e089b66 [compiler-rt] ASan debugging API for report info extraction and locating addresses
Reviewed at http://reviews.llvm.org/D4527

This patch is part of an effort to implement a more generic debugging API, as proposed in http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-July/074656.html, with first part reviewed at http://reviews.llvm.org/D4466. Now adding several new APIs: __asan_report_present, __asan_get_report_{pc,bp,sp,address,type,size,description}, __asan_locate_address. These return whether an asan report happened yet, the PC, BP, SP, address, access type (read/write), access size and bug description (e.g. "heap-use-after-free"), __asan_locate_address takes a pointer and tries to locate it, i.e. say whether it is a heap pointer, a global or a stack, or whether it's a pointer into the shadow memory. If global or stack, tries to also return the variable name, address and size. If heap, tries to return the chunk address and size. Generally these should serve as an alternative to "asan_describe_address", which only returns all the data in text form. Having an API to get these data could allow having debugging scripts/extensions that could show additional information about a variable/expression/pointer. Test cases in test/asan/TestCases/debug_locate.cc and test/asan/TestCasea/debug_report.cc.

llvm-svn: 218481
2014-09-25 23:53:57 +00:00
Evgeniy Stepanov c07dc68852 [asan] Fix one test on Android-L.
index() is deprecated.

llvm-svn: 218312
2014-09-23 15:42:04 +00:00
Alexander Potapenko 1aba330e52 [ASan] Introduce the dump_instruction_bytes flag to print the faulting instruction upon SIGSEGV
When dump_instruction_bytes=1 and the instruction pointer doesn't point to the zero page, ASan prints 16 bytes starting at the instruction point.

llvm-svn: 218243
2014-09-22 11:58:52 +00:00
Evgeniy Stepanov a5d07482d9 [asan] asan_device_setup improvements.
* Allow user SEGV handler if Android-L-like setup is detected.
  Necessary for correctness.
* Change file context labels on the wrapper script to appease SELinux.

llvm-svn: 218124
2014-09-19 15:04:44 +00:00
Alexander Potapenko 53b85c25e0 [ASan] Print a hint when the program crashes accessing the zero page.
This may help some users figure out that the error report is valid.

llvm-svn: 218123
2014-09-19 12:37:00 +00:00
Sergey Matveev 756afb2f82 [asan] Initialize logfile in asan_symbolize.py to sys.stdin.
llvm-svn: 218072
2014-09-18 20:01:28 +00:00
Sergey Matveev 4588de1c22 [asan] Fix a bug in asan_symbolize.py
Do not forget to add newlines between multiple symbolized lines corresponding to
a single input line (i.e. inlining).

llvm-svn: 218071
2014-09-18 19:16:44 +00:00
Evgeniy Stepanov bc496dab07 [asan] Delay system log initialization on Android.
Writing to system log requires libc interceptors to be initialized.
Fixes crashes with verbosity=1 on newer Android builds.

llvm-svn: 217764
2014-09-15 11:37:40 +00:00
Ehsan Akhgari c4f23419bb Avoid calling strtoll and atoll in asan_str_test.cc on Windows for now
Summary:
These two functions are unavailable on MSVC2012, which breaks building the
ASAN tests with MSVC2012.  Since the tests required to run these functions
are disabled on Windows for now, avoid building them to fix the MSVC2012
builds.

Test Plan: This is needed in order to fix building the ASAN tests with MSVC2012.

Reviewers: timurrrr

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5343

llvm-svn: 217763
2014-09-15 11:34:12 +00:00
Timur Iskhodzhanov 651725e191 [ASan/Win] Fix PR20918 -- SEH handler doesn't work with the MD runtime
llvm-svn: 217679
2014-09-12 14:01:30 +00:00
Timur Iskhodzhanov 92c0601d27 [ASan/Win] Rename asan_win_uar_thunk.lib to asan_win_dynamic_runtime_thunk.lib
It turned out that we have to bridge more stuff between the executable
and the ASan RTL DLL than just __asan_option_detect_stack_use_after_return.
See PR20918 for more details.

llvm-svn: 217673
2014-09-12 13:21:02 +00:00
Evgeniy Stepanov e579c76bd5 [asan] Preserve existing LD_PRELOAD setting on Android.
llvm-svn: 217584
2014-09-11 12:20:29 +00:00
Alexey Samsonov 611c906cb3 [Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().
We may as well just use Symbolizer::GetOrInit() in all the cases.
Don't call Symbolizer::Get() early in tools initialization: these days
it doesn't do any important setup work, and we may as well create the
symbolizer the first time it's actually needed.

llvm-svn: 217558
2014-09-10 22:45:09 +00:00
Kostya Serebryany 1fb81720ec [asan] relax the assertion around array cookie load; still need to extract a reproducer where this assertion fails...
llvm-svn: 217215
2014-09-05 01:16:30 +00:00
Alexey Samsonov f537aeaea1 [ASan] Remove the call to GetPageSizeCached from fast path of FastPoisonShadow
llvm-svn: 217194
2014-09-04 20:47:27 +00:00
Evgeniy Stepanov 21202ba8dd [asan] Update asan_device_setup to support Android L Preview.
llvm-svn: 216884
2014-09-01 15:37:50 +00:00
Kostya Serebryany c148f7c3af [asan] enable poison_array_cookie back
llvm-svn: 216705
2014-08-29 01:16:18 +00:00
Kostya Serebryany ac77055272 [asan] introduce __asan_load_cxx_array_cookie: check that the array cookie address is properly poisoned and return the cookie value. If not, return 0 to avoid infinite loop of DTORs (in case of use-after-free). Calls to this function will be inserted by clang (separate change)
llvm-svn: 216692
2014-08-28 22:28:04 +00:00
Kostya Serebryany 1e3b338606 [asan] disable poison_array_cookie while I am investigating a false positive on chromium (I suspect that LLVM looses nosanitizer metadata; no test yet)
llvm-svn: 216684
2014-08-28 20:24:05 +00:00
Timur Iskhodzhanov 737370da20 [ASan/Win] Add the -Zl flag to avoid /DEFAULTLIB:libcmt directive in the asan_win_uar_thunk object file
This directive results in 'symbol already defined' when linking DLLs that use -MD

llvm-svn: 216663
2014-08-28 12:28:04 +00:00
Alexander Potapenko 83061238d4 [ASan] Whitespace fix. No functionality change.
llvm-svn: 216544
2014-08-27 13:43:18 +00:00
Evgeniy Stepanov 8f4e736080 [asan] Restore asan-rt name on linux back to pre-r216380.
There is no reason to have different library names for shared and static
cases on linux. It also breaks Android where we install the shared asan-rt
library into the system and should keep the old name.

This change reverts most of r216380 limiting it to win32 targets only.

llvm-svn: 216533
2014-08-27 09:46:54 +00:00
Timur Iskhodzhanov 81885731a8 [ASan/Win] Rename asan_dll_thunk.cc to asan_win_dll_thunk.cc
llvm-svn: 216448
2014-08-26 10:21:37 +00:00
Timur Iskhodzhanov 6903e10ddf [ASan/Win] Add an extra thunk.lib to handle stack-use-after-return option
With this patch, "check-asan" passes all the tests with both MT and MD ASan RTL if you set COMPILER_RT_BUILD_SHARED_ASAN to ON
(PR20214)

llvm-svn: 216447
2014-08-26 10:08:24 +00:00
Kostya Serebryany 74bd6bc9f9 [sanitizer] move mlock interceptor from asan/tsan/msan to common; no functionality change intended
llvm-svn: 216407
2014-08-25 20:57:59 +00:00
Timur Iskhodzhanov dc8caada51 [ASan/Win] Add /DEBUG to the MD RTL link flags
llvm-svn: 216387
2014-08-25 16:45:53 +00:00
Timur Iskhodzhanov 2311f4dfaa [ASan] Replace CMake if/APPEND/endif with append_if
llvm-svn: 216386
2014-08-25 16:40:39 +00:00
Timur Iskhodzhanov 0a88b25c43 [ASan/Win] Intercept memory allocation functions in the MD CRT
llvm-svn: 216382
2014-08-25 13:19:05 +00:00
Timur Iskhodzhanov ea3ce790dc [ASan] Rename the ASan dynamic RT
Reviewed at http://reviews.llvm.org/D5026

llvm-svn: 216380
2014-08-25 11:44:06 +00:00
Timur Iskhodzhanov 220ddacf8d [ASan/Win] Land the trivial bits of -MD RTL support (PR20214)
llvm-svn: 216265
2014-08-22 12:38:07 +00:00
Timur Iskhodzhanov f2d24473fe [ASan] Use check_library_exists to determine if libc/libstdc++ are available
llvm-svn: 216264
2014-08-22 12:26:34 +00:00
Alexander Potapenko 373863d31e Follow-up for r215436: use SIZE_T for strlen and wcslen interceptors.
llvm-svn: 216184
2014-08-21 16:12:46 +00:00
Timur Iskhodzhanov a14ef30443 [ASan] Turns out we should always intercept __cxa_throw
At least check-asan works with this change.

If the change breaks anything, we'll need to add:
a) a comment describing why we have to use INTERCEPT_FUNCTION rather than
   ASAN_INTERCEPT_FUNC
and
b) a test case.

llvm-svn: 216177
2014-08-21 13:33:39 +00:00
Alexey Samsonov 2e39027931 [LSan] Parse common flags from LSAN_OPTIONS even if LSan is combined with
another sanitizer.

A user may run both LSan and LSan+ASan. It is weird to pass path to leak
suppression file (or other common sanitizer flags, like "verbosity") in
"LSAN_OPTIONS" in the first case and in "ASAN_OPTIONS" in the second case.

llvm-svn: 215949
2014-08-18 23:39:47 +00:00