Commit Graph

2844 Commits

Author SHA1 Message Date
Matt Morehouse 14cf71a3a5 [libFuzzer] Guard symbolization with try-lock.
Summary:
When out-of-memory or timeout occurs, threads can be stopped during
symbolization, thereby causing a deadlock when the OOM/TO handlers
attempt symbolization.  We avoid this deadlock by skipping symbolization
if another thread is symbolizing.

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 331825
2018-05-08 23:45:05 +00:00
Dean Michael Berris 47e6b8c2c7 [XRay][compiler-rt] Support string-based config for Basic mode.
Summary:
This addresses http://llvm.org/PR36790.

This change allows the XRay Basic Mode implementation to use the
string-based initialization routine provided through
`__xray_log_init_mode(...)`. In the process, we've also deprecated some
flags defined for the `XRAY_OPTIONS` environment variable.

We then introduce another environment variable that can control the XRay
Basic Mode implementation through `XRAY_BASIC_OPTIONS`.

We also rename files from `xray_inmemory_log` to `xray_basic_logging` to
be more in line with the mode implementation.

Depends on D46174.

Reviewers: echristo, kpw, pelikan, eizan

Reviewed By: kpw

Subscribers: mgorny, llvm-commits

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

llvm-svn: 331507
2018-05-04 06:27:53 +00:00
Dean Michael Berris 5c389ace7d [XRay][compiler-rt] Support string-based config for FDR mode
Summary:
In this chage we add support for the string-based configuration
mechanism for configuring FDR mode.

We deprecate most of the `xray_fdr_log_*` flags that are set with the
`XRAY_OPTIONS` environment variable. Instead we make the FDR
implementation take defaults from the `XRAY_FDR_OPTIONS` environment
variable, and use the flags defined in `xray_fdr_flags.{h,cc,inc}` for
the options we support.

This change addresses http://llvm.org/PR36790.

Depends on D46173.

Reviewers: eizan, pelikan, kpw, echristo

Subscribers: llvm-commits, mgorny

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

llvm-svn: 331506
2018-05-04 06:13:35 +00:00
Dean Michael Berris f0a6927932 [XRay][compiler-rt+docs] Introduce __xray_log_init_mode(...).
Summary:
This addresses http://llvm.org/PR36790.

The change Deprecates a number of functions and types in
`include/xray/xray_log_interface.h` to recommend using string-based
configuration of XRay through the __xray_log_init_mode(...) function. In
particular, this deprecates the following:

- `__xray_set_log_impl(...)` -- users should instead use the
`__xray_log_register_mode(...)` and `__xray_log_select_mode(...)` APIs.

- `__xray_log_init(...)` -- users should instead use the
`__xray_log_init_mode(...)` function, which also requires using the
`__xray_log_register_mode(...)` and `__xray_log_select_mode(...)`
functionality.

- `__xray::FDRLoggingOptions` -- in following patches, we'll be
migrating the FDR logging implementations (and tests) to use the
string-based configuration. In later stages we'll remove the
`__xray::FDRLoggingOptions` type, and ask users to migrate to using the
string-based configuration mechanism instead.

- `__xray::BasicLoggingOptions` -- same as `__xray::FDRLoggingOptions`,
we'll be removing this type later and instead rely exclusively on the
string-based configuration API.

We also update the documentation to reflect the new advice and remove
some of the deprecated notes.

Reviewers: eizan, kpw, echristo, pelikan

Reviewed By: kpw

Subscribers: llvm-commits

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

llvm-svn: 331503
2018-05-04 06:01:12 +00:00
Volodymyr Sapsai 3835320617 Revert "Follow-up to r331378. Update tests to allow to use C atomics in C++."
It reverts commit r331484 because it caused test failures

    ThreadSanitizer-x86_64 :: Darwin/gcd-groups-destructor.mm
    ThreadSanitizer-x86_64 :: Darwin/libcxx-shared-ptr-stress.mm
    ThreadSanitizer-x86_64 :: Darwin/xpc-race.mm

Foundation.h transitively includes <atomic>, so we have a case of benign mixing
<stdatomic.h> and <atomic>.

llvm-svn: 331491
2018-05-03 23:06:37 +00:00
Volodymyr Sapsai 6e713d9866 Follow-up to r331378. Update tests to allow to use C atomics in C++.
Reviewers: kubamracek

Reviewed By: kubamracek

Subscribers: cfe-commits

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

llvm-svn: 331484
2018-05-03 21:30:47 +00:00
Matt Morehouse 52fd169035 [libFuzzer] Report at most one crash per input.
Summary:
Fixes https://github.com/google/sanitizers/issues/788/, a deadlock
caused by multiple crashes happening at the same time.  Before printing
a crash report, we now test and set an atomic flag.  If the flag was
already set, the crash handler returns immediately.

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 331310
2018-05-01 21:01:53 +00:00
Dmitry Vyukov 21dc68fe7b tsan: improve "destroy of a locked mutex" reports
1. Allow to suppress by current stack.
We generally allow to suppress by all main stacks.
Current is probably the stack one wants to use to
suppress such reports.

2. Fix last lock stack restoration.
We trimmed shadow value by storing it in u32.
This magically worked for the test that provoked
the report on the main thread. But this breaks
for locks in any other threads.

llvm-svn: 331023
2018-04-27 08:59:35 +00:00
Reid Kleckner 824eb0e6a0 [asan] Align __asan_global_start so that it works with LLD
Otherwise LLD will not align the .ASAN$GA section start, and
&__asan_globals + 1 will not be the start of the next real ASan global
metadata in .ASAN$GL.

We discovered this issue when attempting to use LLD on Windows in
Chromium: https://crbug.com/837090

llvm-svn: 330990
2018-04-26 20:46:50 +00:00
Petar Jovanovic 152060275f Add s390x to XFAIL for illegal_read/write_test.cc
Follow up to r330840 and r330849.
It seems that s390 is also not distinguishing illegal WRITE and READ memory
access.
Add s390x to XFAIL for the tests.

llvm-svn: 330863
2018-04-25 19:34:48 +00:00
Kostya Kortchinsky d8803d3d92 [scudo] Adding an interface function to print allocator stats
Summary:
This adds `__scudo_print_stats` as an interface function to display the Primary
and Secondary allocator statistics for Scudo.

Reviewers: alekseyshl, flowerhack

Reviewed By: alekseyshl

Subscribers: delcypher, llvm-commits, #sanitizers

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

llvm-svn: 330857
2018-04-25 18:52:29 +00:00
Petar Jovanovic 3517ece21f Finetune supported arches for the tests added in r330840
r330840 introduced two tests that may not be supported on all architectures.
powerpc64 seems to be one of those.

llvm-svn: 330849
2018-04-25 17:34:30 +00:00
Petar Jovanovic 1dd3584ec0 [mips] Implement GetWriteFlag() for mips
The read/write flag is set by manually decoding the instruction that caused
the exception. It is implemented this way because the cause register which
contains the needed flag was removed from the signal context structure which
the user handler receives from the kernel.

Patch by Milos Stojanovic.

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

llvm-svn: 330840
2018-04-25 16:21:00 +00:00
Peter Collingbourne 7b17c9d05c asan: Mark printf-4.c as unsupported on Windows.
Although sprintf is not intercepted on Windows, this test can pass
if sprintf calls memmove, which is intercepted, so we can't XFAIL it.

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

llvm-svn: 330469
2018-04-20 19:07:35 +00:00
Dan Liew b7a3bc99c9 [LibFuzzer] Report when custom counters are available.
This upstreams a feature from the JFS solver's fork of LibFuzzer.

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

llvm-svn: 330391
2018-04-20 06:46:19 +00:00
Alex Shlyapnikov 02f7841e4a [HWASan] Add "N" suffix to generic __hwasan_load/store.
Summary:
"N" suffix is added by the instrumentation and interface functions
are expected to be exported from the library as __hwasan_loadN* and
__hwasan_storeN*.

Reviewers: eugenis

Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 330297
2018-04-18 22:05:18 +00:00
Kuba Mracek 296ce3bd23 [tsan] Add interceptors for objc_sync_enter and objc_sync_exit
Objective-C's @synchronize synchronization primitive uses calls to objc_sync_enter and objc_sync_exit runtime functions. In most cases, they end up just calling pthread_mutex_lock/pthread_mutex_unlock, but there are some cases where the synchronization from pthread_mutex_lock/pthread_mutex_unlock interceptors isn't enough. Let's add explicit interceptors for objc_sync_enter and objc_sync_exit to handle all cases.

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

llvm-svn: 329982
2018-04-13 01:05:29 +00:00
Kuba Mracek 0fb14e944c [asan] Reduce flakiness in stack-overflow detection
IsStackOverflow only treats accesses within 512 bytes of SP as stack-overflow. This should really be the size of a page instead.

The scariness_score_test.cc triggers stack overflow with frames that are even larger than a page, which can also trigger a fault that will not be recognized as stack-overflow. Let's just use smaller frames.

llvm-svn: 329980
2018-04-13 00:29:24 +00:00
Simon Dardis dfee530748 [compiler-rt][asan][mips] UnXFAIL some consistently passing tests
llvm-svn: 329688
2018-04-10 11:09:17 +00:00
Vitaly Buka 9802089e13 libFuzzer, OpenBSD support
Summary:
- Enabling libfuzzer on OpenBSD
- OpenBSD can t support asan, msan ... the tests can t be run.

Patch by David CARLIER

Reviewers: eugenis, phosek, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, mgorny, krytarowski, llvm-commits, #sanitizers

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

llvm-svn: 329631
2018-04-09 22:38:26 +00:00
Peter Collingbourne 6662e9890b shadowcallstack: Make runtime tests compatible with aarch64.
Differential Revision: https://reviews.llvm.org/D45303

llvm-svn: 329614
2018-04-09 20:18:10 +00:00
Matt Morehouse fcc97b29c1 [libFuzzer] Print a correct error message when a directory can't be
opened.

Summary:
Currently if the directory cannot be opened for a reason other than
non-existence (e.g. too many open file descriptors) the error message
printed is incredibly confusing.

Patch By: Alex Gaynor

Reviewers: kcc, morehouse

Reviewed By: morehouse

Subscribers: delcypher, llvm-commits, Sanitizers

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

llvm-svn: 329438
2018-04-06 18:15:24 +00:00
Simon Dardis a1b7447dfd [compiler-rt][dfsan][mips] UnXPASS a consistently passing test
llvm-svn: 329422
2018-04-06 17:03:36 +00:00
Kostya Kortchinsky 0716fb9376 [asan] Fix aligned_alloc test case
Summary:
Under some circumstances (that I haven't dug further into), the first stack
frame for the test looks like:
`#0 0x4e6038 in __interceptor_memalign.localalias.1 ...compiler-rt/lib/asan/asan_malloc_linux.cc:113`
which isn't matched by the current CHECK.

Expand the CHECK to match aligned_alloc or memalign. Hopefully this should fix
the PowerPC issue as well, otherwise we'll bring back the FIXME.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 329226
2018-04-04 20:03:16 +00:00
Vlad Tsyrklevich 1781d105ed Add simple runtime tests for shadowcallstack
Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h

Reviewers: pcc, kcc, delcypher, eugenis, filcab

Reviewed By: pcc

Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc

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

llvm-svn: 329210
2018-04-04 17:53:33 +00:00
Rong Xu 1a45e0cccc [profile] Move newly added test to the supported platform
Move test/profile/instrprof-value-merge.c from r328987 to Linux directory.

llvm-svn: 329016
2018-04-02 21:24:07 +00:00
Rong Xu 95ab7582f0 [profile] Fix value profile runtime merging issues
This patch fixes the following issues:
(1) The strong definition of the merge hook function was not working which
breaks the online value profile merging. This patch removes the weak
attribute of VPMergeHook and assigns the value dynamically.
(2) Truncate the proifle file so that we don't have garbage data at the end of
the file.
(3) Add new __llvm_profile_instrument_target_value() interface to do the value
profile update in batch. This is needed as the original incremental by 1
in __llvm_profile_instrument_target() is too slow for online merge.

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

llvm-svn: 328987
2018-04-02 16:57:00 +00:00
Alex Shlyapnikov 0ee5a5577c [ASan] Disable new ASan error reporting tests on various ARMs.
As many other ASan tests already, has to disable these failing tests on
arm, armhf and aarch64 configs.

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

llvm-svn: 328849
2018-03-30 00:03:36 +00:00
Dan Liew 0f08dff1b5 [asan] Split the `throw_invoke_test.cc` into a Linux specific variant
and the general version to avoid use of libstdc++ on non-Linux
platforms.

This is motivated by the fact that using `libstdc++` is deprecated on
Darwin and maybe removed some day.

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

llvm-svn: 328775
2018-03-29 13:53:50 +00:00
Alex Shlyapnikov b43b558012 [ASan] Disable aligned_alloc-alignment.cc on PPC64.
Differential Revision: https://reviews.llvm.org/D44404

llvm-svn: 328753
2018-03-29 02:18:57 +00:00
Alex Shlyapnikov 239533319f [ASan] Disable aligned_alloc-alignment.cc on ppc64be
Differential Revision: https://reviews.llvm.org/D44404

llvm-svn: 328742
2018-03-29 00:09:12 +00:00
Alex Shlyapnikov 5062d7a22d [ASan] Disable aligned_alloc-alignment.cc test on gcc.
This check "CHECK: {{#0 0x.* in .*aligned_alloc}}" fails on ppc64be, gcc
build. Disabling the test for gcc for now.

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

llvm-svn: 328741
2018-03-28 23:01:04 +00:00
Alex Shlyapnikov b276621d3d [ASan] Disable aligned_alloc-alignment.cc on Android.
Differential Revision: https://reviews.llvm.org/D44404

llvm-svn: 328734
2018-03-28 22:00:08 +00:00
Alex Shlyapnikov 506b8388ed [ASan] Add aligned_alloc declaration to aligned_alloc-alignment.cc test.
aligned_alloc is not always defined in headers.

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

llvm-svn: 328726
2018-03-28 19:53:55 +00:00
Alex Shlyapnikov 10f50a44c1 [ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ing
Summary:
Currently many allocator specific errors (OOM, for example) are reported as
a text message and CHECK(0) termination, not stack, no details, not too
helpful nor informative. To improve the situation, ASan detailed errors were
defined and reported under the appropriate conditions.

Issue: https://github.com/google/sanitizers/issues/887

Reviewers: eugenis

Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 328722
2018-03-28 18:22:40 +00:00
Alex Shlyapnikov 0e44f5eb8b [HWASan] Make use-after-free c, not c++ test.
To minimize testing surface (remove libstdc++ from the picture, for
one), make use-after-free c, not c++ test.

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

llvm-svn: 328646
2018-03-27 17:45:53 +00:00
Matt Morehouse 86db6dd2ed [libFuzzer] Disable optimization for exit_on_src_pos.test.
Test fails on Darwin with -O2.

llvm-svn: 328634
2018-03-27 16:40:34 +00:00
Matt Morehouse 22a1afd99f [libFuzzer] Place volatile after pointer types.
For a few tests, volatile was placed before the '*' in pointer
declarations, resulting in it applying to the underlying data rather
than the pointer itself.  Placing volatile after the '*' allows us to
switch those tests to -O2.

llvm-svn: 328633
2018-03-27 16:40:20 +00:00
Alex Shlyapnikov b66b8fd0f2 [HWASan] Relax use-after-free.cc test matching rules.
Relax use-after-free.cc test matching rules to cover more malloc/free
interceptor names variations.

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

llvm-svn: 328630
2018-03-27 16:04:40 +00:00
Evgeniy Stepanov 7989d8da20 Revert "[asan] Replace vfork with fork."
Replacing vfork with fork results in significant slowdown of certain
apps (in particular, memcached).

This reverts r327752.

llvm-svn: 328600
2018-03-27 00:31:16 +00:00
Matt Morehouse 93ce24838c [libFuzzer] Do not optimize minimize_two_crashes.test.
Speculative fix for build bot breakage on Mac.

llvm-svn: 328576
2018-03-26 19:36:20 +00:00
Vitaly Buka 48d19f6961 [sanitizer] Make test compatible with Darwin
llvm-svn: 328467
2018-03-26 01:29:48 +00:00
Vitaly Buka 8616363017 Mmap interceptor providing mprotect support
Summary:
- Intercepting mprotect calls.
- Fixing forgotten flag check.

Patch by David CARLIER

Reviewers: vitalybuka, vsk

Subscribers: delcypher, srhines, kubamracek, llvm-commits, #sanitizers

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

llvm-svn: 328415
2018-03-24 07:45:24 +00:00
Alex Shlyapnikov 53ddbac32b [HWASan] Fix use-after-free.cc test on x86-64
Differential Revision: https://reviews.llvm.org/D44705

llvm-svn: 328407
2018-03-24 02:10:49 +00:00
Matt Morehouse 5317f2e4c9 [libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.
Summary:
Disables certain CMP optimizations to improve fuzzing signal under -O1
and -O2.

Switches all fuzzer tests to -O2 except for a few leak tests where the
leak is optimized out under -O2.

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: cfe-commits, llvm-commits

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

llvm-svn: 328384
2018-03-23 23:35:28 +00:00
Vitaly Buka b53180846b FreeBSD sanitizer common, intercept couple of more functions
Summary:
Intercepts lstat, acct, access, faccessat and strlcpy/strlcat

Patch by David CARLIER

Reviewers: visa, vitalybuka

Subscribers: krytarowski, fedor.sergeev, srhines, kubamracek, llvm-commits, #sanitizers

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

llvm-svn: 328376
2018-03-23 21:44:59 +00:00
Vitaly Buka bb096c27bf Revert "Mmap interceptor providing mprotect support"
Breaks Darwin.

This reverts commit r328369.

llvm-svn: 328375
2018-03-23 21:44:59 +00:00
Vitaly Buka e4d34c0d56 Mmap interceptor providing mprotect support
Summary:
- Intercepting mprotect calls.
- Fixing forgotten flag check.

Patch by David CARLIER

Reviewers: vitalybuka, vsk

Reviewed By: vitalybuka

Subscribers: srhines, kubamracek, llvm-commits, #sanitizers

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

llvm-svn: 328369
2018-03-23 20:59:51 +00:00
Vitaly Buka 8980449bb6 Mmap interceptor new option, Write Exec runtime detector
Summary:
Following-up the refactoring of mmap interceptors, adding a new common
option to detect PROT_WRITE|PROT_EXEC pages request.

Patch by David CARLIER

Reviewers: vitalybuka, vsk

Reviewed By: vitalybuka

Subscribers: krytarowski, #sanitizers

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

llvm-svn: 328151
2018-03-21 21:25:07 +00:00
George Karpenkov 430aa7405f [libFuzzer] Disable equivalence-signals test on Darwin due to persistent failures
llvm-svn: 328125
2018-03-21 17:55:36 +00:00