Commit Graph

6097 Commits

Author SHA1 Message Date
Anna Zaks 7920eb0b1f Reapply: [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
        of the report to stderr. This patch changes this behavior and writes the full
        text of the report to syslog before we terminate the process. It also calls
        os_trace (Activity Tracing available on OS X and iOS) with a message saying
        that the report is available in syslog. This is useful, because this message
        will be shown in the crash log.

        For this to work, the patch makes sure we store the full report into
        error_message_buffer unconditionally, and it also strips out ANSI escape
        sequences from the report (they are used when producing colored reports).

        I've initially tried to log to syslog during printing, which is done on Android
        right now. The advantage is that if we crash during error reporting or the
        produced error does not go through ScopedInErrorReport, we would still get a
        (partial) message in the syslog. However, that solution is very problematic on
        OS X. One issue is that the logging routine uses GCD, which may spawn a new
        thread on its behalf. In many cases, the reporting logic locks threadRegistry,
        which leads to deadlocks.

        Reviewed at http://reviews.llvm.org/D13452

        (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid
         build failures on Linux.)

llvm-svn: 251577
2015-10-28 23:18:44 +00:00
Evgeniy Stepanov 2253d1c052 [asan] Fix asan_device_setup script on KitKat.
app_process32, when started via a shell script wrapper, needs a
different security context to satisty SELinux.

Patch by Abhishek Arya.

llvm-svn: 251572
2015-10-28 22:55:12 +00:00
Evgeniy Stepanov d10e6280cb [asan] Disable a flaky test on Android.
Bug: https://github.com/google/sanitizers/issues/618
llvm-svn: 251554
2015-10-28 20:45:52 +00:00
Ivan Krasin 1fe5fab905 sanitizer_common: be more verbose, when symbolizer is not found.
Summary:
I have othen been stuck when I got an ASAN report, but no symbols
are resolved. The reasons might be different, and it always 
requires a bit of detective work to track down.

These more verbose error messages will help the users like me.

Reviewers: samsonov

Subscribers: llvm-commits

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

llvm-svn: 251553
2015-10-28 20:45:34 +00:00
Anna Zaks 55fbb6d7f5 Revert "[asan] On OS X, log reports to syslog and os_trace"
This reverts commit 251447.

(Which caused failures on a Linux bot.)

llvm-svn: 251467
2015-10-27 23:15:05 +00:00
Daniel Sanders 6c583b8b25 [mips][asan] XFAIL ptrace.cc
It was recently enabled for non-x86 targets and doesn't seem to work for MIPS.
The reason is currently unclear so XFAILing while I investigate.

llvm-svn: 251466
2015-10-27 23:13:26 +00:00
Anna Zaks 9a95c9a633 [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
of the report to stderr. This patch changes this behavior and writes the full
text of the report to syslog before we terminate the process. It also calls
os_trace (Activity Tracing available on OS X and iOS) with a message saying
that the report is available in syslog. This is useful, because this message
will be shown in the crash log.

For this to work, the patch makes sure we store the full report into
error_message_buffer unconditionally, and it also strips out ANSI escape
sequences from the report (they are used when producing colored reports).

I've initially tried to log to syslog during printing, which is done on Android
right now. The advantage is that if we crash during error reporting or the
produced error does not go through ScopedInErrorReport, we would still get a
(partial) message in the syslog. However, that solution is very problematic on
OS X. One issue is that the logging routine uses GCD, which may spawn a new
thread on its behalf. In many cases, the reporting logic locks threadRegistry,
which leads to deadlocks.

Reviewed at http://reviews.llvm.org/D13452

llvm-svn: 251447
2015-10-27 20:13:01 +00:00
Anna Zaks 55f195f5ae [asan] Sort headers.
llvm-svn: 251446
2015-10-27 20:12:55 +00:00
Anna Zaks ab1aa08191 [asan] On OS X, tag mapped regions with VM_MEMORY_ANALYSIS_TOOL tag
This will tag all mmapped memory sanitizers use with "Performance tool data"
when viewed in vmmap. (Even though sanitizers are not performance tools, it's
the best available match and better than having the unidentified objects.)

http://reviews.llvm.org/D13609

llvm-svn: 251445
2015-10-27 20:12:53 +00:00
Daniel Sanders 171d6fa35d Attempt to fix asan's ptrace.cc on the clang-cmake-mips builder after r251331.
llvm-svn: 251379
2015-10-27 01:35:57 +00:00
Evgeniy Stepanov 12ffb42893 [msan] Yet another attempt to fix process_vm_readv test.
llvm-svn: 251372
2015-10-27 00:11:28 +00:00
Evgeniy Stepanov f0344626d2 [asan] Mark 5 tests unsupported on Android.
llvm-svn: 251362
2015-10-26 22:19:50 +00:00
Evgeniy Stepanov fb38728241 [asan] Fix throw-call-test to properly XFAIL on android/aarch64.
The test is sensitive to stack layout changes. Tweak it a bit to
expose the bug on aarch64 as well as on arm.

llvm-svn: 251361
2015-10-26 22:19:47 +00:00
Evgeniy Stepanov 798d4f0329 [asan] Switch back to BFD linker in asan/android tests.
We've switched to Gold earlier because of a minor misconfiguration
of the BFD linker in Android NDK. It turns out, Gold has much bigger
problems:

https://sourceware.org/bugzilla/show_bug.cgi?id=19163
(a bug is actually in the android runtime loader, but it means that
gold does not work with android L and even M).

Switching back to BFD and adding a workaround by explicitly linking
libm to all tests.

llvm-svn: 251360
2015-10-26 22:19:46 +00:00
Evgeniy Stepanov 9944209a0a [asan] Don't use asanwrapper in 64-bit android tests.
Asanwrapper is required on older android versions to work around undesired
linker behavior. It is not required on L and newer, and does not fully
support multiarch devices.

llvm-svn: 251359
2015-10-26 22:19:44 +00:00
Alexey Samsonov c6de580afe asan_symbolize.py: Call llvm-symbolizer with --functions=linkage instead of --functions=short.
llvm-svn: 251356
2015-10-26 21:48:49 +00:00
Evgeniy Stepanov 1a1973b846 [msan] Fix process_vm_readv test.
The check for the glibc version was not working as expected (dlsym
was finding the interceptor instead of the libc implementation).

llvm-svn: 251345
2015-10-26 20:55:35 +00:00
Adhemerval Zanella 6153ecc4fd [compiler-rt] Fix ptrace interceptor for aarch64
This patch fixes the ptrace interceptor for aarch64. The PTRACE_GETREGSET
ptrace syscall with with invalid memory might zero the iovec::iov_base
field and then masking the subsequent check after the syscall (since it
will be 0 and it will not trigger an invalid access). The fix is to copy
the value on a local variable and use its value on the checks.

The patch also adds more coverage on the Linux/ptrace.cc testcase by addding
check for PTRACE_GETREGSET for both general and floating registers (aarch64
definitions added only).

llvm-svn: 251331
2015-10-26 18:55:04 +00:00
Adhemerval Zanella 871d324799 [compiler-rt] Enable ptrace sanitizer for arm
This patch enables the ptrace syscall interceptors for arm and adds support
for both PTRACE_GETVFPREGS and PTRACE_SETVFPREGS used to get the VFP register
from ARM.

The ptrace tests is also updated with arm and PTRACE_GETVFPREGS tests.

llvm-svn: 251321
2015-10-26 18:15:14 +00:00
Hal Finkel 9f42bf047c Fixup test/ubsan/TestCases/Misc/coverage-levels.cc, LLVM is smarter
Fixing up this test case because LLVM is smarter now, and can better analyze:

  if ((argc << shift) == 16)

in this test case.

llvm-svn: 251147
2015-10-23 20:37:51 +00:00
Evgeniy Stepanov 1e9aadba17 [msan] Re-submit test for process_vm_readv.
Includes a workaround for glibc < 2.15, which does not provide the
function under test.

llvm-svn: 251079
2015-10-23 00:00:22 +00:00
Evgeniy Stepanov 7b04acd28d [msan] Temporarily remove a failing test to fix the bot.
The test requires a newer glibc version that the one on the bot.

llvm-svn: 251077
2015-10-22 23:40:06 +00:00
Kostya Serebryany e3d25c3873 [sanitizer-coverage] introduce __sanitizer_get_total_unique_caller_callee_pairs
llvm-svn: 251071
2015-10-22 22:06:41 +00:00
Evgeniy Stepanov 0d933e0b27 [msan] Intercept process_vm_readv/writev.
llvm-svn: 251059
2015-10-22 20:35:42 +00:00
Yury Gribov 8da1408277 [asan] Get rid of UB in string tests. Patch by Max Ostapenko.
Differential revision: http://reviews.llvm.org/D13895

llvm-svn: 250998
2015-10-22 08:10:56 +00:00
Evgeniy Stepanov 86713d90c7 [msan] Build unit test shared library code with -fPIC.
llvm-svn: 250957
2015-10-21 22:13:36 +00:00
Adhemerval Zanella b0d5dd0199 [lsan] [aarch64] Add support for AArch64
This patch add support for leak sanitizer for aarch64.  Similar to
MIPS it uses a SizeClassAllocator32 due VMA constraints (aarch64
currently supports 39 and 42-bit VMA).

It also fixes the android build issue.

llvm-svn: 250898
2015-10-21 13:08:06 +00:00
Ivan Krasin cffe8caed3 Disabling speculative loads under asan.
Summary:
While instrumenting std::string with asan I discovered that speculative load might load data from poisoned region. Disabling all speculative loads for asan-annotated functions.

The test follows the std::string implementation.

Corresponding CL in llvm: http://reviews.llvm.org/D13264
Patch by Mike Aizatsky, the review page for the CL is http://reviews.llvm.org/D13265

Reviewers: aizatsky

Subscribers: kcc, llvm-commits

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

llvm-svn: 250837
2015-10-20 17:34:47 +00:00
Angel Garcia Gomez ea61047c6f Apply modernize-use-default to compiler-rt.
Summary: Replace empty bodies of default constructors and destructors with '= default'.

Reviewers: klimek, bkramer

Subscribers: alexfh, cfe-commits

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

llvm-svn: 250823
2015-10-20 12:53:50 +00:00
Yury Gribov 34f4561220 [ubsan] Fix looksLikeFloatCastOverflowDataV1 heuristic to work if one of the types is unknown.
Differential revision: http://reviews.llvm.org/D13775

llvm-svn: 250806
2015-10-20 08:40:52 +00:00
Evgeniy Stepanov 0b98b27677 [msan] Intercept mincore.
llvm-svn: 250761
2015-10-19 23:39:11 +00:00
Evgeniy Stepanov cc25301092 [msan] Intercept pthread_getcancel*.
llvm-svn: 250752
2015-10-19 23:00:13 +00:00
Xinliang David Li d7134ead18 [PGO] Eliminate prof data register calls on FreeBSD platform
This is a follow up patch of r250199 after verifying the start/stop
section symbols work as spected on FreeBSD.

llvm-svn: 250680
2015-10-19 04:17:19 +00:00
Xinliang David Li 4da5de9c34 Use struct type instead of raw array for raw profile header (NFC)
This patch introduces a well defined header struct
to represent raw profile header instead of using raw array.
Previously the raw array is used in two different files and
is very error prone when header structure is re-organized.
This is a small cleanup with NFC.

llvm-svn: 250561
2015-10-16 22:21:56 +00:00
Saleem Abdulrasool b5bba5c256 builtins: Expand out floating point exponents for MSVC
MSVC 2013 doesnt support C99 fully, including the hexidecimal floating point
representation.  Use the expanded value to permit building with it.

Patch by Tee Hao Wei!

llvm-svn: 250365
2015-10-15 04:26:19 +00:00
Saleem Abdulrasool 9ca87a63ad builtins: use C implementation on MSVC
The assembly implementations use GNU syntax which MSVC doesn't handle.  Rather
than duplicate the code in a second syntax, use the C implementations.

Patch by Tee Hao Wei!

llvm-svn: 250360
2015-10-15 02:47:19 +00:00
Saleem Abdulrasool 956365ef7f builtins: __builtin_clzll for x86 on MSVC
Add an implementation for __builtin_clzll on MSVC even when _BitScanForward4 is
unavailable.

Patch by Tee Hao Wei!

llvm-svn: 250359
2015-10-15 02:46:37 +00:00
Xinliang David Li f556a7e3c3 [PGO]: Eliminate calls to __llvm_profile_register_function for Linux.
On Linux, the profile runtime can use __start_SECTNAME and __stop_SECTNAME
symbols defined by the linker to locate the start and end location of
a named section (with C name). This eliminates the need for instrumented
binary to call __llvm_profile_register_function during start-up time.

llvm-svn: 250200
2015-10-13 18:40:00 +00:00
Evgeniy Stepanov c7ee62c561 [msan] Add __msan_copy_shadow interface function.
This can be used to annotate copies of memory that are not observed by MSan.

llvm-svn: 250124
2015-10-12 23:20:24 +00:00
Evgeniy Stepanov f4ebc08831 [asan] Zero initialize sem_t in sem_init.
Old version of sem_init (GLIBC_2.0) fails to initialize parts of
sem_t that are used in sem_timedwait. This is fixed in GLIBC_2.1,
but since ASan interceptors downgrade sem_* to the oldest available
version, this can introduce bugs that are only present in sanitized
build. Workaround by zero-initializing sem_t in sem_init.

llvm-svn: 250113
2015-10-12 21:32:30 +00:00
Filipe Cabecinhas 150def9787 [ubsan] Invoke test program using %run.
llvm-svn: 250063
2015-10-12 16:33:40 +00:00
Saleem Abdulrasool 565872584b Revert "builtins: enable builtins build for MSVC"
Revert once more.  This seems to fail to build on the buildbots which build with
ninja rather than MSBuild/Visual Studio.  This requires further build
infrastructure changes to deal with the assembly routines.

llvm-svn: 250001
2015-10-11 22:30:10 +00:00
Saleem Abdulrasool 76e70699d5 Revert "Revert "builtins: enable builtins build for MSVC""
Previous changes should now permit building on MSVC 2013 in addition to MSVC
2015.

llvm-svn: 250000
2015-10-11 22:00:46 +00:00
Saleem Abdulrasool e49971517a builtins: define and use ALWAYS_INLINE
Abstract out the always inline spelling similar to ASAN.  NFC.

llvm-svn: 249986
2015-10-11 17:35:42 +00:00
Saleem Abdulrasool 8b3353f20f builtins: use NORETURN macro
Now that we have the NORETURN macro, use that to mark the function as noreturn,
rather than the GNU __attribute__.

llvm-svn: 249985
2015-10-11 17:35:38 +00:00
Saleem Abdulrasool 911cfc11c4 builtins: spell inline as __inline
__inline is a vendor specific spelling for inline.  clang and gcc treat it the
same as inline, and is available in MSVC 2013 which does not implement C99
(VS2015 supports the inline keyword though).  This will allow us to build the
builtins using MSVC.

llvm-svn: 249953
2015-10-10 21:21:28 +00:00
Saleem Abdulrasool 114aae4ac7 Revert "builtins: enable builtins build for MSVC"
Seems to break on the sanitizer buildbot.  Revert until it can be fixed
properly.

llvm-svn: 249950
2015-10-10 18:52:01 +00:00
Saleem Abdulrasool 9650c4a26e builtins: silence a MSVC warning
_BitReverse64 is only available on ARM and x64.  Guard it accordingly.

llvm-svn: 249949
2015-10-10 17:57:37 +00:00
Saleem Abdulrasool fbd8bb6fee builtins: enable builtins build for MSVC
Patch by Tee Hao Wei!

llvm-svn: 249948
2015-10-10 17:57:33 +00:00
Chris Bieneman 6ed46bd380 [CMake] [macho_embedded] [builtins] Need to also drop the bswap builtins.
llvm-svn: 249914
2015-10-09 22:46:19 +00:00