Commit Graph

7463 Commits

Author SHA1 Message Date
Kostya Serebryany 4cd2845e6a [sanitizer] allocator: move TransferBatch into SizeClassAllocator64/SizeClassAllocator32 because we actually need different iplementations for the 64- and 32-bit case. NFC; the following patches will make the TransferBatch implementations differ
llvm-svn: 277899
2016-08-06 01:24:11 +00:00
Reid Kleckner c209664b07 Try to fix the ill.cc test on Linux
llvm-svn: 277898
2016-08-06 00:57:58 +00:00
Reid Kleckner 2a38531eca Use %stdcxx11 instead of -std=c++11 so the test passes with VS 2015
llvm-svn: 277894
2016-08-06 00:37:14 +00:00
Nico Weber 023bb97737 Disable a few more flaky asan64 tests.
llvm-svn: 277886
2016-08-05 22:51:10 +00:00
Nico Weber 0f6aad4ad2 Disable a few win asan64 tests that don't reliably pass, https://reviews.llvm.org/D23230
llvm-svn: 277882
2016-08-05 22:36:30 +00:00
Reid Kleckner 9cba2e2d97 Fix two tests in Win64 ASan
Go back to intercepting kernel32!RaiseException, and only go for
ntdll!RtlRaiseException if that fails. Fixes throw_and_catch.cc test.

Work around an issue in LLVM's win64 epilogues. We end up with an
epilogue that looks like this, and it drives the Win64 unwinder crazy
until stack overflow:
        call    ill_cc!__asan_handle_no_return
        xor     eax,eax
        add     rsp,40h // epilogue starts
        pop     rbp     // CSR
        ud2             // Trap here
        ret             // Ret?
        nop     word ptr [rax+rax]
        sub     rsp,28h // Next function

Will file a PR soon.

llvm-svn: 277874
2016-08-05 21:47:46 +00:00
Mike Aizatsky ef70ae9036 [sanitizers] remove failing test.
The test often fails on Windows because there are more branches
in the code that is generated.

llvm-svn: 277862
2016-08-05 20:48:48 +00:00
Mike Aizatsky 04897dcc3d [sanitizers] trace buffer API to use user-allocated buffer.
Subscribers: kubabrecka

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

llvm-svn: 277858
2016-08-05 20:09:42 +00:00
Etienne Bergeron 61ba38c8dd fix random typos [NFC]
llvm-svn: 277850
2016-08-05 18:49:08 +00:00
Reid Kleckner 628d6b5c81 Fix dumping of process module list and test it
I probably broke this a year ago in r243895.

llvm-svn: 277842
2016-08-05 17:55:00 +00:00
Saleem Abdulrasool 1313ae306a builtins: windows has only one flavour on ARM
Windows on ARM is a hard-float only environment.  Don't try to build two copies
of the same library.

llvm-svn: 277834
2016-08-05 16:53:05 +00:00
Saleem Abdulrasool b4022f9782 builtins: better categorisation of Thumb1 builtins
Adjust the builtins to better annotate the Thumb1 routines and their purpose.
Exclude the remaining thumb1 sources on Windows ARM.

llvm-svn: 277828
2016-08-05 16:24:56 +00:00
Reid Kleckner 2a06f48bb5 Print a more useful BP value from MSVC-built ASan runtimes
MSVC doesn't have an exact equivalent for __builtin_frame_address, but
_AddressOfReturnAddress() + sizeof(void*) should be equivalent for all
frames build with -fno-omit-frame-pointer.

llvm-svn: 277826
2016-08-05 16:01:57 +00:00
Ivan Krasin 8de920cf0e Reverting r277632 as it breaks the build on MacOS.
Reviewers: kcc

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

llvm-svn: 277798
2016-08-05 03:18:27 +00:00
Ivan Krasin a425623dd9 CFI: add XFAIL test for a future optimization of two vcalls.
Summary:
Often, a code will call multiple virtual methods of a given object.
If they go in a linear block, it should be possible to check vtable
before the first call, then store vtable pointer and reuse it for
the second vcall without any additional checks.

This is expected to have a positive performance impact on a hot
path in Blink, see https://crbug.com/634139.

Reviewers: kcc

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

llvm-svn: 277795
2016-08-05 01:45:54 +00:00
Saleem Abdulrasool b44444b3f1 builtins: split out the EABI and VFP ARM sources
These are meant to only be included on certain targets.  This only disables it
for Windows ARM for now.  Ideally these would be conditionally included as
appropriate.

llvm-svn: 277777
2016-08-04 21:58:39 +00:00
Reid Kleckner c696467530 Avoid re-entrancy between __sanitizer::Report, OutputDebugString, and RtlRaiseException
Our Report implementation calls OutputDebugString, which calls
RtlRaiseException, which can re-enter back into the ASan runtime and
cause a hang.

Don't treat this special debugger-only exception code as a noreturn
event, since the stack won't really unwind all the way.

llvm-svn: 277763
2016-08-04 20:05:13 +00:00
Etienne Bergeron d2b37ada4d fix whitespaces from https://reviews.llvm.org/D23170
llvm-svn: 277746
2016-08-04 18:30:41 +00:00
Etienne Bergeron 27eb6d521e [compiler-rt] Fix memory allocator for dynamic address space
Summary:
The sanitizer allocators can works with a dynamic address space
(i.e. specified with ~0ULL).

Unfortunately, the code was broken on GetMetadata and GetChunkIdx.

The current patch is moving the Win64 memory test to a dynamic
address space. There is a migration to move every concept to a
dynamic address space on windows.

To have a better coverage, the unittest are now testing
dynamic address space on other platforms too.

Reviewers: rnk, kcc

Subscribers: kubabrecka, dberris, llvm-commits, chrisha

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

llvm-svn: 277745
2016-08-04 18:15:38 +00:00
Bruno Cardoso Lopes 4e786cf3de [ASAN] Mark test/asan/TestCases/ill.cc as unsupported on darwin
Introduced in r277621, this test is currently failing all around in
public bots: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/20787
and internal bots. Mark it as unsupported on darwin until we figure
out how it should behave.

llvm-svn: 277733
2016-08-04 15:57:30 +00:00
Bruno Cardoso Lopes 3076db8da0 [Darwin] Exclude interception union tests on Darwin and Android
Since the directory is empty on Darwin, disable the inclusion and avoid
the warning below. Exclude on Android as well to match the behavior from
lib/interception/tests/CMakeLists.txt

lit.py:
/Users/buildslave/jenkins/sharedspace/clang-R_master@2/llvm/utils/lit/lit/discovery.py:224:
warning: input
'/Users/buildslave/jenkins/sharedspace/clang-R_master@2/clang-build/Build/tools/clang/runtime/compiler-rt-bins/test/interception/Unit'
contained no tests

This fixes the above warning in some of public bots, like
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/8686

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

rdar://problem/27581108

llvm-svn: 277692
2016-08-04 04:46:39 +00:00
Dean Michael Berris 3c86ed7f60 [compiler-rt][XRay] Stash xmm registers in the trampolines
We now stash and restore the xmm registers in the trampolines so that
log handlers don't need to worry about clobbering these registers.

In response to comments in D21612.

Reviewers: rSerge, eugenis, echristo, rnk

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 277683
2016-08-04 00:09:35 +00:00
Reid Kleckner 15a3ce0f59 Only run ill.cc test on x86, 32 or 64 bit
llvm-svn: 277679
2016-08-03 23:24:06 +00:00
Ivan Krasin 9535cebb71 Add CFI tests for -lowertypetests-bitsets-level.
Summary:
-lowertypetests-bitsets-level controls which kinds of bitsets
are generated, as introduced in r277556. This change adds tests
to compiler-rt.

Reviewers: kcc

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

llvm-svn: 277632
2016-08-03 19:08:55 +00:00
Reid Kleckner 222610bf10 [ASan] Report illegal instruction exceptions in ASan
Summary:
Respect the handle_sigill common flag and handle_segv flags while we're
at it.

We still handle signals/exceptions differently on Unix and Windows. The
installation process is tricky on Windows, and difficult to push down
into sanitizer_common without concerning it with the different
static/dynamic CRT models on Windows.

Reviewers: kcc, etienneb

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 277621
2016-08-03 18:13:14 +00:00
Etienne Bergeron f856c4a4e2 [compiler-rt] Fix CHECK coding style [NFC]
llvm-svn: 277604
2016-08-03 15:47:40 +00:00
Etienne Bergeron 2bb23bfc73 [compilter-rt] Try to fix correctly rL277560
rL277560: [compiler-rt] Fix broken interception unittest
llvm-svn: 277567
2016-08-03 05:03:35 +00:00
Kostya Serebryany dcaec77936 [sanitizer] remove one redundant loop from the allocator
llvm-svn: 277563
2016-08-03 03:42:55 +00:00
Etienne Bergeron 50b98dce2e [compiler-rt] Fix broken interception unittest
Summary:
This patch is fixing a broken unittest which make the win64 bot failing.

The bug was introduce here:
  https://reviews.llvm.org/D23046

The interception code is not the same in 32-bit and in 64-bit.
The added unittest can only be patched on 32-bits.

Reviewers: rnk

Subscribers: llvm-commits, chrisha

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

llvm-svn: 277560
2016-08-03 02:44:30 +00:00
Reid Kleckner 9f0ef01197 Reduce coverage PC buffer size on 32-bit Windows to match 32-bit Linux
In r235779, Timur bumped the buffer size up to 1<<27, or about 134
million coverage points, presumably to handle Chrome. We allocate two
arrays of uptrs with this size, and this reliably exhausts all available
address space on 32-bit Windows (2 allocations of 512MB) when ASan is
also enabled.

Let's reduce the buffer size for now to stabilize the test suite. We can
re-evaluate the approach later when we've brought the Chrome ASan
builders back to life.

Kostya said that Mike reduced the number of instrumented coverage points
that LLVM emits by half since Timur made this change, so reducing this
array size should also be safe.

With this change, the 32-bit ASan tests reliably pass for me on Windows
10.

llvm-svn: 277558
2016-08-03 01:19:46 +00:00
Kostya Serebryany c49e296805 [sanitizer] refactor TransferBatch to hide the implementation. NFC expected. Second attempt after failed r276383 which was reverted.
llvm-svn: 277554
2016-08-03 00:14:10 +00:00
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