Commit Graph

9960 Commits

Author SHA1 Message Date
Vitaly Buka ec6327bab8 Revert "Mmap interceptor new option, Write Exec runtime detector"
Breaks Android bot.

This reverts commit r327747.

llvm-svn: 327762
2018-03-17 00:31:41 +00:00
Petr Hosek 961235d335 [Fuzzer] Build the shared memory hooks for Fuchsia
This is needed otherwise we'll get undefined references when trying
to use the libFuzzer built for Fuchsia.

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

llvm-svn: 327759
2018-03-16 22:40:55 +00:00
Vitaly Buka ec55b07824 OpenBSD UBsan support final missing bits
Summary:
One forgotten file change + reordering one header due to clang-format

Patch by David CARLIER

Reviewers: vitalybuka, vsk

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

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

llvm-svn: 327758
2018-03-16 22:29:29 +00:00
Evgeniy Stepanov a4561123de [asan] Replace vfork with fork.
Summary:
vfork is not ASan-friendly because it modifies stack shadow in the
parent process address space. While it is possible to compensate for that with, for example,
__asan_handle_no_return before each call to _exit or execve and friends, simply replacing
vfork with fork looks like by far the easiest solution.

Posix compliant programs can not detect the difference between vfork and fork.

Fixes https://github.com/google/sanitizers/issues/925

Reviewers: kcc, vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 327752
2018-03-16 22:15:05 +00:00
Evgeniy Stepanov 9034c02270 [asan] Remove empty fork interceptor.
After a partial revert, ASan somehow ended up with an empty interceptor for fork().

llvm-svn: 327748
2018-03-16 21:31:49 +00:00
Vitaly Buka d2aca7bf89 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: 327747
2018-03-16 21:25:09 +00:00
Jonas Devlieghere bf0ed8e9b8 Revert "Mmap interceptor new option, Write Exec runtime detector"
This reverts r327696 because it is failing on GreenDragon.

  http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/43605/
  http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/10957/

llvm-svn: 327719
2018-03-16 15:34:09 +00:00
Dmitry Vyukov e63bc9c200 tsan: revert: Update buildgo.sh to pass -isysroot on Darwin.
This commit breaks actual Go runtime build on gomote builders (10.12) with:

xcode-select: error: tool 'xcodebuild' requires Xcode,
but active developer directory '/Library/Developer/CommandLineTools'
is a command line tools instance

Without this part build works fine.
The original commit does not include any explanation as to why
it is needed.

llvm-svn: 327700
2018-03-16 10:20:58 +00:00
Vitaly Buka 1d0c7ff1c4 FreeBSD TSan support update
Summary:
- Disable thread_finalize callback on FreeBSD, fixing couple of unit tests.

Patch by David CARLIER

Reviewers: vitalybuka

Reviewed By: vitalybuka

Subscribers: emaste, kubamracek, krytarowski, llvm-commits, #sanitizers

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

llvm-svn: 327697
2018-03-16 08:23:33 +00:00
Vitaly Buka 21f1b69862 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: 327696
2018-03-16 08:22:18 +00:00
Vitaly Buka 764012b497 MSan, FreeBSD few tests fixes
Summary:
pthread_getattr_np_deadlock support
pthread_getname_np unsupported

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

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

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

llvm-svn: 327678
2018-03-15 22:41:28 +00:00
Vitaly Buka fc8bb95724 OpenBSD UBsan support procmaps
Summary: procmaps OpenBSD specifics

Patch by David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: mgorny, emaste, kubamracek, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 327677
2018-03-15 22:40:47 +00:00
Vitaly Buka 92e6fbf54a OpenBSD UBsan support common functions
Summary: Ripped off OpenBSD specific from the common Linux implementation

Patch by David Carlier

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

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

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

llvm-svn: 327674
2018-03-15 22:19:39 +00:00
Martin Pelikan e0207e4948 [TSan] fix Go runtime test on amd64 with PIE
Summary:
Without this diff, the test segfaults.  Examining the generated executable
(which gets auto-deleted likely by cmake/ninja) yields this error message:

ThreadSanitizer failed to allocate 0x4000 (16384) bytes at address 1755558480000 (errno: 12)

Note that the address has more than 47 bits, which on amd64 means special
treatment and therefore points out an overflow.  The allocation came from
__tsan_map_shadow on a .data pointer, which (on my work Debian-based box)
means the 0x550000000000 range.  This doesn't correspond to the constants
mentioned in tsan_platform.h for Go binaries on Linux/amd64.

The diff therefore allocates memory in the sort of area Go programs would,
and prevents the test from crashing.  It would be nice if reviewers kindly
considered other setups and architectures :-)

Reviewers: kcc, dvyukov

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

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

llvm-svn: 327621
2018-03-15 12:10:43 +00:00
Vitaly Buka f6d8da1425 [sanitizer] Fix off type in mmap64 interceptor
llvm-svn: 327596
2018-03-15 01:13:29 +00:00
Kostya Kortchinsky a51139046e [scudo] Add Chunk::getSize, rework Chunk::getUsableSize
Summary:
Using `getActuallyAllocatedSize` from the Combined resulting in mediocre
compiled code, as the `ClassId != 0` predicament was not propagated there,
resulting in additional branches and dead code. Move the logic in the frontend,
which results in better compiled code. Also I think it makes it slightly easier
to distinguish between the size the user requested, and the size that was
actually allocated by the allocator.

`const` a couple of things as well.

This has no functional impact.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: delcypher, #sanitizers, llvm-commits

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

llvm-svn: 327525
2018-03-14 15:50:32 +00:00
Sylvestre Ledru d9a8b6a745 fix some user facing typos / in the comments
llvm-svn: 327402
2018-03-13 14:35:10 +00:00
Alex Shlyapnikov 79a7c4fe73 [Sanitizers] Add more standard compliant posix_memalign implementation for LSan.
Summary:
Add more standard compliant posix_memalign implementation for LSan and
use corresponding sanitizer's posix_memalign implenetations in allocation
wrappers on Mac.

Reviewers: eugenis, fjricci

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

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

llvm-svn: 327338
2018-03-12 21:59:06 +00:00
Evgeniy Stepanov c2e54761c9 [asan] poison_heap=0 should not disable __asan_handle_no_return.
Reviewers: kcc, alekseyshl, vitalybuka

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 327337
2018-03-12 21:46:55 +00:00
Kostya Kortchinsky e95ef87663 [scudo] Secondary allocator overhaul to support Windows
Summary:
The need for this change stems from the fact that Windows doesn't support
partial unmapping (`MEM_RELEASE` implies the entire allocated region). So we
now have to keep track of the reserved region and the committed region, so that
we can function without the trimming we did when dealing with larger alignments.

Instead of just having a `ReservedAddressRange` per chunk, we introduce a
`LargeChunkHeader` (and `LargeChunk` namespace) that additionally holds the
committed size and the usable size. The former is needed for stats purposes,
the latter is used by the frontend. Requiring both is debatable, we could only
work with the usable size but then be off by up to a page per chunk when
dealing with stats.

Additionally, we introduce more stats since they turned out to be useful for
experiments, and a `PrintStats` function that will be used by the combined
allocator in later patch.

Reviewers: alekseyshl, flowerhack

Reviewed By: alekseyshl

Subscribers: delcypher, #sanitizers, llvm-commits

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

llvm-svn: 327321
2018-03-12 19:29:38 +00:00
Kostya Kortchinsky 85ecac5f3f [sanitizer] Align & pad the allocator structures to the cacheline size v2
Summary:
This is a new version of D44261, which broke some builds with older gcc, as
they can't align on a constexpr, but rather require an integer (see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56859) among others.

We introduce `SANITIZER_CACHE_LINE_SIZE` in `sanitizer_platform.h` to be
used in `ALIGNED` attributes instead of using directly `kCacheLineSize`.

Reviewers: alekseyshl, thakis

Reviewed By: alekseyshl

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

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

llvm-svn: 327297
2018-03-12 17:18:26 +00:00
Petr Hosek 0b013e041d [Fuzzer] When building for Fuchsia, add an explicit libc++ dependency
libFuzzer dependes on C++ library, when building for Fuchsia, we
need to ensure that libFuzzer is only being built after libc++
has been built, so we add an explicity dependency on it.

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

llvm-svn: 327196
2018-03-10 02:00:18 +00:00
Dan Liew 0c51c94b00 [asan] Clean up the REQUIRES of `asan/TestCases/strcat-overlap.cc`
by explicitly listing where we expect this test to work.

Because this test invokes undefined behaviour all sorts of things
can happen (e.g. crash, or on some bots asan manages to catch
something). The test seems to pass okay on Darwin (x86_64/x86_64/i386)
and on Linux (x86_64/i386) so explicitly require one of these platforms
to run the test.

llvm-svn: 327185
2018-03-09 23:12:32 +00:00
Peter Collingbourne 43b055f8b1 cfi: Disable simple-pass.cpp on Darwin.
-mretpoline does not work yet on Darwin.

llvm-svn: 327168
2018-03-09 20:41:56 +00:00
Kostya Kortchinsky 112d7a435b [sanitizer] Revert rCRT327145
Summary:
It breaks the Chromium toolchain due to:
```
lib/sanitizer_common/sanitizer_allocator_primary32.h:269:34: error: requested alignment is not an integer constant
   struct ALIGNED(kCacheLineSize) SizeClassInfo {
```

Reviewers: alekseyshl, thakis

Reviewed By: thakis

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

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

llvm-svn: 327167
2018-03-09 20:17:12 +00:00
Peter Collingbourne 2974856ad4 Use branch funnels for virtual calls when retpoline mitigation is enabled.
The retpoline mitigation for variant 2 of CVE-2017-5715 inhibits the
branch predictor, and as a result it can lead to a measurable loss of
performance. We can reduce the performance impact of retpolined virtual
calls by replacing them with a special construct known as a branch
funnel, which is an instruction sequence that implements virtual calls
to a set of known targets using a binary tree of direct branches. This
allows the processor to speculately execute valid implementations of the
virtual function without allowing for speculative execution of of calls
to arbitrary addresses.

This patch extends the whole-program devirtualization pass to replace
certain virtual calls with calls to branch funnels, which are
represented using a new llvm.icall.jumptable intrinsic. It also extends
the LowerTypeTests pass to recognize the new intrinsic, generate code
for the branch funnels (x86_64 only for now) and lay out virtual tables
as required for each branch funnel.

The implementation supports full LTO as well as ThinLTO, and extends the
ThinLTO summary format used for whole-program devirtualization to
support branch funnels.

For more details see RFC:
http://lists.llvm.org/pipermail/llvm-dev/2018-January/120672.html

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

llvm-svn: 327163
2018-03-09 19:11:44 +00:00
Kostya Kortchinsky 69df838b52 [sanitizer] Align & pad the allocator structures to the cacheline size
Summary:
Both `SizeClassInfo` structures for the 32-bit primary & `RegionInfo`
structures for the 64-bit primary can be used by different threads, and as such
they should be aligned & padded to the cacheline size to avoid false sharing.
The former was padded but the array was not aligned, the latter was not padded
but we lucked up as the size of the structure was 192 bytes, and aligned by
the properties of `mmap`.

I plan on adding a couple of fields to the `RegionInfo`, and some highly
threaded tests pointed out that without proper padding & alignment, performance
was getting a hit - and it is going away with proper padding.

This patch makes sure that we are properly padded & aligned for both. I used
a template to avoid padding if the size is already a multiple of the cacheline
size. There might be a better way to do this, I am open to suggestions.

Reviewers: alekseyshl, dvyukov

Reviewed By: alekseyshl

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

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

llvm-svn: 327145
2018-03-09 16:18:38 +00:00
Dan Liew 3aa75a7f9b [asan] Try to unbreak arm build bots by only running the test on
x86_64 and x86_64H (and not in the iOS simulator) where it seems
to work. We need to properly fix the test when time permits.

llvm-svn: 327122
2018-03-09 12:26:29 +00:00
Kuba Mracek ffb5014d9e Mark the -overlap tests are "UNSUPPORTED: android". Android test harness doesn't know how to handle suppression files.
llvm-svn: 327091
2018-03-09 00:41:29 +00:00
Kuba Mracek 08126e7eaa Mark strcat-overlap.cc as "UNSUPPORTED: win32"
llvm-svn: 327081
2018-03-09 00:03:09 +00:00
Kuba Mracek f9ee716299 Move lto-constmerge-odr.cc to Posix (it's failing on Windows).
llvm-svn: 327080
2018-03-08 23:53:29 +00:00
Dan Liew 0faaa99e4d [asan] Fix bug where suppression of overlapping accesses was ignored on
`strcpy()`, `strncpy()`, `strcat()`, and `strncat()`.

rdar://problem/35576899

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

llvm-svn: 327068
2018-03-08 21:50:22 +00:00
Kuba Mracek e70e5fcc7e [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [compiler-rt part, take 3]
This fixes a false positive ODR violation that is reported by ASan when using LTO. In cases, where two constant globals have the same value, LTO will merge them, which breaks ASan's ODR detection. See the included testcase for an example.

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

llvm-svn: 327062
2018-03-08 21:02:52 +00:00
Kuba Mracek e3dfb9408a More revert of r327031
llvm-svn: 327038
2018-03-08 18:20:03 +00:00
Kuba Mracek 0fe43695e5 Revert r327031
llvm-svn: 327032
2018-03-08 17:31:31 +00:00
Kuba Mracek 653f94df53 [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [compiler-rt part]
This fixes a false positive ODR violation that is reported by ASan when using LTO. In cases, where two constant globals have the same value, LTO will merge them, which breaks ASan's ODR detection.

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

llvm-svn: 327031
2018-03-08 17:24:47 +00:00
Eugene Zemtsov e465a84f85 Build LLVMDemangle from build_symbolizer.sh
Symbolizer now depends on internal implementation of itaniumDemangle.

llvm-svn: 326987
2018-03-08 04:34:22 +00:00
Eugene Zemtsov 824189f624 Add Demangle lib into internalization list
Symbolizer now depends on internal implementation of itaniumDemangle.

llvm-svn: 326983
2018-03-08 02:57:54 +00:00
Vitaly Buka 1732ee75ff [sanitizer] Fix SANITIZER_INTERCEPT_MMAP and SANITIZER_INTERCEPT_MMAP64 values
llvm-svn: 326938
2018-03-07 19:43:50 +00:00
Petr Hosek 2d19f9036e [Fuzzer] Avoid the unnecessary rebuild of the custom libc++
This changes the add_custom_libcxx macro to resemble the
llvm_ExternalProject_Add. The primary motivation is to avoid
unnecessary libFuzzer rebuilds that are being done on every
Ninja/Make invocation. The libc++ should be only rebuilt whenever
the libc++ source itself changes.

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

llvm-svn: 326921
2018-03-07 18:14:09 +00:00
Kostya Kortchinsky e245ec0cf0 [scudo] Make logging more consistent
Summary:
A few changes related to logging:
- prepend `Scudo` to the error messages so that users can identify that we
  reported an error;
- replace a couple of `Report` calls in the RSS check code with
  `dieWithMessage`/`Print`, mark a condition as `UNLIKELY` in the process;
- change some messages so that they all look more or less the same. This
  includes the `CHECK` message;
- adapt a couple of tests with the new strings.

A couple of side notes: this results in a few 1-line-blocks, for which I left
brackets. There doesn't seem to be any style guide for that, I can remove them
if need be. I didn't use `SanitizerToolName` in the strings, but directly
`Scudo` because we are the only users, I could change that too.

Reviewers: alekseyshl, flowerhack

Reviewed By: alekseyshl

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

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

llvm-svn: 326901
2018-03-07 16:22:16 +00:00
Kamil Rytarowski 9b996f03cb Don't intercept mmap64() on NetBSD
Disable SANITIZER_INTERCEPT_MMAP64 for SI_NETBSD.

NetBSD switched to 64-bit offsets almost 30 years ago on 32-bit platforms
and never needed mmap64() concept.

llvm-svn: 326883
2018-03-07 09:16:10 +00:00
George Burgess IV de772ce015 Attempt to appease buildbots
I can't reproduce this build error locally, but it appears
straightforward enough to fix. r326851 renamed two of the params of this
interceptor, but apparently to update their use here.

Failure:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/4569

llvm-svn: 326876
2018-03-07 07:36:23 +00:00
Adam Nemet 8e0bc894f9 Disable tests from r326852 on Darwin
Darwin needs xlocale.h but I see no precedence in the code how non-Posix
headers like this are handled and I am not experienced with this code.  Just
disable the tests for now to recover the bots.

rdar://38208146

llvm-svn: 326874
2018-03-07 05:33:37 +00:00
Dean Michael Berris 35824efb45 [XRay][compiler-rt] Add APIs for processing logs in memory
Summary:
This change adds APIs to allow logging implementations to provide a
function for iterating through in-memory buffers (if they hold in-memory
buffers) and a way for users to generically deal with these buffers
in-process. These APIs are:

  - __xray_log_set_buffer_iterator(...) and
    __xray_log_remove_buffer_iterator(): installs and removes an
    iterator function that takes an XRayBuffer and yields the next one.

  - __xray_log_process_buffers(...): takes a function pointer that can
    take a mode identifier (string) and an XRayBuffer to process this
    data as they see fit.

The intent is to have the FDR mode implementation's buffers be
available through this `__xray_log_process_buffers(...)` API, so that
they can be streamed from memory instead of flushed to disk (useful for
getting the data to a network, or doing in-process analysis).

Basic mode logging will not support this mechanism as it's designed to
write the data mostly to disk.

Future implementations will may depend on this API as well, to allow for
programmatically working through the XRay buffers exposed to the
users in some fashion.

Reviewers: eizan, kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 326866
2018-03-07 02:45:14 +00:00
Kuba Mracek cddd6339e9 Fixup r326851: mmap64 interceptor should not be used on Darwin.
llvm-svn: 326864
2018-03-07 02:30:55 +00:00
Vitaly Buka 56bdcc8e1e [sanitizer] Update symbolizer test
llvm-svn: 326855
2018-03-07 00:15:10 +00:00
Vitaly Buka 4580dc1a83 [sanitizer] Extract common code into STRXFRM_INTERCEPTOR_IMPL
llvm-svn: 326854
2018-03-07 00:14:52 +00:00
Vitaly Buka 2e5f44653b [sanitizer] Move strxfrm interceptors into sanitizer_common
llvm-svn: 326853
2018-03-07 00:14:30 +00:00
Vitaly Buka 46520a4dc1 [sanitizer] Add interceptors for wcsxfrm, wcsxfrm_l
Patch by Oliver Chang

Reviewers: vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits

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

llvm-svn: 326852
2018-03-07 00:14:12 +00:00