Commit Graph

7763 Commits

Author SHA1 Message Date
Dean Michael Berris 1b09aae82a [compiler-rt][XRay] Support tail call sleds
Summary:
This change depends on D23986 which adds tail call-specific sleds. For
now we treat them first as normal exits, and in the future leave room
for implementing this as a different kind of log entry.

The reason for deferring the change is so that we can keep the naive
logging implementation more accurate without additional complexity for
reading the log. The accuracy is gained in effectively interpreting call
stacks like:

  A()
    B()
      C()

Which when tail-call merged will end up not having any exit entries for
A() nor B(), but effectively in turn can be reasoned about as:

  A()
  B()
  C()

Although we lose the fact that A() had called B() then had called C()
with the naive approach, a later iteration that adds the explicit tail
call entries would be a change in the log format and thus necessitate a
version change for the header. We can do this later to have a chance at
releasing some tools (in D21987) that are able to handle the naive log
format, then support higher version numbers of the log format too.

Reviewers: echristo, kcc, rSerge, majnemer

Subscribers: mehdi_amini, llvm-commits, dberris

Differential Revision: https://reviews.llvm.org/D23988

llvm-svn: 284178
2016-10-13 23:56:54 +00:00
Kostya Serebryany 8633900e03 Make lsan complain loudly when running under ptrace
Summary:
LeakSanitizer does not work with ptrace but currently it
will print warnings (only under verbosity=1) and then proceed
to print tons of false reports.
This patch makes lsan fail hard under ptrace with a verbose message.

https://github.com/google/sanitizers/issues/728

Reviewers: eugenis, vitalybuka, aizatsky

Subscribers: kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D25538

llvm-svn: 284171
2016-10-13 22:34:13 +00:00
Reid Kleckner 3137c81e56 Make __asan_handle_no_return a no-op during initialization
Some of our existing tests hang on the new Windows bot with this stack:

770, clang_rt.asan_dynamic-i386.dll!__asan::AsanTSDGet+0x3e
771, clang_rt.asan_dynamic-i386.dll!__asan::GetCurrentThread+0x9
772, clang_rt.asan_dynamic-i386.dll!__asan_handle_no_return+0xe
773, clang_rt.asan_dynamic-i386.dll!__asan_wrap__except_handler4_common+0x12
774, ntdll.dll!wcstombs+0xb0 (No unwind info)
775, ntdll.dll!ZwWow64CallFunction64+0x2001 (No unwind info)
776, ntdll.dll!ZwWow64CallFunction64+0x1fd3 (No unwind info)
777, ntdll.dll!KiUserExceptionDispatcher+0xf (No unwind info)
778, clang_rt.asan_dynamic-i386.dll!destroy_fls+0x13
779, ntdll.dll!RtlLockHeap+0xea (No unwind info)
780, ntdll.dll!LdrShutdownProcess+0x7f (No unwind info)
781, ntdll.dll!RtlExitUserProcess+0x81 (No unwind info)
782, kernel32.dll!ExitProcess+0x13 (No unwind info)
783, clang_rt.asan_dynamic-i386.dll!__sanitizer::internal__exit+0xc
784, clang_rt.asan_dynamic-i386.dll!__sanitizer::Die+0x3d
785, clang_rt.asan_dynamic-i386.dll!__asan::AsanInitInternal+0x50b
786, clang_rt.asan_dynamic-i386.dll!__asan::Allocator::Allocate+0x1c
787, clang_rt.asan_dynamic-i386.dll!__asan::Allocator::Calloc+0x43

We hang because AsanDie tries to defend against multi-threaded death by
infinite looping if someone is already exiting. We might want to
reconsider that, but one easy way to avoid getting here is not to let
our noreturn interceptors call back into fragile parts of ASan.

llvm-svn: 284067
2016-10-12 22:33:57 +00:00
Reid Kleckner a8c44c3d0c Follow up to r283955: add _recalloc_base dll thunk
llvm-svn: 284059
2016-10-12 21:59:56 +00:00
Reid Kleckner a335055643 Fix _recalloc redefinition link error in ASan RTL
Fixes PR30329

Patch by Hans-Bernhard Broeker!

llvm-svn: 283955
2016-10-11 23:13:13 +00:00
Vedant Kumar d5454ce10e [profile] Add test for dead_strip+live_support functionality
Differential Revision: https://reviews.llvm.org/D25457

llvm-svn: 283948
2016-10-11 21:48:48 +00:00
Kuba Brecka ab61c74f93 [compiler-rt] Exclude compiler-rt from using -fmodules when LLVM_ENABLE_MODULES=On
Sanitizers are intentionally not including system headers and often declare slightly different function prototypes, which is incompatible with -fmodules and -fcxx-modules. Let’s simply exclude compiler-rt from using -fmodules.

Differential Revision: https://reviews.llvm.org/D25230

llvm-svn: 283658
2016-10-08 09:01:27 +00:00
Qin Zhao 998371f3be [esan] Fix ESan test failure on Debian Sid bot
Summary: Increase early allocation buffer size.

Reviewers: bruening

Subscribers: kubabrecka

Differential Revision: https://reviews.llvm.org/D25380

llvm-svn: 283598
2016-10-07 20:53:35 +00:00
Vedant Kumar 78b2b73ac1 [ubsan] More 0 -> nullptr conversions (NFC)
llvm-svn: 283511
2016-10-06 23:41:57 +00:00
Vedant Kumar 413fce239e [ubsan] 0 -> nullptr (NFC)
llvm-svn: 283506
2016-10-06 22:58:45 +00:00
Vedant Kumar cb7110be27 [ubsan] Turn on 'Has CXXABI' to enable support for -fsanitize=vptr on Darwin
Differential Revision: https://reviews.llvm.org/D24990

llvm-svn: 283466
2016-10-06 16:45:40 +00:00
Sagar Thakur d9a1a53b8d [ESan] [MIPS] Fix workingset-signal-posix.cpp on MIPS
Used uptr for __sanitizer_kernel_sigset_t.sig to avoid byte order issues on big endian systems

Reviewd by bruening.
Differential: D24332 

llvm-svn: 283438
2016-10-06 10:21:42 +00:00
Sagar Thakur 51458256a2 [ESan][MIPS] Adds support for MIPS64
With this patch 12 out of 13 tests are passing.

Reviewed by zhaoqin.
Differential: D23799 

llvm-svn: 283435
2016-10-06 09:58:11 +00:00
Dean Michael Berris 4ef1a69b40 [compiler-rt][XRay][NFC] clang-format XRay sources
llvm-svn: 283421
2016-10-06 07:09:40 +00:00
Anna Zaks cacfb554a8 [compiler-rt] Enable building iOS by default.
llvm-svn: 283379
2016-10-05 20:45:36 +00:00
Anna Zaks bfe61253b8 [asan] Fixup: Switch to using dynamic shadow offset on iOS
Address lint comments.

llvm-svn: 283378
2016-10-05 20:45:34 +00:00
Anna Zaks b17a5db2ee [asan] Reapply: Switch to using dynamic shadow offset on iOS
The VM layout is not stable between iOS version releases, so switch to dynamic shadow offset.

Differential Revision: https://reviews.llvm.org/D25218

llvm-svn: 283375
2016-10-05 20:33:59 +00:00
Anna Zaks 4ca31f8ad9 Revert "[asan] Switch to using dynamic shadow offset on iOS"
This reverts commit b2af965b7924ad793b313996a96633bb72daf629.

Revert as these changes broke a Chromium buildbot.

llvm-svn: 283349
2016-10-05 17:42:24 +00:00
Diana Picus 47cf72c34c [sanitizers] Update sanitizers test to better match glibc internals
Reapply 282061.

One of the tests relying on sem_t's layout gets the wrong value for versions of
glibc newer than 2.21 on platforms that don't have 64-bit atomics (e.g. ARM).

This commit fixes the test to work with:
* versions of glibc >= 2.21 on platforms with 64-bit atomics: unchanged
* versions of glibc >= 2.21 on platforms without 64-bit atomics: the semaphore
value is shifted by SEM_VALUE_SHIFT (which is set to 1 in glibc's internal
headers)
* versions of glibc < 2.21: unchanged

The logic is complicated a bit by the fact that the sanitizers always pick the
oldest version of the symbol available in glibc, which creates discrepancies
between old platforms which contain several versions od the sem_init symbol, and
newer platforms which contain only one.

See the glibc 2.23 sources:
* sysdeps/nptl/internaltypes.h (struct new_sem for glibc >= 2.21 and
                                struct old_sem for glibc < 2.21)
* nptl/sem_getvalue.c

This was uncovered on one of the new buildbots that we are trying to move to
production.

Differential Revision: https://reviews.llvm.org/D24766

llvm-svn: 283299
2016-10-05 07:13:42 +00:00
Kostya Serebryany 3aacfafaad [asan] When protect_shadow_gap=0, set up the shadow for the shadow gap. This is needed to support NVIDIA CUDA drivers. Unfortunately, I don't know how to test it properly with CUDA on a public build bot, so adding a test that emulates the CUDA behavior.
llvm-svn: 283270
2016-10-04 23:39:58 +00:00
Anna Zaks 11ee532c3a [asan] Switch to using dynamic shadow offset on iOS
The VM layout is not stable between iOS version releases, so switch to dynamic shadow offset.

Differential Revision: https://reviews.llvm.org/D25218

llvm-svn: 283240
2016-10-04 19:02:53 +00:00
Kostya Serebryany e923a1a486 [sanitizer-coverage] remove stale code, second attempt after failed r282994
llvm-svn: 283185
2016-10-04 04:18:30 +00:00
Vitaly Buka bf1bc21157 Revert "[sanitizer-coverage] remove stale code" at it breaks Windows bot.
This reverts commit r282994.

llvm-svn: 283183
2016-10-04 02:59:03 +00:00
Vitaly Buka b0590268c2 Support configurable path to LLVM src
llvm-svn: 283166
2016-10-04 00:06:23 +00:00
Qin Zhao ab5478a9c6 [esan] Fix ESan test failure on Debian Sid bot
Summary:
Handles early allocation from dlsym by allocating memory from a local
static buffer.

Reviewers: bruening

Subscribers: kubabrecka

Differential Revision: https://reviews.llvm.org/D25193

llvm-svn: 283139
2016-10-03 20:03:10 +00:00
Kostya Serebryany 73957e39a4 [sanitizer-coverage] remove stale code
llvm-svn: 282994
2016-10-01 00:55:13 +00:00
Kostya Kortchinsky ada2761407 [scudo] Fix an edge case in the secondary allocator
Summary:
s/CHECK_LT/CHECK_LE/ in the secondary allocator, as under certain circumstances
Ptr + Size can be equal to MapEnd. This edge case was not found by the current
tests, so those were extended to be able to catch that.

Reviewers: kcc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D25101

llvm-svn: 282913
2016-09-30 19:57:21 +00:00
Etienne Bergeron 9f987d3f89 [compiler-rt] Fix interception of crt atoll on win10 CRT.
Summary:
The check-asan-dynamic tests were broken on win10 because the interception
library was not able to hook on some functions.

credits: thanks sebastian marchand to help debugging this on win10.

Reviewers: rnk

Subscribers: chrisha, llvm-commits, dberris

Differential Revision: https://reviews.llvm.org/D25120

llvm-svn: 282904
2016-09-30 19:37:11 +00:00
Etienne Bergeron c07e576968 [compiler-rt] Add support for the dynamic shadow allocation
Summary:
This patch is adding support for dynamic shadow allocation.

This is a merge and re-commit of the following patches.

```
[compiler-rt] Fix Asan build on Android
  https://reviews.llvm.org/D24768
[compiler-rt] Add support for the dynamic shadow allocation
  https://reviews.llvm.org/D23363
```

This patch needed to re-land at the same time:
```
[asan] Support dynamic shadow address instrumentation
  https://reviews.llvm.org/D23354
```

Reviewers: rnk, zaks.anna

Subscribers: tberghammer, danalbert, kubabrecka, dberris, chrisha, llvm-commits

Differential Revision: https://reviews.llvm.org/D25104

llvm-svn: 282882
2016-09-30 17:47:34 +00:00
Etienne Bergeron cde78361d9 [compiler-rt][asan] Disable a broken test on windows 64-bits
Summary:
This test is broken on wndows 64-bit.

The interception library is not able to hook on the memchr functions.

Snippet of the function that is not hookable:
```
--- No source file -------------------------------------------------------------
000007FEFA1A18CD CC                   int         3  
000007FEFA1A18CE CC                   int         3  
000007FEFA1A18CF CC                   int         3  
--- f:\dd\vctools\crt\vcruntime\src\string\amd64_arm_arm64\memchr.c ------------
        while ( cnt && (*(unsigned char *)buf != (unsigned char)chr) ) {
000007FEFA1A18D0 4D 85 C0             test        r8,r8  
000007FEFA1A18D3 74 0D                je          memchr+12h (07FEFA1A18E2h)  
000007FEFA1A18D5 38 11                cmp         byte ptr [rcx],dl  
000007FEFA1A18D7 74 09                je          memchr+12h (07FEFA1A18E2h)  
                buf = (unsigned char *)buf + 1;
000007FEFA1A18D9 48 FF C1             inc         rcx  
                cnt--;
000007FEFA1A18DC 49 83 E8 01          sub         r8,1  
000007FEFA1A18E0 75 F3                jne         memchr+5h (07FEFA1A18D5h)  
        }
```

Reviewers: rnk

Subscribers: kubabrecka, dberris, llvm-commits, chrisha

Differential Revision: https://reviews.llvm.org/D25037

llvm-svn: 282860
2016-09-30 14:31:39 +00:00
Etienne Bergeron 04a9eb4c0f [compiler-rt][asan] Fix incorrect regexp breaking an asan unittest on win64
Summary:
On windows, the memcpy and memmove function can be the same.
This is correcly detected when hooking, but it's not possible
to report the right function name when doing symbolisation.

The same fix was applied for the static asan unittest.
We forgot to apply the fix for the dynamic asan tests.
```
lvm\projects\compiler-rt\test\asan/TestCases/Windows/.svn/text-base/intercept_memcpy.cc.svn-base:// CHECK-NEXT:  __asan_{{.*}}mem{{.*}}
```

This patch is fixing this test (win64):
```
ddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memcpy_indirect.cc
```

Reviewers: rnk, vitalybuka

Subscribers: llvm-commits, kubabrecka, chrisha, dberris

Differential Revision: https://reviews.llvm.org/D25038

llvm-svn: 282859
2016-09-30 14:29:43 +00:00
Vitaly Buka 968bcc421d Remove Google specific code.
llvm-svn: 282808
2016-09-29 23:05:35 +00:00
Vitaly Buka 0ec5a2830d Don't use internal symbolizer if we are in process of reporting Out-of-Memory.
Reviewed by eugenis offline, as reviews.llvm.org is down.

llvm-svn: 282805
2016-09-29 23:00:54 +00:00
Mike Aizatsky 7f4516b049 [sancov] removing html report option test, the option doesn't exist anymore
llvm-svn: 282727
2016-09-29 16:59:04 +00:00
Vitaly Buka 19fe95d7d2 Add symbols introduced with -m32 build
llvm-svn: 282695
2016-09-29 07:08:42 +00:00
Vitaly Buka 757a419dd2 Limit script to sanitizers as SCUDO does not pass tests if we add symbolizer
llvm-svn: 282694
2016-09-29 07:08:40 +00:00
Vitaly Buka 29f52fb02c Move verbose clang binaries detection
llvm-svn: 282682
2016-09-29 03:53:20 +00:00
Vitaly Buka e8c12662ac Add build script for symbolizer which can be linked into instrumented process.
Reviewers: eugenis

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D24974

llvm-svn: 282617
2016-09-28 18:46:52 +00:00
Etienne Bergeron 42cdfbcf3e [compiler-rt] Fix interception of multiple defined symbols.
Summary:
The MSVC compiler is generating multiple instance of the exception handler
when compiling on win64 with /MD.

see: https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx

Two tests were failing when running:
```
ninja check-asan-dynamic.
```

The tests were failing because only the first occurence of the function was patched.
The function `__C_specific_handler` is defined in `ntdll` and `vcruntime140`.

After this patch, there is still two remaining tests failing.
```
********************
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 87.81s
********************
Failing Tests (2):
    AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memchr.cc
    AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memcpy_indirect.cc

  Expected Passes    : 342
  Passes With Retry  : 2
  Expected Failures  : 16
  Unsupported Tests  : 152
  Unexpected Failures: 2
```

Reviewers: rnk, vitalybuka

Subscribers: vitalybuka, llvm-commits, chrisha, dberris

Differential Revision: https://reviews.llvm.org/D24983

llvm-svn: 282614
2016-09-28 18:04:07 +00:00
Dmitry Vyukov b3587836bc [ASAN] Pass previous stack information through __sanitizer_finish_switch_fiber
This patch extends __sanitizer_finish_switch_fiber method to optionally return previous stack base and size.

This solves the problem of coroutines/fibers library not knowing the original stack context from which the library is used. It's incorrect to assume that such context is always the default stack of current thread (e.g. one such library may be used from a fiber/coroutine created by another library). Bulding a separate stack tracking mechanism would not only duplicate AsanThread, but also require each coroutines/fibers library to integrate with it.

Author: Andrii Grynenko (andriigrynenko)
Reviewed in: https://reviews.llvm.org/D24628

llvm-svn: 282582
2016-09-28 12:28:16 +00:00
Strahinja Petrovic 37d757039d [lsan] [aarch64] Fix calculating TLS area
This patch fixes calculating begin of TLS area on AARCH64.
Differential Revision: https://reviews.llvm.org/D24454

llvm-svn: 282571
2016-09-28 10:15:15 +00:00
Vedant Kumar ff17fcbc58 [sanitizer_common] Delete some copy/move methods in InternalScopedBuffer
Differential Revision: https://reviews.llvm.org/D24811

llvm-svn: 282548
2016-09-27 22:52:34 +00:00
Saleem Abdulrasool 81eb5f6a60 builtins: use thumb-2 if possible on comparesf2
This code can be built with thumb-2 like many of the other builtin routines.
Enable that here as well.

llvm-svn: 282530
2016-09-27 19:12:31 +00:00
Dmitry Vyukov b32c3ecdb1 tsan: relaxed check in CheckShadowMapping
Some platforms use strange addresses in shadow mapping.
E.g. aarch64/42vma:
  static const uptr kHiAppMemEnd   = 0x3ffffffffffull;
instead of 0x40000000000ull (the range is half-open).
This caused bot failures after r282405:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/12242/steps/ninja%20check%201/logs/FAIL%3A%20SanitizerCommon-tsan-aarch64-Linux%3A%3Aclock_gettime.c
Relaxed the new check in CheckShadowMapping to not expect round addresses.

llvm-svn: 282407
2016-09-26 14:23:34 +00:00
Dmitry Vyukov 730aa585c0 tsan: make shadow mapping linear within a single user region
This is a follow up to r282152.
A more extensive testing on real apps revealed a subtle bug in r282152.
The revision made shadow mapping non-linear even within a single
user region. But there are lots of code in runtime that processes
memory ranges and assumes that mapping is linear. For example,
region memory access handling simply increments shadow address
to advance to the next shadow cell group. Similarly, DontNeedShadowFor,
java memory mover, search of heap memory block header, etc
make similar assumptions.
To trigger the bug user range would need to cross 0x008000000000 boundary.
This was observed for a module data section.

Make shadow mapping linear within a single user range again.
Add a startup CHECK for linearity.

llvm-svn: 282405
2016-09-26 13:41:33 +00:00
Dmitry Vyukov a48a998d48 tsan: remove kMidShadowOff mapping parameter
kMidShadowOff is trivially computable from other parameters.
Remove it.

llvm-svn: 282404
2016-09-26 13:27:07 +00:00
Dmitry Vyukov f8f74c7dc1 tsan: simplify meta mapping
Don't xor user address with kAppMemXor in meta mapping.
The only purpose of kAppMemXor is to raise shadow for ~0 user addresses,
so that they don't map to ~0 (which would cause overlap between
user memory and shadow).
For meta mapping we explicitly add kMetaShadowBeg offset,
so we don't need to additionally raise meta shadow.

llvm-svn: 282403
2016-09-26 13:24:48 +00:00
Maxim Ostapenko 5b145205b5 [msan] Fix second parameter in MsanReallocate from previous commit.
It's wrong to pass to MsanReallocate a pointer that MSan allocator doesn't own.
Use nullptr instead of ptr to prevent possible (still unlikely) failure.

llvm-svn: 282390
2016-09-26 08:26:23 +00:00
Maxim Ostapenko b3cf42ce56 [asan, msan] Fix reallocation logic when IsInDlsymAllocPool(ptr) is true.
llvm-svn: 282389
2016-09-26 08:11:21 +00:00
Evgeniy Stepanov 5ab97ec2f6 [msan] Disable flaky fork.cc on PPC64.
This test is very flaky on PPC64 (both BE and LE), but not on other platforms.

llvm-svn: 282315
2016-09-23 23:41:44 +00:00