Commit Graph

7432 Commits

Author SHA1 Message Date
Kostya Serebryany 8b4904f9d7 [scudo] add NORETURN to the declaration of dieWithMessage; this should fix a warning in lib/scudo/scudo_termination.cpp
llvm-svn: 277546
2016-08-02 23:23:13 +00:00
Kostya Serebryany 707894b092 [sanitizer] Implement a __asan_default_options() equivalent for Scudo
Summary:
Currently, the Scudo Hardened Allocator only gets its flags via the SCUDO_OPTIONS environment variable.
With this patch, we offer the opportunity for programs to define their own options via __scudo_default_options() which behaves like __asan_default_options() (weak symbol).
A relevant test has been added as well, and the documentation updated accordingly.
I also used this patch as an opportunity to rename a few variables to comply with the LLVM naming scheme, and replaced a use of Report with dieWithMessage for consistency (and to avoid a callback).

Reviewers: llvm-commits, kcc

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

llvm-svn: 277536
2016-08-02 22:25:38 +00:00
Etienne Bergeron 5d42763779 [compiler-rt] Add more interception patterns.
Summary:
These instructions where not supported on my win7 computer.
They were happening on strstr when building chrome unittests with asan.

Reviewers: rnk

Subscribers: llvm-commits, chrisha

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

llvm-svn: 277519
2016-08-02 20:38:05 +00:00
Reid Kleckner d6371ea52a [asan] Intercept RtlRaiseException instead of kernel32!RaiseException
Summary:
On my install of Windows 10, RaiseException is a tail call to
kernelbase!RaiseException. Obviously, we fail to intercept that.
Instead, try hooking at the ntdll!RtlRaiseException layer. It is
unlikely that this layer will contain control flow.

Intercepting at this level requires adding a decoding for
'LEA ESP, [ESP + 0xXXXXXXXX]', which is a really obscure way to write
'SUB ESP, 0xXXXXXXXX' that avoids clobbering EFLAGS.

Reviewers: etienneb

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 277518
2016-08-02 20:36:29 +00:00
Reid Kleckner dabcee8b2c Remove stale CHECK lines that should have been included in r277478
We no longer assign ids to unregistered threads. We don't have any stack
trace for thread creation for these worker threads, so this shouldn't
affect report quality much.

llvm-svn: 277514
2016-08-02 20:26:59 +00:00
Etienne Bergeron eb09609f39 fix comments typos [NFC]
llvm-svn: 277511
2016-08-02 20:07:49 +00:00
Xinliang David Li 14c91c4eca [Profile] track ownership of filename pattern string
Make sure runtime copy and owns the string when passed
in from external users of runtime API.

llvm-svn: 277507
2016-08-02 19:34:00 +00:00
Reid Kleckner b0e4a86e05 [asan] Remove NtWaitForWorkViaWorkerFactory interceptor
Summary:
On Windows 10, this gets called after TLS has been torn down from NTDLL,
and we crash attempting to return fake_tsd. This interceptor isn't
needed after r242948 anyway, so let's remove it. The ASan runtime can
now tolerate unregistered threads calling __asan_handle_no_return.

Reviewers: vitalybuka, etienneb

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 277478
2016-08-02 16:17:32 +00:00
Kuba Brecka a56c2ad594 Follow-up for r277458: Update the tsan_mman_test.cc unit test.
llvm-svn: 277463
2016-08-02 14:41:03 +00:00
Kuba Brecka 3a748d6067 [tsan] Fix the behavior of OSAtomicTestAndClear
The system implementation of OSAtomicTestAndClear returns the original bit, but the TSan interceptor has a bug which always returns zero from the function. This patch fixes this and adds a test.

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

llvm-svn: 277461
2016-08-02 14:30:52 +00:00
Kuba Brecka b5a60ec7fe [tsan] Fix behavior of realloc(nullptr, 0) on Darwin
On Darwin, there are some apps that rely on realloc(nullptr, 0) returning a valid pointer. TSan currently returns nullptr in this case, let's fix it to avoid breaking binary compatibility.

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

llvm-svn: 277458
2016-08-02 14:22:12 +00:00
Jonas Hahnfeld 8ad6cc1c26 Revert "[CMake] Pass -nostdlib if supported"
This reverts commit r277419.

llvm-svn: 277420
2016-08-02 06:01:05 +00:00
Jonas Hahnfeld 55933dfb32 [CMake] Pass -nostdlib if supported
The sanitizers use C++ but don't require linking with the library.

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

llvm-svn: 277419
2016-08-02 05:51:09 +00:00
Jonas Hahnfeld 9b2c3ab620 [CMake] Load LLVMConfig for standalone build of builtins
Therefore move some code into reusable macros.

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

llvm-svn: 277418
2016-08-02 05:51:05 +00:00
Reid Kleckner 1734b97901 [winasan] Try to fix LNK4099 warnings seen by users
/Zi creates a separate PDB that we're supposed to pass along with our
sanitizer libraries, but the object library compilation rules aren't set
up to handle that. Rather than set that up, put the debug info in the
object files the way every other platform does it with /Z7.

llvm-svn: 277406
2016-08-02 01:02:46 +00:00
Xinliang David Li 24a927b3c2 improve test cases to fix bot failure
llvm-svn: 277403
2016-08-01 23:20:30 +00:00
Evgeniy Stepanov 6c25e57a56 [asan] Disable android-coverage test on anything other than arm.
llvm-svn: 277395
2016-08-01 21:58:34 +00:00
Xinliang David Li e594277683 Make test more robust with better matching
llvm-svn: 277387
2016-08-01 21:06:54 +00:00
Xinliang David Li 7380a0d4a6 [Profile] Add new test case to cover comdat renaming
Test checks that context specific profiles for comdat functions
are not lost.

llvm-svn: 277381
2016-08-01 20:28:26 +00:00
Chris Bieneman 178cdfbf66 [CMake] Don't trust compiler error code, also check for errors
Summary: rnk reported that MSVC ignores unknown flags and still returns 0. This should cause unknown flags to be an error during the compiler check.

Reviewers: rnk

Subscribers: brad.king, llvm-commits

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

llvm-svn: 277377
2016-08-01 20:18:18 +00:00
Reid Kleckner 1bd5e3ec56 Use 'unsigned long' to match the APIs of the MS bitscan intrinsics
We were getting warnings about how 'uint32_t*' is different from
'unsigned long*' even though they are effectively the same on Windows.

llvm-svn: 277363
2016-08-01 18:39:27 +00:00
Etienne Bergeron 502df06e21 [compiler-rt] Fix various typos in asan dll [NFC]
llvm-svn: 277345
2016-08-01 15:08:12 +00:00
Maxim Ostapenko 9f0546b5a9 [asan] Reduce flakiness of heavy recovery mode tests.
When we run halt_on_error-torture.cc with 10 threads and 20 iterations with halt_on_error=false:suppress_equal_pcs=false, we write 200 reports to 10.txt file and sometimes have collisions.
We have CHECK-COLLISION check that greps 'AddressSanitizer: nested bug in the same thread, aborting' message in 10.txt, but it doesn't contain this line.
If I don't redirect stderr > 10.txt 'AddressSanitizer: nested bug in the same thread, aborting' is printed to my screen as expected.
Same happens for halt_on_error_suppress_equal_pcs.cc and halt_on_error-torture.cc. This happens because of kernel bug: https://lkml.org/lkml/2014/2/17/324
Furtunately, we can fix these tests by implicitly setting O_APPEND for opened files (use >> instead of > for stderr redirection).

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

llvm-svn: 277324
2016-08-01 07:24:36 +00:00
Xinliang David Li 52626f132c Fix a bug in lit var def: remove extra space
llvm-svn: 277312
2016-08-01 01:54:40 +00:00
Dimitry Andric 41d9b3640c Fix ASan alloca_constant_size.cc test on FreeBSD.
On FreeBSD <alloca.h> does not exist: alloca(3) is defined in <stdlib.h>
instead.

llvm-svn: 277300
2016-07-31 20:16:59 +00:00
Dimitry Andric 75534e23d0 XFAIL one sanitizer symbolizer test for FreeBSD
Summary:
Due to a QoI issuse in FreeBSD's libcxxrt-based demangler, one sanitizer
symbolizer test consistently appears to fail:

    Value of: DemangleSwiftAndCXX("foo")
      Actual: "float"
    Expected: "foo"

This is because libcxxrt's __cxa_demangle() incorrectly demangles the "foo"
identifier to "float".  It should return an error instead.

For now, XFAIL this particular test for FreeBSD, until we can fix libcxxrt
properly (which might take some time to coordinate with upstream).

Reviewers: rnk, zaks.anna, emaste

Subscribers: emaste, llvm-commits, kubabrecka

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

llvm-svn: 277297
2016-07-31 19:27:46 +00:00
Etienne Bergeron 0b2d71373b [compiler-rt] Add support for interception redirect exports.
Summary:
On windows, an export can be redirected to an other DLL.
This patch is adding the required support to the internal
GetProcAddress implementation.

This case was encountered by instrumenting chromium (win 64-bits)
using this GN configuration:
```
is_component_build = true
is_debug = false
enable_nacl = false
is_clang = true
is_asan = true
clang_base_path = "d:\src\llvm\ninja64"
clang_use_chrome_plugins = false
clang_version = "4.0.0"
```

The operating system is win7 (x64).
Visual Studio: 2015 Professional



Reviewers: rnk

Subscribers: llvm-commits, chrisha

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

llvm-svn: 277294
2016-07-31 17:56:26 +00:00
Xinliang David Li f418bb8023 [Profile] Add a new test case
The end-end test checks that cs-profile counter update
is obtained as expected.

llvm-svn: 277276
2016-07-30 20:12:00 +00:00
Adhemerval Zanella 4f9de1e7bf tsan: Enable 48-bit VMA support on aarch64
This patch adds 48-bits VMA support for tsan on aarch64.  As current
mappings for aarch64, 48-bit VMA also supports PIE executable.  This
limits the mapping mechanism because the PIE address bits
(usually 0aaaaXXXXXXXX) makes it harder to create a mask/xor value
to include all memory regions.  I think it is possible to create a
large application VAM range by either dropping PIE support or tune
current range.

It also changes slight the way addresses are packed in SyncVar structure:
previously it assumes x86_64 as the maximum VMA range.  Since ID is 14 bits
wide, shifting 48 bits should be ok.

Tested on x86_64, ppc64le and aarch64 (39 and 48 bits VMA).

llvm-svn: 277137
2016-07-29 12:45:35 +00:00
Dean Michael Berris 17a586e6de [compiler-rt][XRay] Address follow-up comments to initial interface and initialisation code
This addresses some comments from D21612, which contains the following changes:

- Update __xray_patch() and __xray_unpatch() API documentation to not imply asynchrony.
- Introduce a scope cleanup mechanism to make sure we can roll-back changes to the XRayPatching global atomic.
- Introduce a few more comments for potential extension points for other platforms (for the implementation details of patching and un-patching).

Reviewers: eugenis, rnk, kcc, echristo, majnemer

Subscribers: llvm-commits, mehdi_amini

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

llvm-svn: 277124
2016-07-29 07:11:58 +00:00
Vitaly Buka 49dd9d23cc [asan] Enable the rest of use-after-scope tests
Summary:
Test where broken because of missing lifetime markers for temps and
because of aggressive optimization which removed markers in some cases.

PR27453

Reviewers: eugenis, kcc

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 277074
2016-07-28 23:03:27 +00:00
Etienne Bergeron 74999eb50f Fix broken build bot
The address resolution is ussing RTLD_NEXT and not RTLD_DEFAULT.
Which means &func may not be equivalent to dlsym("func").

llvm-svn: 276951
2016-07-28 01:35:32 +00:00
Etienne Bergeron 8c6eb1566c [compiler-rt] Fix warnings in interception code
Summary:
This patch is re-introducing the code to fix the
dynamic hooking on windows and to fix a compiler
warning on Apple.

Related patches:

* https://reviews.llvm.org/D22641
* https://reviews.llvm.org/D22610
* https://reviews.llvm.org/rL276311
* https://reviews.llvm.org/rL276490

Both architecture are using different techniques to
hook on library functions (memchr, strcpy,...). 

On Apple, the function is not dynamically hooked and
the symbol always points to a valid function 
(i.e. can't be null). The REAL macro returns the
symbol.

On windows, the function is dynamically patch and the
REAL(...) function may or may not be null. It depend
on whether or not the function was hooked correctly.
Also, on windows memcpy and memmove are the same.

```
#if !defined(__APPLE__)
[...]
# define REAL(x) __interception::PTR_TO_REAL(x)
# define ASSIGN_REAL(dst, src) REAL(dst) = REAL(src)
[...]
#else  // __APPLE__
[...]
# define REAL(x) x
# define ASSIGN_REAL(x, y)
[...]
#endif  // __APPLE__

Reviewers: rnk

Subscribers: kcc, hans, kubabrecka, llvm-commits, bruno, chrisha

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

llvm-svn: 276885
2016-07-27 16:16:54 +00:00
Etienne Bergeron a07ce512eb [compiler-rt] Activate interception unittests
Summary:
The unittests recently added were not running when executing 'check-all'.
Tests are stable on every archictetures and we can now turn them on.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, chrisha

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

llvm-svn: 276881
2016-07-27 15:29:49 +00:00
Dmitry Vyukov 246e0283d4 tsan: don't deliver signals when they are blocked
When we delay signals we can deliver them when the signal
is blocked. This can be surprising to the program.
Intercept signal blocking functions merely to process
pending signals. As the result, at worst we will delay
a signal till return from the signal blocking function.

llvm-svn: 276876
2016-07-27 14:34:21 +00:00
Dean Michael Berris 7094aa4f8d Revert "Default COMPILER_RT_BUILD_XRAY=ON"
This reverts commit 23240d8de38c79220a888f645a1f4b686bfb87c6.

Broke the build because the build bots haven't gotten the latest config
from zorg yet.

llvm-svn: 276847
2016-07-27 08:10:04 +00:00
Dean Michael Berris d3aaa77ff9 Default COMPILER_RT_BUILD_XRAY=ON
llvm-svn: 276845
2016-07-27 07:27:35 +00:00
Dean Michael Berris 9a0c446d9e Use RAII for ensuring that mprotect calls are undone
Summary: This fixes an mprotect leak identified in D21612.

Reviewers: echristo, rSerge

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 276833
2016-07-27 04:30:25 +00:00
Evgeniy Stepanov d140aec490 [asan] Remove zero FSR check on ARM.
The kernel on Nexus 5X returns error_code in ucontext which has
correct FSR_WRITE flag, but empty (zero) abort type field. Removing
the checks means that we will report all SEGVs as READ on very old
kernels, but will properly distinguish READ vs WRITE on moderately
old ones.

llvm-svn: 276803
2016-07-26 21:02:45 +00:00
Evgeniy Stepanov 08ef0e0175 [asan] Hardcode page size 4096 on Android.
EXEC_PAGESIZE lies.
sysconf() is broken in .preinit_array.

llvm-svn: 276802
2016-07-26 21:02:44 +00:00
Reid Kleckner cb42ea0b4f [sanitizer] Try to fix LargeMmapAllocator test on Windows
This test attempts to allocate 100 512MB aligned pages of memory. This
is implemented in the usual way by allocating size + alignment bytes and
aligning the result. As a result, this test allocates 51.2GB of memory.
Windows allocates swap for all memory allocated, and our bots do not
have this much swap available.

Avoid the failure by using a more reasonable alignment, like 16MB, as we
do on 32-bit.

llvm-svn: 276779
2016-07-26 17:59:09 +00:00
Xinliang David Li c5307c6993 Define compatibility flag if not defined with -std=c++
llvm-svn: 276708
2016-07-25 23:12:53 +00:00
Chris Bieneman 56e3827e92 Revert "Enable cross-compilation across architectures on android"
This reverts commit r276333.

As I commented in the review (https://reviews.llvm.org/D22415), this change isn't needed because CMAKE_C_FLAGS is implicitly added by CMake to the command line for all C source files.

With this patch enabled CMAKE_C_FLAGS is duplicated on all C sources, and applied to ASM sources, which is not ideal.

I sent an email about this to llvm-commits on the commit thread. I suspect the problem the patch author was actually seeing is that CMAKE_C_FLAGS isn't applied to ASM files, and the builtins library has quite a few of those. The correct solution there is to specify CMAKE_ASM_FLAGS with whatever flags need to be passed to the compiler when compiling ASM files.

If there are other problems with flag propagation, please let me know.

llvm-svn: 276683
2016-07-25 20:25:38 +00:00
Bruno Cardoso Lopes 1f849e3b84 Revert r276539 "Silence -Wpointer-bool-conversion warning after r276324"
Some bots are not happy with the change.
This reverts commit d307ca28083065851ad969444f3c063562f2d4bd.

llvm-svn: 276541
2016-07-24 01:27:07 +00:00
Bruno Cardoso Lopes bd36338449 Silence -Wpointer-bool-conversion warning after r276324
sanitizer_common_interceptors.inc:667:12: warning: address of function 'memchr' will always evaluate to 'true' [-Wpointer-bool-conversion]
  if (REAL(memchr)) {
  ~~       ^~~~~~

llvm-svn: 276539
2016-07-24 01:09:03 +00:00
Xinliang David Li 6f6825fe13 Fix buildbot failure
llvm-svn: 276512
2016-07-23 03:34:30 +00:00
Xinliang David Li 54bb751a87 [Profile] Tighten test with expected profile count
llvm-svn: 276500
2016-07-22 23:53:00 +00:00
Xinliang David Li 544ae6c4f3 [Profile] Fix a fixme in the test
llvm-svn: 276494
2016-07-22 23:44:06 +00:00
Xinliang David Li 5a6dc4c9b8 [Profile] Add new test
To test that online merging is enabled by default.

llvm-svn: 276493
2016-07-22 23:38:58 +00:00
Bruno Cardoso Lopes fb4358d15b Revert "fix https://reviews.llvm.org/D22610" and "[compiler-rt] Fix memmove/memcpy overlap detection on windows"
This currently fails ~500 tests on Darwin:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/20456/

This reverts commit 4cfee0dff1facb8fa2827d25c5943bfef96d1a8f and
dbd91205d578cb61ab77be06087e9f65ba8a7ec8.

llvm-svn: 276490
2016-07-22 23:02:34 +00:00