Commit Graph

6175 Commits

Author SHA1 Message Date
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
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 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
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
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
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
Vedant Kumar 1caaa28732 Revert "[profile] Hide lprofCurFilename"
This reverts commit r282294. It breaks a Linux bot:

  http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/12180

It looks like the test checks that __llvm_profile_set_filename() alters the raw
profile filename in both the dylib and the main program. Now that
lprofCurFilename is hidden, this can't work, and we get two profiles (one for
the call to "main" and one for "func").

Back this change out so that we don't affect external users.

llvm-svn: 282304
2016-09-23 21:58:25 +00:00
Vedant Kumar ac9fbf9085 [profile] Hide lprofCurFilename
Differential Revision: https://reviews.llvm.org/D24885

llvm-svn: 282294
2016-09-23 20:53:42 +00:00
Kuba Brecka 7bc254f89c [asan] Stop appending -lm, -pthread and other linker options on Darwin for ASan unit tests
On Darwin, -lm, -pthread and others are implied. -pthread currently produces a warning (compiler option unused).

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

llvm-svn: 282260
2016-09-23 16:43:29 +00:00
Etienne Bergeron e7863a86ad [compiler-rt][lsan] Fix compiler error due to attribute (windows)
Summary:
Window compiler is stricter for attributes location. This patch fixes a compilation error.
```
D:\src\llvm\llvm\projects\compiler-rt\lib\lsan\lsan_thread.cc(39): error C2144: syntax error: 'int' should be preceded by ';'
```

Reviewers: rnk, majnemer

Subscribers: majnemer, llvm-commits, chrisha, dberris

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

llvm-svn: 282254
2016-09-23 15:11:41 +00:00
Maxim Ostapenko f42c138470 [msan] Prevent initialization failure with newer (2.23+) glibc in use.
This patch is pretty the same as http://reviews.llvm.org/D20235 that we used
for ASan. Using the same hack for MSan fixes its initialization with newer
Glibc in use.

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

llvm-svn: 282232
2016-09-23 07:40:55 +00:00
Xinliang David Li 5f78d3894b [Profile] Remove unused variable
llvm-svn: 282198
2016-09-22 21:12:40 +00:00
Xinliang David Li e68df598f5 [Profile] suppress verbose rt message by default
llvm-svn: 282193
2016-09-22 21:00:29 +00:00
Dmitry Vyukov 5f44b04475 tsan: fix bug introduced in 282152
In ShadowToMem we call MemToShadow potentially for incorrect addresses.
So DCHECK(IsAppMem(p)) can fire in debug mode.
Fix this by swapping range and MemToShadow checks.

llvm-svn: 282157
2016-09-22 14:33:43 +00:00
Dmitry Vyukov cc1f318b5a tsan: support pie binaries on newer kernels
4.1+ Linux kernels map pie binaries at 0x55:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d1fd836dcf00d2028c700c7e44d2c23404062c90
Currently tsan does not support app memory at 0x55 (https://github.com/google/sanitizers/issues/503).
Older kernels also map pie binaries at 0x55 when ASLR is disables (most notably under gdb).

This change extends tsan mapping for linux/x86_64 to cover 0x554-0x568 app range and fixes both 4.1+ kernels and gdb.

This required to slightly shrink low and high app ranges and move heap. The mapping become even more non-linear, since now we xor lower bits. Now even a continuous app range maps to split, intermixed shadow ranges. This breaks ShadowToMemImpl as it assumes linear mapping at least within a continuous app range (however it turned out to be already broken at least on arm64/42-bit vma as uncovered by r281970). So also change ShadowToMemImpl to hopefully a more robust implementation that does not assume a linear mapping.

llvm-svn: 282152
2016-09-22 13:42:02 +00:00
Sagar Thakur 2ce2ab3a4d [ESan][MIPS] Fix tests struct-simple.cpp on MIPS
For mips assember '#' is the start of comment. We get assembler error messages if # is used in the struct names. Therefore using '$' which works for all architectures.

Differential: D24335
Reviewed by: zhaoqin

llvm-svn: 282142
2016-09-22 08:36:54 +00:00
Filipe Cabecinhas a8b5f5e9d1 [asan] Reify ErrorGeneric
Summary:
Finish work on PR30351 (last one, after D24551, D24552, and D24554 land)

Also replace the old ReportData structure/variable with the current_error_ static
member of the ScopedInErrorReport class.

This has the following side-effects:
  - Move ASAN_ON_ERROR(); call to the start of the destructor, instead
    of in StartReporting().
      - We only generate the error structure after the
        ScopedInErrorReport constructor finishes, so we can't call
        ASAN_ON_ERROR() during the constructor. I think this makes more
        sense, since we end up never running two of the ASAN_ON_ERROR()
        callback. This also works the same way as error reporting, since
        we end up having a lock around it. Otherwise we could end up
        with the ASAN_ON_ERROR() call for error 1, then the
        ASAN_ON_ERROR() call for error 2, and then lock the mutex for
        reporting error 1.
  - The __asan_get_report_* functions will be able to, in the future,
    provide information about other errors that aren't a "generic
    error". But we might want to rethink that API, since it's too
    restricted. Ideally we teach lldb about the current_error_ member of
    ScopedInErrorReport.

Reviewers: vitalybuka, kcc, eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 282107
2016-09-21 20:18:18 +00:00
Filipe Cabecinhas 490f96cba6 [asan] Store full AddressDescription objects in ErrorInvalidPointerPair
Reviewers: kcc, vitalybuka, eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 282102
2016-09-21 19:21:01 +00:00
Nico Weber b097c8fa2b revert 282085, 281909, they broke 32-bit dynamic ASan and the sanitizer-windows bot
llvm-svn: 282096
2016-09-21 18:22:43 +00:00
Etienne Bergeron 5e697c679b Fix typo in comment [NFC]
llvm-svn: 282092
2016-09-21 17:16:38 +00:00