Commit Graph

14669 Commits

Author SHA1 Message Date
David Carlier 8fdd821aef [Sanitizers] intercept netent, protoent and mincore on FreeBSD.
netent on Linux in addition as well.

Reviewd By: vitalybuka

Differential Revision: https://reviews.llvm.org/D109287
2021-09-10 19:24:51 +01:00
Julian Lettner ee0ac45672 [TSan][Darwin] Add integration tests for dyld interposition
Add integration tests for dyld interposition: DYLD_LIBRARY_PATH and
DYLD_INSERT_LIBRARIES.

DYLD_INSERT_LIBRARIES is also relevant for TSan thread
finalization/destruction sequence in the presence of additional pthread
introspection hooks (libBacktraceRecording.dylib for Xcode 'Queue
Debugging' feature).

rdar://78739125

Differential Revision: https://reviews.llvm.org/D109332
2021-09-09 22:33:59 +02:00
Steven Wu 05eaa2b42f [CMake][Darwin] Ignore stderr during SDKSetting.plist parsing
Don't print stderr to commandline when configuring compiler-rt for
darwin platforms. NFC.

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D108156
2021-09-09 12:09:29 -07:00
Florian Mayer 039fd9af45 [NFC] [hwasan] move prints closer together.
this makes the code slightly more readable.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D109442
2021-09-09 13:39:11 +01:00
Tom Stellard 9ee64c3746 scudo: Only add no-omit-frame-pointer flags when the compiler supports them
Reviewed By: cryptoad

Differential Revision: https://reviews.llvm.org/D109196
2021-09-08 21:10:40 -07:00
Matt Morehouse ff77c4eac7 [libFuzzer] Add missing argument to CrashResistantMerge.
Fixes a build error caused by a bad merge conflict resolution for
https://reviews.llvm.org/D105084.
2021-09-08 11:48:33 -07:00
Leonard Chan e170cf5061 [compiler-rt][fuzzer] Do not link in libc++ in tests and disable exceptions
Differential Revision: https://reviews.llvm.org/D109208
2021-09-08 11:45:52 -07:00
Leonard Chan 056d024235 [compiler-rt] Use COMPILER_RT_TEST_CXX_COMPILER for linking compiler-rt tests
Before, COMPILER_RT_TEST_COMPILER was used which pointed to a C compiler. While
it is incorrect to assume either of these is the default compiler, using the
C++ one allows for linking cpp tests.

Differential Revision: https://reviews.llvm.org/D109207
2021-09-08 11:44:00 -07:00
Dan Liew 71841146b6 Fix `asan/TestCases/Darwin/scrible.cpp` to work on platforms where `long` is not 64-bits.
Previously the test was failing on platforms where `long` was less than
64-bits wide (e.g. older WatchOS simulators and arm64_32) because the
`padding` field was too small.

The test currently relies on the `my_object->isa` being scribbled or
left unmodified after `my_object` is freed. However, this was not the
case because the `isa` pointer intersected with
`ChunkHeader::free_context_id`.  `free_context_id` starts at the
beginning of user memory but it only initialized once the memory is
freed. This caused the `isa` pointer to change after it was freed
leading to the test crashing.

To fix this the `padding` field has been made explicitly 64-bits wide
(same size as `ChunkHeader::free_context_id`).

rdar://75806757

Differential Revision: https://reviews.llvm.org/D109409
2021-09-08 09:53:09 -07:00
gtt1995 a30dbbe924 Redistribute energy for Corpus
I found that the initial corpus allocation of fork mode has certain defects.
I designed a new initial corpus allocation strategy based on size grouping.
This method can give more energy to the small seeds in the corpus and
increase the throughput of the test.

Fuzzbench data (glibfuzzer is -fork_corpus_groups=1):
https://www.fuzzbench.com/reports/experimental/2021-08-05-parallel/index.html

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D105084
2021-09-08 09:22:45 -07:00
aristotelis e6597dbae8 Greedy set cover implementation of `Merger::Merge`
Extend the existing single-pass algorithm for `Merger::Merge` with an algorithm that gives better results. This new implementation can be used with a new **set_cover_merge=1** flag.

This greedy set cover implementation gives a substantially smaller final corpus (40%-80% less testcases) while preserving the same features/coverage. At the same time, the execution time penalty is not that significant (+50% for ~1M corpus files and far less for smaller corpora). These results were obtained by comparing several targets with varying size corpora.

Change `Merger::CrashResistantMergeInternalStep` to collect all features from each file and not just unique ones. This is needed for the set cover algorithm to work correctly. The implementation of the algorithm in `Merger::SetCoverMerge` uses a bitvector to store features that are covered by a file while performing the pass. Collisions while indexing the bitvector are ignored similarly to the fuzzer.

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D105284
2021-09-07 09:42:38 -07:00
Frederic Cambus 4787ef3d0f [compiler-rt] Document that builtins is known to work on OpenBSD.
Differential Revision: https://reviews.llvm.org/D109346
2021-09-07 04:25:12 -04:00
David Carlier d669cc7321 [Sanitizer] Intercept clock_getcpuid/pthread_getcpuid on netbsd.
Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D109278
2021-09-06 10:51:51 +01:00
Florian Mayer 2706b1a6e2 [hwasan] Test use-after-scope with -fno-exceptions.
Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D109224
2021-09-06 10:10:09 +01:00
David Spickett 915a8bb5ee Revert "[compiler-rt][Profile] Disable test on Arm/AArch64 Linux"
This reverts commit 8b86f8a325.

The inconsistent behaviour has been fixed with
5e50d3073a.
2021-09-06 08:45:06 +00:00
David Carlier 2833a2edac [Sanitizers] netbsd build fix due to wordexp interception. 2021-09-04 12:50:28 +01:00
David Carlier 08c3cdb8b8 [Sanitizers][PGO] missing return statement 2021-09-04 11:40:58 +01:00
Kazuaki Ishizaki a1e7e401d2 [compiler-rt] NFC: Fix trivial typo
Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D77457
2021-09-04 14:12:58 +05:30
David Spickett 5e50d3073a [compiler-rt][Profile] Wait for child threads in set-file-object test
We've been seeing this test return 31 instead of 32 for the "functions"
line in this test on our AArch64 bots.

One possible cause is some of the children not finishing in time
before the llvm-profdata commands are run, if the machine is heavily loaded.

Wait for all the children to finish before exiting the parent.

Reviewed By: zequanwu

Differential Revision: https://reviews.llvm.org/D109222
2021-09-03 11:48:50 -07:00
David Spickett 8b86f8a325 [compiler-rt][Profile] Disable test on Arm/AArch64 Linux
While a fix for flaky results is being reviewed.
2021-09-03 12:58:09 +00:00
Florian Mayer abf8ed8a82 [hwasan] Support more complicated lifetimes.
This is important as with exceptions enabled, non-POD allocas often have
two lifetime ends: the exception handler, and the normal one.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D108365
2021-09-03 10:29:50 +01:00
Rainer Orth 79d58b4d30 [sanitizer_common] Define wordexp_wrde_dooffs for Solaris
The Solaris buildbots have been broken for some time:

  In file included from /opt/llvm-buildbot/home/solaris11-amd64/clang-solaris11-amd64/llvm/compiler-rt/lib/asan/asan_interceptors.cpp:174:
  /opt/llvm-buildbot/home/solaris11-amd64/clang-solaris11-amd64/llvm/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:4000:19: error: use of undeclared identifier 'wordexp_wrde_dooffs'
          ((flags & wordexp_wrde_dooffs) ? p->we_offs : 0) + p->we_wordc;
                    ^

This was caused by D108646 <https://reviews.llvm.org/D108646>; the fix is
equivalent to D108838 <https://reviews.llvm.org/D108838>.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D109193
2021-09-03 10:02:31 +02:00
David Carlier 25765d860d [Sanitizers] remove empty test case. 2021-09-02 23:53:38 +01:00
David Carlier 6f9a96e9cd [Sanitizers] intercept clock_getcpuclockid on FreeBSD, and pthread_getcpuclockid.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D108884
2021-09-02 22:35:04 +01:00
Fangrui Song 68745a557e [InstrProfiling] Use llvm.compiler.used if applicable for Mach-O
Similar to D97585.

D25456 used `S_ATTR_LIVE_SUPPORT` to ensure the data variable will be retained
or discarded as a unit with the counter variable, so llvm.compiler.used is
sufficient. It allows ld to dead strip unneeded profc and profd variables.

Reviewed By: vsk

Differential Revision: https://reviews.llvm.org/D105445
2021-09-01 14:46:51 -07:00
Kostya Serebryany b0fdbadf9f [ubsan] warn inside the sigaction interceptor if static linking is suspected, and continue instead of crashing on null deref
[ubsan] warn inside the sigaction interceptor if static linking is suspected, and continue instead of crashing on null deref

Reviewed By: kostik

Differential Revision: https://reviews.llvm.org/D109081
2021-09-01 12:36:48 -07:00
Andrew Browne befb384484 [DFSan][NFC] Fix comment formatting. 2021-08-31 15:35:08 -07:00
Vedant Kumar 6c439a3817 [profile] Specify "-V" to otool to get expected test output
Newer Xcode toolchains ship a new otool implementation that prints out
section contents in a slightly different way than otool-classic. Specify
"-V" to otool to get the expected test output.

Differential Revision: https://reviews.llvm.org/D108929
2021-08-31 10:49:51 -07:00
Kai Luo a594362436 [AIX] Rename shared_libraries_to_archive -> objects_to_archive. NFC. 2021-08-31 06:47:06 +00:00
Xu Mingjie f10d003b0c [tsan] Add environment variable TSAN_SYMBOLIZER_PATH as we do in other sanitizers
ASan, LSan, MSan and UBSan all allow to use environment variable `*SAN_SYMBOLIZER_PATH` to pass the symbolizer path, this patch add `TSAN_SYMBOLIZER_PATH` to TSan.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D108911
2021-08-31 10:18:52 +08:00
Dmitry Vyukov 37b78291c6 tsan: add a comment to CallUserSignalHandler
Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D108907
2021-08-30 11:33:19 +02:00
David Carlier b35e636e40 [Sanitizers] PGO implements enable/disable SIGKILL on callers on FreeBSD.
Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D108867
2021-08-28 22:53:16 +01:00
David Carlier 84013d7093 [Sanitizers] wordexp interceptor build fix on FreeBSD.
Reviewers: vitalybuka

Reviewed-By: vitalybuka

Differential Revision: https://reviews.llvm.org/D108838
2021-08-27 23:58:06 +01:00
Michael Jones 4dde7064e7 [compiler-rt][obvious] fix typo, delete paren
I should've deleted a parenthesis on line 4222 in
https://reviews.llvm.org/D108843 and this patch fixes it.

Differential Revision: https://reviews.llvm.org/D108852
2021-08-27 22:55:39 +00:00
Michael Jones 012b664b2e [compiler-rt] fix real strlens that were missed
In reviews.llvm.org/D108316 I missed a few instances of REAL(strlen) and
this change fixes that, as well as restoring one that seems like it
shouldn't have been changed.

Reviewed By: hctim, vitalybuka

Differential Revision: https://reviews.llvm.org/D108843
2021-08-27 22:33:28 +00:00
Evgenii Stepanov f89ebe108e Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR in the sanitizer symbolizer build.
In this mode libc++ headers end up in two directories:
* include/<triple>/c++/v1 for the site config header
* include/c++/v1 for everything else

Also switch from -I to -isystem.

Differential Revision: https://reviews.llvm.org/D108841
2021-08-27 13:50:19 -07:00
Zequan Wu 1b05245119 [Profile] Support __llvm_profile_set_file_object in continuous mode.
Replace D107203, because __llvm_profile_set_file_object is usually used when the
process doesn't have permission to open/create file. That patch trying to copy
from old profile to new profile contradicts with the usage.

Differential Revision: https://reviews.llvm.org/D108242
2021-08-27 13:06:46 -07:00
Lang Hames b749ef9e22 [ORC][ORC-RT] Reapply "Introduce ELF/*nix Platform and runtime..." with fixes.
This reapplies e256445bff, which was reverted in 45ac5f5441 due to bot errors
(e.g. https://lab.llvm.org/buildbot/#/builders/112/builds/8599). The issue that
caused the bot failure was fixed in 2e6a4fce35.
2021-08-27 14:41:58 +10:00
Vitaly Buka f1bb30a495 [sanitizer] No THREADLOCAL in qsort and bsearch
qsort can reuse qsort_r if available.
bsearch always passes key as the first comparator argument, so we
can use it to wrap the original comparator.

Differential Revision: https://reviews.llvm.org/D108751
2021-08-26 16:55:06 -07:00
Vitaly Buka 96fa1eaae4 [sanitizer] Add basic qsort test 2021-08-26 12:03:26 -07:00
Vitaly Buka 39100c82d3 [NFC][sanitizer] Swap qsort_r and qsort code
To simplify future review.
2021-08-26 10:24:59 -07:00
Alex Richardson b475ce39e8 [sanitizer] Fix build on FreeBSD RISC-V
We have to avoid calling renameat2 and clone on FreeBSD.
Additionally, the mcontext structure has different members.

Reviewed By: jrtc27, luismarques

Differential Revision: https://reviews.llvm.org/D103886
2021-08-26 12:05:37 +01:00
Vitaly Buka 23a1e9f70b [sanitizer] Add new line to the test 2021-08-25 14:33:06 -07:00
Vitaly Buka c92631a59a [sanitizer] Fix VReport of symbol version
Version is already a string and does not need stringizing.
2021-08-25 14:32:15 -07:00
Vitaly Buka ea575598f5 [sanitizers] Basic realpath test 2021-08-25 14:32:15 -07:00
Vitaly Buka 5213f307ab Revert "Problem with realpath interceptor"
Breaks realpath(, nullptr) for all sanitizers.

Somehow INTERCEPT_FUNCTION and INTERCEPT_FUNCTION_VER return
false even if everything seemingly right.

And this is the issue for COMMON_INTERCEPT_FUNCTION_GLIBC_VER_MIN.
There is a check in every sanitlizer:
if (!INTERCEPT_FUNCTION_VER(name, ver) && !INTERCEPT_FUNCTION(name))

For non-versioned interceptors when INTERCEPT_FUNCTION returns false
it's not considered fatal, and it just prints a warning.

However INTERCEPT_FUNCTION_VER in this case will fallback to
INTERCEPT_FUNCTION replacing realpath with wrong version.

We need to investigate that before relanding the patch.

This reverts commit faef0d042f.
2021-08-25 13:55:23 -07:00
Florian Mayer 023f18bbaf [hwasan] do not check if freed pointer belonged to allocator.
In that case it is very likely that there will be a tag mismatch anyway.

We handle the case that the pointer belongs to neither of the allocators
by getting a nullptr from allocator.GetBlockBegin.

Reviewed By: hctim, eugenis

Differential Revision: https://reviews.llvm.org/D108383
2021-08-25 09:31:01 +01:00
Vitaly Buka 2d743af4e9 [msan] Unpoison trailing nullptr in wordexp interceptor
Differential Revision: https://reviews.llvm.org/D108665
2021-08-24 17:19:11 -07:00
Vitaly Buka 4c699b1cd0 [msan] Don't EXPECT_POISONED beyond the we_wordv
Partially reverts commit 629411d799.

EXPECT_POISONED argument is outside of the allocation so we can't
assume the state of shadow there.
2021-08-24 17:19:10 -07:00
Vitaly Buka 629411d799 [msan] Fix wordexp after D108646
I introduced this bug reformating the patch before commit.
2021-08-24 16:36:28 -07:00