Commit Graph

10027 Commits

Author SHA1 Message Date
Kostya Kortchinsky daca5ba7dd [sanitizer] Correct name length computation for some Fuchsia vmos
Summary:
This was missed during the review of D38595, but the vmo name size computation
should use internal_strlen, not sizeof, otherwise we end up with 7 character
names.

Reviewers: mcgrathr, flowerhack

Reviewed By: mcgrathr

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

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

llvm-svn: 329842
2018-04-11 18:55:26 +00:00
George Karpenkov 0fc4b7f429 [xray] Fix OS X bots.
OS X has "fat" executables which contain the code for all architectures.

llvm-svn: 329832
2018-04-11 18:00:09 +00:00
Aaron Smith 56e6e0d352 Revert "[cmake] Remove duplicate command line options from build"
The Android sanitizer buildbot is failing with this change and it
looks like an additional change to cmake is necessary to fix the 
build. Reverting this change for now.

llvm-svn: 329828
2018-04-11 17:31:18 +00:00
Aaron Smith 112d6760a8 [cmake] Remove duplicate command line options from build
CMAKE_CXX_FLAGS was added twice to the command line. This causes the command 
line options to be doubled which works until it doesn't as not all options 
can be specified twice. 

For example,

clang-cl foo.c /GS- /GS- -mllvm -small-loop-cost=1 -mllvm -small-loop-cost=1
clang (LLVM option parsing): for the -small-loop-cost option: may only occur zero or one times!

llvm-svn: 329817
2018-04-11 14:56:35 +00:00
Dean Michael Berris 6bb0157dca [XRay][compiler-rt] Fix osx-based builds
This is a follow-up to D45474.

llvm-svn: 329776
2018-04-11 05:16:11 +00:00
Dean Michael Berris 826e666cc7 [XRay][clang+compiler-rt] Support build-time mode selection
Summary:
This patch implements the `-fxray-modes=` flag which allows users
building with XRay instrumentation to decide which modes to pre-package
into the binary being linked. The default is the status quo, which will
link all the available modes.

For this to work we're also breaking apart the mode implementations
(xray-fdr and xray-basic) from the main xray runtime. This gives more
granular control of which modes are pre-packaged, and picked from
clang's invocation.

This fixes llvm.org/PR37066.

Note that in the future, we may change the default for clang to only
contain the profiling implementation under development in D44620, when
that implementation is ready.

Reviewers: echristo, eizan, chandlerc

Reviewed By: echristo

Subscribers: mgorny, mgrang, cfe-commits, llvm-commits

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

llvm-svn: 329772
2018-04-11 01:28:25 +00:00
Kostya Kortchinsky 141139e695 [sanitizer] Allow BackgroundThread to not depend on StackDepot v2
Summary:
This is a redo of D45296.
It looks like the random stack-protector issues I was getting were coming from
my Android emulator, and updating everything all around and relaunching stuff
ended up making it go away.
I guess I'll have to see how it behaves on the bots.
Only additional change from the previous CL is some `const` were appropriate.

Reviewers: alekseyshl

Reviewed By: alekseyshl

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

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

llvm-svn: 329706
2018-04-10 14:41:40 +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
Petr Hosek 00b9248cb3 [sanitizer] Enable threads for libc++ build used by the symbolizer
Disabling threads makes <atomic> unusable, but this is needed by LLVM
libraries that are dependencies of the symbolizer.

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

llvm-svn: 329672
2018-04-10 05:54:36 +00:00
Vitaly Buka 3539c09d3b GetRandom / OpenBSD, using getentropy to get high quality randomness
Summary:
- getentropy presence since late 2014, safe to use.
- guarantees to delivers good random data up to 256 bytes.
- fall back to /dev/urandom as long the buffer is correct.

Patch by David CARLIER

Reviewers: kubamracek, vitalybuka

Reviewed By: vitalybuka

Subscribers: cryptoad, llvm-commits, #sanitizers

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

llvm-svn: 329633
2018-04-09 22:46:40 +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
Kostya Kortchinsky 09873b2bcf [sanitizer] Reverting rCRT329595
Summary:
Even this version seems to mess with Android somehow. Reverting for now while
I figure out what's up.

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

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

llvm-svn: 329606
2018-04-09 19:18:50 +00:00
Kostya Kortchinsky dd7c60c2d2 [sanitizer] Allow BackgroundThread to not depend on StackDepot
Summary:
Still pursuing the ultimate goal of splitting the Symbolizer code from
RTSanitizerCommon core, allow `BackgroundThread` to work even when not linked
with `sanitizer_stackdepot.cc`. There is no reason this function should pull in
the whole `StackDepot` if symbolization is not supported.

Currently this has no functional change as the depot is always linked anyway.

Reviewers: alekseyshl

Reviewed By: alekseyshl

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

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

llvm-svn: 329595
2018-04-09 17:25:57 +00:00
Alex Shlyapnikov 40c90bfba8 [ASan] NFC: make use of a new ErrorBase ctor
Summary:
Minor style changes to complement D44404:
- make use of a new ErrorBase ctor
- de-duplicate a comment about VS2013 support

Reviewers: eugenis

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

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

llvm-svn: 329586
2018-04-09 16:00: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
Petr Hosek fb6a4a7907 [CMake] Support statically linked libc++abi and libunwind
This expands the CMake check to handle both statically and dynamically
linked version of libc++abi and libunwind and matches the implemnetation
used elsewhere in LLVM.

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

llvm-svn: 329205
2018-04-04 16:27:33 +00:00
Kostya Kortchinsky 9336ab6996 [sanitizer] Split stacktrace/symbolizer: Windows unwind
Summary:
The purpose of this set of changes is to separate stackframe/symbolizer support into their own RT within sanitizer_common.
Sanitizers with no use for those could then be built without the extraneous dependencies pulled in by the default visibility interface functions.
I am aiming to do small changes for specific platforms.

In this one, we split the unwind functions from sanitizer_win.cc into their own sanitizer_unwind_win.cc.

Reviewers: alekseyshl, rnk

Reviewed By: alekseyshl, rnk

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

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

llvm-svn: 329204
2018-04-04 15:23:30 +00:00
Dean Michael Berris fe79b04a74 [XRay][compiler-rt] Build XRay runtime for OpenBSD
Summary:
This is D45125; the patch enables the build of XRay on OpenBSD. We also
introduce some OpenBSD specific changes to the runtime implementation,
involving how we get the TSC rate through the syscall interface specific
to OpenBSD.

Reviewers: dberris

Authored by: devnexen

Subscribers: dberris, mgorny, krytarowski, llvm-commits

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

llvm-svn: 329189
2018-04-04 13:04:15 +00:00
Kostya Kortchinsky 2c5f944015 [sanitizer] Remove empty Symbolizer PrepareForSandboxing
Summary:
`Symbolizer::PrepareForSandboxing` is empty for all platforms and apparently
has been for a while (D10213). Remove it, and shuffle things around so that the
platform specific code is now in `PlatformPrepareForSandboxing`.

This allows to have one less symbolizer dependency in a common file, which
helps for the upcoming split.

Also remove `SymbolizerPrepareForSandboxing` in tsan_go which appears to not
be used anywhere.

Reviewers: alekseyshl, eugenis, dvyukov, mcgrathr

Reviewed By: alekseyshl

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

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

llvm-svn: 329094
2018-04-03 18:07:22 +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
Evgeniy Stepanov 29e6fd6785 [asan] Add vfork to the list of reasons for stack errors.
Until we figure out what to do with it, vfork can cause stack-based
false positives.

llvm-svn: 328681
2018-03-28 00:45:20 +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
Kostya Kortchinsky eeee252d50 [scudo] Fuchsia minimal shared runtime
Summary:
Fuchsia requires its Scudo shared runtime to not be C++ dependant. Since they
don't use UBSan in conjunction with Scudo, we can just remove the runtime,
and add the extra `nostdinc++` and `nostdlib++` flags. No need for Coverage
either. This allows to keep things going while working on additional splits
of sanitizer_commong and a more minimal runtime.

Reviewers: phosek, flowerhack, alekseyshl

Reviewed By: phosek, alekseyshl

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

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

llvm-svn: 328625
2018-03-27 14:40:39 +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 f791c9659b [sanitizer] Fix Darwin build
llvm-svn: 328417
2018-03-24 08:13:18 +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
Vitaly Buka eb8a3674ec [sanitizer] Fix strlcpy and strlcat interceptors on Darwin
llvm-svn: 328414
2018-03-24 07:31:59 +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
Alex Shlyapnikov 3e65a06015 Remove duplicated const qualifier.
llvm-svn: 328403
2018-03-24 00:40:51 +00:00
Alex Shlyapnikov 5cd35ed4fe [HWASan] Port HWASan to Linux x86-64 (compiler-rt)
Summary:
Porting HWASan to Linux x86-64, first of the three patches, compiler-rt part.

The approach is similar to ARM case, trap signal is used to communicate
memory tag check failure. int3 instruction is used to generate a signal,
access parameters are stored in nop [eax + offset] instruction immediately
following the int3 one

Had to add HWASan init on malloc because, due to much less interceptors
defined (most other sanitizers intercept much more and get initalized
via one of those interceptors or don't care about malloc), HWASan was not
initialized yet when libstdc++ was trying to allocate memory for its own
fixed-size heap, which led to CHECK-fail in AllocateFromLocalPool.

Also added the CHECK() failure handler with more detailed message and
stack reporting.

Reviewers: eugenis

Subscribers: kubamracek, dberris, mgorny, kristof.beyls, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 328385
2018-03-23 23:38:04 +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