Commit Graph

855 Commits

Author SHA1 Message Date
Kuba Mracek 0b16ae5090 [asan] Remove column numbers from test expectations in invalid-pointer-pairs.cc
This is failing on some of our internal bots because we're using different symbolizers. It doesn't seem important and we never test for column numbers in any other tests, so let's just remove it.

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

llvm-svn: 298822
2017-03-26 21:20:42 +00:00
Evgeniy Stepanov 656bc5bb5c Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.
Only depend on LLD if it is going to be built.

Re-land of r298174 which got reverted in r298287.

llvm-svn: 298753
2017-03-25 00:42:25 +00:00
Alex Shlyapnikov f51fafde1e Fix flaky strtok.c test.
Asserting the result of strtok when we expect delimiter overflow is
flaky, the result depends on the random state of memory right after the
delimiters.

llvm-svn: 298743
2017-03-24 21:43:56 +00:00
Alex Shlyapnikov 4ab77b9f28 [asan] Add an interceptor for strtok
Summary:
This change addresses https://github.com/google/sanitizers/issues/766. I
tested the change with make check-asan and the newly added test case.

Reviewers: ygribov, kcc, alekseyshl

Subscribers: kubamracek, llvm-commits

Patch by mrigger

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

llvm-svn: 298650
2017-03-23 21:39:52 +00:00
Reid Kleckner 731bc9d2fe Use lld-link /nopdb to suppress PDB generation when DWARF is required
Fixes cfi/stats.cpp and asan/fuse-lld.cc on Windows.

llvm-svn: 298545
2017-03-22 19:49:29 +00:00
Reid Kleckner 2b19203e19 Revert "[compiler-rt][asan] Turn on ASAN unittests for win64."
This reverts commit r296878.

These test still require too much swap to pass reliably.

llvm-svn: 298450
2017-03-21 22:07:06 +00:00
Evgeniy Stepanov 3bf85d3124 Revert r298174, r298173, r298169, r298159.
Revert "Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF."
Revert "[asan] Remove gc-sections test with bfd."
Revert "[asan] Disable globals-gc test with ld.bfd."
Revert "[asan] Fix dead stripping of globals on Linux (compiler-rt)"

OOM in gold linker.

llvm-svn: 298287
2017-03-20 18:45:27 +00:00
Kuba Mracek 5971469566 Disable stack-use-after-return.cc on AArch64. The test was not testing the right thing before (the call to pthread_attr_setstacksize wasn't doing anything) anyway, and now it's running out of stack due to an unrelated change.
llvm-svn: 298267
2017-03-20 16:36:34 +00:00
Kuba Mracek 662c9b1e81 Re-commit of r296706 ("Increase stack size for stack-use-after-return test"). Hopefully the recent changes in the test will make it not flaky anymore.
Differential Revision: https://reviews.llvm.org/D30267

llvm-svn: 298200
2017-03-19 00:59:08 +00:00
Kuba Mracek 61f8bca7c5 Apparently, PTHREAD_STACK_MIN can be in limits.h on some systems...
llvm-svn: 298196
2017-03-18 22:01:33 +00:00
Kuba Mracek 0d9b01fb95 Change stack-use-after-return.cc to respect PTHREAD_STACK_MIN before calling pthread_attr_setstacksize. To investigate <https://reviews.llvm.org/D30267>. NFC.
llvm-svn: 298195
2017-03-18 21:35:12 +00:00
Kuba Mracek 07183b4a82 Add extra return value checks into stack-use-after-return.cc to help diagnose AArch64 test failures for <https://reviews.llvm.org/D30267>. NFC.
llvm-svn: 298193
2017-03-18 20:39:31 +00:00
Evgeniy Stepanov 0e6cb1925c Fix sanitizer tests with LLVM_TOOL_LLD_BUILD=OFF.
Only depend on LLD if it is going to be built.

llvm-svn: 298174
2017-03-18 00:25:43 +00:00
Evgeniy Stepanov 7453bb7940 [asan] Remove gc-sections test with bfd.
It used to be XFAIL: *, but with the new implementation it passes in some cases
and fails in other. There are similar tests for gold and lld that are not
flaky, and a positive test for bfd that makes sure that were are not breaking
existing functionality.

llvm-svn: 298173
2017-03-18 00:25:40 +00:00
Evgeniy Stepanov 9424af1b30 [asan] Disable globals-gc test with ld.bfd.
Fails on clang-cmake-armv7-a15-full.

llvm-svn: 298169
2017-03-17 23:40:50 +00:00
Evgeniy Stepanov 79ee0c1813 [asan] Fix dead stripping of globals on Linux (compiler-rt)
Runtime support for the new instrumentation of globals based on !associated, and a bunch of tests.

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

llvm-svn: 298159
2017-03-17 22:17:38 +00:00
Kostya Serebryany 82a41dd6c4 [asan] add one more argument to __sanitizer_print_memory_profile, remove a redundant weak definition.
llvm-svn: 297914
2017-03-15 23:27:14 +00:00
Filipe Cabecinhas f7c7c11312 [asan] Split SIGSEGV / SIGBUS handling so we can handle only one of them and not the other.
Summary: This is useful in some platforms where one of these signals is special.

Reviewers: kubamracek, kcc

Subscribers: llvm-commits

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

llvm-svn: 297665
2017-03-13 21:06:41 +00:00
Etienne Bergeron 4edb9fd3c8 [compiler-rt][asan] Turn on ASAN unittests for win64.
Summary:
Asan is now working on windows 64-bit.
This patch is turning on the unittest.

Reviewers: rnk

Reviewed By: rnk

Subscribers: kubamracek, dberris, beanz, mgorny, llvm-commits, chrisha

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

llvm-svn: 296878
2017-03-03 16:35:46 +00:00
Francis Ricci ddee63ffb2 Revert "Increase stack size for stack-use-after-return test"
Reverting due to failures on aarch64

This reverts commit f8ff7e585134196e8482e4dd8752cd4c22cf027a.

llvm-svn: 296719
2017-03-02 00:12:56 +00:00
Francis Ricci bdc963a98c Increase stack size for stack-use-after-return test
Summary:
The current size is flaky, as revealed by checking
the stack size attr after setting it.

Reviewers: kubamracek, rnk

Subscribers: llvm-commits

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

llvm-svn: 296706
2017-03-01 23:18:13 +00:00
Filipe Cabecinhas 74ad311556 Reapply r296419: [asan] Print a "PC is at a non-executable memory region" message if that's the case
Summary: Points the user to look at function pointer assignments.

Reviewers: kcc, eugenis, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 296653
2017-03-01 18:52:11 +00:00
Filipe Cabecinhas 6e36c11d2a Revert r296419 since the strings appear to need some tweaking.
llvm-svn: 296428
2017-02-28 02:45:46 +00:00
Filipe Cabecinhas f1d4ae579d [non-executable-pc.cpp] Try to fix clang-ppc64be buildbot.
llvm-svn: 296424
2017-02-28 02:05:53 +00:00
Filipe Cabecinhas cd643f6324 [asan] Print a "PC is at a non-executable memory region" message if that's the case
Summary: Points the user to look at function pointer assignments.

Reviewers: kcc, eugenis, kubamracek

Subscribers: llvm-commits

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

llvm-svn: 296419
2017-02-28 00:56:43 +00:00
Etienne Bergeron fc68c2c777 [compiler-rt][asan] Add support for desallocation of unhandled pointers
Summary: On windows 10, the ucrt DLL is performing allocations before the function hooking and there are multiple allocations not handled by Asan. When a free occur at the end of the process, asan is reporting desallocations not malloc-ed.

Reviewers: rnk, kcc

Reviewed By: rnk, kcc

Subscribers: kcc, llvm-commits, kubamracek, chrisha, dberris

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

llvm-svn: 295730
2017-02-21 16:09:38 +00:00
Etienne Bergeron 60ce0f667c [compiler-rt][asan|win] Force tls_init test to use dynamic runtime
Summary:
There is no guarantee that the tls_init is executed on the static runtime
(/MT).

On windows 7, this unittest is failing.
On windows 10, I believe it's working because of the new CRT.

On ASAN side, it doesn't matter that the hook point is run or not.
It must be run only if there is other tls_initializer that are registered.

Reviewers: rnk, chrisha

Reviewed By: rnk

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 295057
2017-02-14 15:21:53 +00:00
Marcos Pividori 0033fcf72e [sanitizer] Add weak hooks for Windows.
Add support for weak hooks on Windows, as we do on Linux and Darwin.
As we use the macro: `SANITIZER_INTERFACE_WEAK_DEF()` it was not necessary to
modify the header file: `sanitizer_common_interceptors.h`.

After this diff, many tests were fixed for libFuzzer.

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

llvm-svn: 294409
2017-02-08 06:31:56 +00:00
Kostya Serebryany 263722f40f [asan] replace std::random_shuffle with std::shuffle in tests since std::random_shuffle is being deprecated in C++17; NFC
llvm-svn: 294370
2017-02-07 23:13:10 +00:00
Marcos Pividori e49ec6d57c [asan] Intercept SetUnhandledExceptionFilter.
In this diff I update the code for asan on Windows, so we can intercept
SetUnhandledExceptionFilter and catch some exceptions depending on the result of
IsHandledDeadlyException() (which depends on asan flags).

This way we have the same behavior on Windows and Posix systems.
On Posix, we intercept signal and sigaction, so user's code can only register
signal handlers for signals that are not handled by asan.
After this diff, the same happens on Windows, user's code can only register
exception handlers for exceptions that are not handled by asan.

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

llvm-svn: 293957
2017-02-02 23:02:04 +00:00
Marcos Pividori 8789a5a9f6 [sanitizer] Fix interface tests when SANITIZER_CAN_USE_CXXABI is true.
We ignore `__ubsan_handle_dynamic_type_cache_miss*` symbols when
`SANITIZER_CAN_USE_CXXABI` is true. Because they are included in the
library but they are not included in the interface lists.

llvm-svn: 293711
2017-01-31 22:57:55 +00:00
Marcos Pividori 8dac0cede7 [sanitizer] Fix interface test on Darwin, failing after 293682.
The test was failing because we export the functions: "__sanitizer_mz*" but they
are not included in the general interface lists.
Also, weak undefined symbols are tagged with U by `nm -g` on Darwin.

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

llvm-svn: 293710
2017-01-31 22:57:50 +00:00
Marcos Pividori 25527bf021 [sanitizer] Add list of symbols exported in sanitizers' interface.
Add a new auxiliary file to each sanitizer: sanitizer_interface.inc, listing all
the functions exported, with the macros: INTERFACE_FUNCTION() and
INTERFACE_WEAK_FUNCTION().
So, when we need to define or repeat a procedure for each function in the
sanitizer's interface, we can define the macros and include that header.
In particular, these files are needed for Windows, in the nexts commits.
Also, this files could replace the existing files: weak_symbols.txt for Apple.
Instead of reading weak_symbols.txt to get the list of weak symbols, we could
read the file sanitizer_interface.inc and consider all the symbols included with
the macro INTERFACE_WEAK_FUNCTION(Name).

In this commit, I only include these files to the sanitizers that work on
Windows. We could do the same for the rest of the sanitizers when needed.

I updated tests for: Linux, Darwin and Windows. If a new function is exported
but is not present in the interface list, the tests
"interface_symbols_[darwin|windows|linux].c" fail.

Also, I remove the comments: "/* OPTIONAL */" which are not required any more,
because we use the macro: INTERFACE_WEAK_FUNCTION() for weak functions.

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

llvm-svn: 293682
2017-01-31 20:23:21 +00:00
Maxim Ostapenko 651cfe3cfa [lsan] Renable LSan for x86 Linux
The missed clang part was committed at https://reviews.llvm.org/rL293609 thus
we can reenable LSan for x86 Linux.

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

llvm-svn: 293610
2017-01-31 07:15:37 +00:00
Dimitry Andric f2ac1d1df2 Recommit: Stop intercepting some malloc-related functions on FreeBSD and
macOS

Summary:
In https://bugs.freebsd.org/215125 I was notified that some configure
scripts attempt to test for the Linux-specific `mallinfo` and `mallopt`
functions by compiling and linking small programs which references the
functions, and observing whether that results in errors.

FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so
normally these tests would fail, but when sanitizers are enabled, they
incorrectly succeed, because the sanitizers define interceptors for
these functions.  This also applies to some other malloc-related
functions, such as `memalign`, `pvalloc` and `cfree`.

Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`,
`pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers.

Also delete the non-functional `cfree` wrapper for Windows, to fix the
test cases on that platform.

Reviewers: emaste, kcc, rnk

Subscribers: timurrrr, eugenis, hans, joerg, llvm-commits, kubamracek

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

llvm-svn: 293536
2017-01-30 19:06:13 +00:00
Marcos Pividori bf0261d518 [asan] Fix tests for exported interfaces.
Add "OPTIONAL" comment to declaration of weak function in the internal
interface. This fix the tests `interface_symbols_linux.c` and
`interface_symbols_darwin.c` which were failing after r293423.

llvm-svn: 293442
2017-01-29 20:19:08 +00:00
Marcos Pividori 8650f5d1a1 General definition for weak functions
In this diff, I define a general macro for defining weak functions
with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()".
This way, we simplify the implementation for different platforms.

For example, we cannot define weak functions on Windows, but we can
use linker pragmas to create an alias to a default implementation.
All of these implementation details are hidden in the new macro.

Also, as I modify the name for exported weak symbols on Windows, I
needed to temporarily disable "dll_host" test for asan, which checks
the list of functions included in asan_win_dll_thunk.

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

llvm-svn: 293419
2017-01-29 05:44:59 +00:00
Evgeniy Stepanov 8bf0633288 Revert "Stop intercepting some malloc-related functions on FreeBSD and macOS"
This reverts r293337, which breaks tests on Windows:

malloc-no-intercept-499eb7.o : error LNK2019: unresolved external symbol _mallinfo referenced in function _main

llvm-svn: 293346
2017-01-27 23:53:20 +00:00
Dimitry Andric 47e0ef3148 Stop intercepting some malloc-related functions on FreeBSD and macOS
Summary:
In https://bugs.freebsd.org/215125 I was notified that some configure
scripts attempt to test for the Linux-specific `mallinfo` and `mallopt`
functions by compiling and linking small programs which references the
functions, and observing whether that results in errors.

FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so
normally these tests would fail, but when sanitizers are enabled, they
incorrectly succeed, because the sanitizers define interceptors for
these functions.  This also applies to some other malloc-related
functions, such as `memalign`, `pvalloc` and `cfree`.

Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`,
`pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers.

Reviewers: emaste, kcc

Subscribers: hans, joerg, llvm-commits, kubamracek

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

llvm-svn: 293337
2017-01-27 22:19:11 +00:00
Kostya Serebryany 99259ee40c [asan] fix __sanitizer_cov_with_check to get the correct caller PC. Before this fix the code relied on the fact that the other function (__sanitizer_cov) is inlined. This was true with clang builds on x86, but not true with gcc builds on x86 and on PPC. This caused bot redness after r292862
llvm-svn: 292998
2017-01-25 01:14:24 +00:00
Kostya Serebryany d843cd55b5 [asan] temporarily disable parts of a test that fail after r292862
llvm-svn: 292994
2017-01-24 23:58:21 +00:00
Greg Parker 200ead56c6 [test] Prevent false detection of an `UNSUPPORTED:` directive by lit.
llvm-svn: 292902
2017-01-24 09:20:50 +00:00
Evgeniy Stepanov 0f550c8176 Revert "[lsan] Enable LSan for x86 Linux."
Breaks tests on i686/Linux due to missing clang driver support:
  error: unsupported option '-fsanitize=leak' for target 'i386-unknown-linux-gnu'

llvm-svn: 292844
2017-01-23 22:52:31 +00:00
Maxim Ostapenko 2523faf677 [lsan] Enable LSan for x86 Linux.
People keep asking LSan to be available on 32 bit targets (e.g. https://github.com/google/sanitizers/issues/403)
despite the fact that false negative ratio might be huge (up to 85%). This happens for big real world applications
that may contain random binary data (e.g. browser), but for smaller apps situation is not so terrible and LSan still might be useful.
This patch adds initial support for x86 Linux (disabled by default), ARM32 is in TODO list.
We used this patch (well, ported to GCC) on our 32 bit mobile emulators and it worked pretty fine
thus I'm posting it here to initiate further discussion.

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

llvm-svn: 292775
2017-01-23 08:45:17 +00:00
Kuba Mracek 245318cb05 [lit] Limit parallelism of sanitizer tests on Darwin [compiler-rt part, take 2]
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests.

This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests.

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

llvm-svn: 292549
2017-01-20 00:25:01 +00:00
Alex Shlyapnikov a8ba9c8e66 Whenever reasonable, merge ASAN quarantine batches to save memory.
Summary:
There are cases when thread local quarantine drains almost empty
quarantine batches into the global quarantine. The current approach leaves
them almost empty, which might create a huge memory overhead (each batch
is 4K/8K, depends on bitness).

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 292525
2017-01-19 22:15:54 +00:00
Kuba Mracek 5da6f6db9a Revert r292232.
llvm-svn: 292236
2017-01-17 18:06:07 +00:00
Kuba Mracek a802a50963 [lit] Limit parallelism of sanitizer tests on Darwin [compiler-rt part]
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests.

This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests.

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

llvm-svn: 292232
2017-01-17 17:18:18 +00:00
Alex Shlyapnikov c4427a3976 ASAN activate/deactive controls thread_local_quarantine_size_kb option.
Summary:
Bypass quarantine altogether when quarantine size is set ot zero.
Also, relax atomic load/store of quarantine parameters, the
release/acquire semantics is an overkill here.

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits, mehdi_amini

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

llvm-svn: 291791
2017-01-12 18:51:25 +00:00
Alex Shlyapnikov c83efa85e2 Repoison the entire ASan chunk if it is not in active use.
Summary:
Repoisoning just the minimal redzones might leave an unpoisoned
gap of the size of the actual redzone minus minimal redzone size.
After ASan activation the actual redzone might be bigger than the minimal
size and ASan allocator assumes that the chunk returned by the common
allocator is either entirely poisoned or entirely not poisoned (it's too
expensive to check the entire chunk or always poison one).

Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 291714
2017-01-11 22:10:35 +00:00