Commit Graph

9555 Commits

Author SHA1 Message Date
Tom de Vries a91707224d [asan] Remove semicolon after do {} while (0)
Remove semicolon after "do {} while (0)" in in CHECK_SMALL_REGION

llvm-svn: 318084
2017-11-13 20:59:20 +00:00
Vitaly Buka c691d4eef2 [tsan] Fix signal chaining
Summary: Return saved values only if installed sigaction is our wrapper.

Reviewers: eugenis, dvyukov

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 318082
2017-11-13 20:49:14 +00:00
Kostya Kortchinsky 2ba105a7da [sanitizer] Update scudo to use new API
Summary:
The ScudoAllocator uses a SecondaryHeader to keep track of the size and base address of each mmap'd chunk.

This aligns well with what the ReservedAddressRange is trying to do.  This changeset converts the scudo allocator from using the MmapNoAccess/MmapFixed APIs to the ReservedAddressRange::Init and ::Map APIs.  In doing so, it replaces the SecondayHeader struct with the ReservedAddressRange object.

This is part 3 of a 4 part changeset; part 1 https://reviews.llvm.org/D39072 and part 2 https://reviews.llvm.org/D38592

Reviewers: alekseyshl, mcgrathr, cryptoad, phosek

Reviewed By: cryptoad

Subscribers: llvm-commits, cryptoad, kubamracek

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

llvm-svn: 318080
2017-11-13 20:38:22 +00:00
Vitaly Buka 014be10717 [tsan] Deadly signal handler for tsan
Summary: https://github.com/google/sanitizers/issues/637

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 318078
2017-11-13 19:56:20 +00:00
Vitaly Buka 2a46e8d1c2 [sanitizer] Relax stack check
-NEXT sometimes does not work as LLVMSymbolizer warning can appear there.

llvm-svn: 318077
2017-11-13 19:56:06 +00:00
Bill Seurer 3e3ee1282b [PowerPC][tsan] Update tsan to handle changed memory layouts in newer kernels
In more recent Linux kernels with 47 bit VMAs the layout of virtual memory
for powerpc64 changed causing the thread sanitizer to not work properly. This
patch adds support for 47 bit VMA kernels for powerpc64.

Tested on several 4.x and 3.x kernel releases.

llvm-svn: 318044
2017-11-13 15:42:28 +00:00
Walter Lee 52b2bd7845 [asan] Add CMake hook to override shadow scale in compiler_rt
Allow user to override shadow scale in compiler_rt by passing
-DCOMPILER_RT_ASAN_SHADOW_SCALE=n to CMake.  Propagate the override
shadow scale value via a compiler define to compiler-rt and asan
tests.  Tests will use the define to partially disable unsupported
tests.  Set "-mllvm -asan-mapping-scale=<n>" for compiler_rt tests.

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

llvm-svn: 318038
2017-11-13 14:02:27 +00:00
Greg Bedwell d6b0ecb795 Allow compiler-rt test targets to work with multi-config CMake generators
Multi-config CMake generators need lit to be able to resolve paths of
artifacts from previous build steps at lit time, rather than expect them
to be fully resolved at CMake time as they may contain the build mode.

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

llvm-svn: 318037
2017-11-13 12:57:54 +00:00
Vitaly Buka 8b9d6be24d [sanitizer] Simplify stack check in accert.cc
Somehow on arm bots stack does not include main.

llvm-svn: 318002
2017-11-12 21:15:19 +00:00
Vitaly Buka 1925591925 [sanitizer] Try to see test output on armv7
llvm-svn: 318001
2017-11-12 20:25:14 +00:00
Kamil Rytarowski 32ee3342d9 Correct NetBSD build issue
Cast SIG_IGN to (uptr).

SIG_IGN is defined on NetBSD as a function pointer and cannot be
assigned to an integer as it is.

sys/signal.h:#define       SIG_IGN         ((void (*)(int))  1)

llvm-svn: 317978
2017-11-11 09:29:21 +00:00
Vitaly Buka 5f767113c5 [msan] Fix signal chaining
Return internally stored handlers only if handlers is set to wrapper

llvm-svn: 317970
2017-11-11 03:03:34 +00:00
Evgeniy Stepanov 24bc8d5905 [ubsan-minimal] Get rid of the libc++ dependency.
Summary:
Use -nodefaultlibs.
Replace std:atomic with sanitizer atomics.

Reviewers: vitalybuka, kongyi, EricWF

Subscribers: mgorny, llvm-commits

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

llvm-svn: 317969
2017-11-11 02:32:02 +00:00
Vitaly Buka 2aa04b4a0f [sanitizer] Include stack trace check into signal tests
llvm-svn: 317963
2017-11-11 01:30:03 +00:00
Vitaly Buka 8f90f8b812 [ubsan] Fix ubsan tests broken by linking as C instead of C++
llvm-svn: 317958
2017-11-11 01:01:09 +00:00
Evgeniy Stepanov ad2c50f9b9 [sanitizer] Remove unnecessary attribute hidden.
This should fix windows build of compiler-rt broken in r317943.

The attribute is unnecessary because since GetMaxVirtualAddress was split in two,
we no longer use common_flags() in the ifunc resolver context.

llvm-svn: 317948
2017-11-10 22:52:44 +00:00
Vitaly Buka 8c6917872c [tsan] Move out more types to sanitizer_common
https://github.com/google/sanitizers/issues/637

llvm-svn: 317946
2017-11-10 22:41:52 +00:00
Evgeniy Stepanov 989299c42b [asan] Use dynamic shadow on 32-bit Android.
Summary:
The following kernel change has moved ET_DYN base to 0x4000000 on arm32:
https://marc.info/?l=linux-kernel&m=149825162606848&w=2

Switch to dynamic shadow base to avoid such conflicts in the future.

Reserve shadow memory in an ifunc resolver, but don't use it in the instrumentation
until PR35221 is fixed. This will eventually let use save one load per function.

Reviewers: kcc

Subscribers: aemerson, srhines, kubamracek, kristof.beyls, hiraditya, llvm-commits

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

llvm-svn: 317943
2017-11-10 22:27:48 +00:00
Peter Collingbourne 0f43b92980 sanitizer_common: Try looking up symbols with RTLD_DEFAULT if RTLD_NEXT does not work.
If the lookup using RTLD_NEXT failed, the sanitizer runtime library
is later in the library search order than the DSO that we are trying
to intercept, which means that we cannot intercept this function. We
still want the address of the real definition, though, so look it up
using RTLD_DEFAULT.

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

llvm-svn: 317930
2017-11-10 22:09:37 +00:00
Kuba Mracek ada45dfde7 [compiler-rt] Fix const and volatile qualifier warnings
Building with a new clang produces a bunch of warnings about dropped 'const' and 'volatile' qualifiers on pointers. Let's fix them.

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

llvm-svn: 317929
2017-11-10 21:19:20 +00:00
Vitaly Buka 84d11cac28 [tsan] Move code of sigaction_impl and signal_impl
They need to be after sanitizer_signal_interceptors.inc to use READ function

Part of https://github.com/google/sanitizers/issues/637

llvm-svn: 317914
2017-11-10 19:23:02 +00:00
Vitaly Buka 01a7e4ca6b [tsan] Extract sigaction_impl and signal_impl
Preparation for switching to sanitizer_signal_interceptors.inc

Part of https://github.com/google/sanitizers/issues/637

llvm-svn: 317913
2017-11-10 19:22:51 +00:00
Kostya Kortchinsky 36e56785b4 [scudo] Bump the Android API level requirement to 21 for getauxval
Summary:
`getauxval` was introduced in 18 & 21 depending on the architecture. Bump the
requirement to 21.

It also turns out that the NDK is finicky: NDK r13b doesn't include sys/auxv.h
when creating a standalone toolchain at API level 19 for ARM. So 18 didn't work
well with older NDKs.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: aemerson, srhines, llvm-commits, kristof.beyls

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

llvm-svn: 317907
2017-11-10 19:01:17 +00:00
Vitaly Buka db5757e68b [msan] Remove INTERCEPT_FUNCTION for sigaction and signal
Already done in InitializeSignalInterceptors()

llvm-svn: 317906
2017-11-10 18:58:59 +00:00
Dean Michael Berris 46d0cd3413 Revert "[XRay][darwin] Initial XRay in Darwin Support"
This reverts r317875.

llvm-svn: 317877
2017-11-10 07:00:55 +00:00
Dean Michael Berris bfd111bca5 [XRay][darwin] Initial XRay in Darwin Support
Summary:
This change implements the changes required in both clang and
compiler-rt to allow building XRay-instrumented binaries in Darwin. For
now we limit this to x86_64. We also start building the XRay runtime
library in compiler-rt for osx.

A caveat to this is that we don't have the tests set up and running
yet, which we'll do in a set of follow-on changes.

This patch uses the monorepo layout for the coordinated change across
multiple projects.

Reviewers: kubamracek

Subscribers: mgorny, cfe-commits, llvm-commits

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

llvm-svn: 317875
2017-11-10 05:50:13 +00:00
Vitaly Buka 3e3f3cf54d [esan] Fix compilation of signal handlers
llvm-svn: 317874
2017-11-10 05:41:13 +00:00
Vitaly Buka 8b689f4092 [tsan] Use __sanitizer_siginfo from sanitizer_common
llvm-svn: 317872
2017-11-10 04:27:47 +00:00
Vitaly Buka 529e321e49 [sanitizer] Remove unused <signal.h> which conflicts with asan declarations
llvm-svn: 317871
2017-11-10 04:12:35 +00:00
Vitaly Buka 748c180fb1 [sanitizer] Forward declaration of __sanitizer_sigaction without signal interceptors
llvm-svn: 317870
2017-11-10 04:05:38 +00:00
Vitaly Buka a10d7a9fcc [sanitizer] Remove unneeded forward declaration of real_sigaction
llvm-svn: 317869
2017-11-10 04:00:58 +00:00
Vitaly Buka 084d365c90 [sanitizer] Remove unneeded forward declarations
llvm-svn: 317868
2017-11-10 03:35:26 +00:00
Vitaly Buka bad0b3ea7e [sanitizer] Remove unused <signal.h> which conflicts with asan declarations
llvm-svn: 317867
2017-11-10 03:18:53 +00:00
Vitaly Buka 112b2d1625 [sanitizer] Fix "cast from 'const void *' to 'sigaction *'" on Darwin
llvm-svn: 317866
2017-11-10 03:13:42 +00:00
Vitaly Buka f2827e133b [sanitizer] Remove references and hide CommonSanitizerReportMutex
llvm-svn: 317865
2017-11-10 02:07:11 +00:00
Vitaly Buka bec32e9ac4 [msan] Deadly signal handler for msan
Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 317864
2017-11-10 02:06:59 +00:00
Vitaly Buka a452f9cc37 [msan] Move sigaction_impl and signal_impl
llvm-svn: 317863
2017-11-10 02:06:50 +00:00
Kostya Serebryany c183e2c33b [libFuzzer] trying to make sigusr tests more reliable
llvm-svn: 317852
2017-11-10 00:26:23 +00:00
Kostya Serebryany e8637f45ea [libFuzzer] split a test into two
llvm-svn: 317851
2017-11-10 00:18:13 +00:00
Vitaly Buka bc55ab6397 [sanitizer] Remove unneeded "struct"
llvm-svn: 317847
2017-11-09 23:06:59 +00:00
Vitaly Buka 893bf354eb [sanitizer] Fix signal interceptors build on Windows
llvm-svn: 317846
2017-11-09 23:05:01 +00:00
Vitaly Buka 8e92025718 [msan] Extract signal_impl and sigaction_impl
Summary: Preparation for using interceptor from sanitizer_common.

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 317844
2017-11-09 22:52:15 +00:00
Vitaly Buka 43c3e6ae1c [sanitizer] Allow sanitizers to redefine implementation of signal interceptors
Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 317843
2017-11-09 22:48:54 +00:00
Vitaly Buka 771e3995a4 [msan] Replace CommonSanitizerReportMutex with ScopedErrorReportLock
llvm-svn: 317842
2017-11-09 22:48:45 +00:00
Kostya Serebryany 533cbf749c [libFuzzer] use pkill instead of killall in a test since the bots don't have killall
llvm-svn: 317840
2017-11-09 22:01:06 +00:00
Kostya Serebryany 54a8456005 [libFuzzer] make sure to flush IO when done merging one file
llvm-svn: 317835
2017-11-09 21:30:33 +00:00
Kostya Kortchinsky 5604ad1c9b [sanitizer] Revert rL317822
Summary:
This reverts D39490.

For toolchains generated with older NDKs (<=r13b as far as we tested),
`cpu_set_t` doesn't exist in `sched.h`.
We have to figure out another way to get the number of CPUs without this.

Reviewers: rnk

Reviewed By: rnk

Subscribers: kubamracek, llvm-commits, krytarowski

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

llvm-svn: 317834
2017-11-09 21:26:07 +00:00
Matt Morehouse 947838c9c5 [libFuzzer] Don't add leaking inputs to corpus.
Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 317831
2017-11-09 20:44:08 +00:00
Kostya Serebryany a2ca2dcc46 [libFuzzer] handle SIGUSR1/SIGUSR2 and try to exit grafully on these signals
llvm-svn: 317829
2017-11-09 20:30:19 +00:00
Teresa Johnson 179b8fbba6 Revert new ThinLTO ASAN test until lit support added
This reverts commit r317723 and r317728. Will be re-added when
support for LTO/ThinLTO added to test/asan/lit.cfg.

llvm-svn: 317823
2017-11-09 19:26:54 +00:00
Kostya Kortchinsky 6458216b28 [scudo] Make getNumberOfCPUs Fuchsia compliant
Summary: This change allows Fuchsia to boot properly using the Scudo allocator.

Reviewers: cryptoad, alekseyshl, krytarowski

Reviewed By: cryptoad, krytarowski

Subscribers: rnk, krytarowski, kubamracek, llvm-commits

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

llvm-svn: 317822
2017-11-09 19:18:55 +00:00
Weiming Zhao e58bb5dc4e [Builtins] Do not use tailcall for Thumb1
Summary:
The `b` instruction in Thumb1 has limited range, which may cause link-time errors if the jump target is far away.
This patch guards the tailcalls for non-Thumb1

Reviewers: peter.smith, compnerd, rengolin, eli.friedman

Reviewed By: rengolin

Subscribers: joerg, dalias, javed.absar, llvm-commits

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

llvm-svn: 317814
2017-11-09 17:32:57 +00:00
Bill Seurer 823338d1fe [PowerPC][msan] Update msan to handle changed memory layouts in newer kernels
In more recent Linux kernels (including those with 47 bit VMAs) the layout of
virtual memory for powerpc64 changed causing the memory sanitizer to not
work properly.  This patch adjusts the memory ranges in the tables for the
memory sanitizer to work on the newer kernels while continuing to work on the
older ones as well.

Tested on several 4.x and 3.x kernel releases.

llvm-svn: 317802
2017-11-09 16:14:57 +00:00
Vitaly Buka 66f32fc431 [sanitizers] Rename GetStackTraceWithPcBpAndContext
Name does not need to enumerate arguments.

llvm-svn: 317774
2017-11-09 07:53:06 +00:00
Vitaly Buka 2b2d3aaa04 [msan] Add context argument into GetStackTrace
llvm-svn: 317773
2017-11-09 07:48:53 +00:00
Vitaly Buka cb4b2c0ffc [lsan] Add "static" to internal function
llvm-svn: 317772
2017-11-09 07:46:30 +00:00
Kostya Serebryany 3ac31d4453 [libFuzzer] allow merge to resume after being preempted
llvm-svn: 317767
2017-11-09 05:49:28 +00:00
Peter Collingbourne c6721f580d ubsan: Allow programs to use setenv to configure ubsan_standalone.
Previously ubsan_standalone used the GetEnv function to read the
environment variables UBSAN_OPTIONS and UBSAN_SYMBOLIZER_PATH. The
problem with GetEnv is that it does not respect changes to the
environment variables made using the libc setenv function, which
prevents clients from setting environment variables to configure
ubsan before loading ubsan-instrumented libraries.

The reason why we have GetEnv is that some runtimes need to read
environment variables while they initialize using .preinit_array,
and getenv does not work while .preinit_array functions are being
called. However, it is unnecessary for ubsan_standalone to initialize
that early. So this change switches ubsan_standalone to using getenv
and removes the .preinit_array entry. The static version of the runtime
still ends up being initialized using a C++ constructor that exists
to support the shared runtime.

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

llvm-svn: 317757
2017-11-09 02:22:07 +00:00
Kostya Serebryany e1d121d715 [libFuzzer] mechanically simplify a test, NFC
llvm-svn: 317756
2017-11-09 02:13:43 +00:00
Kostya Serebryany 8a94f220aa [libFuzzer] fix a test (and hopefully, the bot)
llvm-svn: 317749
2017-11-09 01:45:59 +00:00
Kostya Serebryany 68fdef1f7a [libFuzzer] allow user to specify the merge control file
llvm-svn: 317747
2017-11-09 01:05:29 +00:00
Evgeniy Stepanov 75a35179de [Sanitizers, CMake] Also use version script for libclang_rt.asan-i386.so
When building LLVM on x86_64-pc-linux-gnu (Fedora 25) with the bundled gcc 6.4.1
which uses gld 2.26.1-1.fc25, the dynamic/Asan-i386-calls-Dynamic-Test and
dynamic/Asan-i386-inline-Dynamic-Test tests failed to link with

/usr/bin/ld: /var/scratch/gcc/llvm/dist/lib/clang/6.0.0/lib/linux/libclang_rt.asan-i386.so: fork: invalid version 21 (max 0)
/var/scratch/gcc/llvm/dist/lib/clang/6.0.0/lib/linux/libclang_rt.asan-i386.so: error adding symbols: Bad value

I tried building with a self-compiled gcc 7.1.0 using gld 2.28, but the error remained.

It seems the error has been hit before (cf. https://reviews.llvm.org/rL314085), but
no real explanation has been found.

However, the problem goes away when linking the i386 libclang_rt.asan with a version
script just like every other variant is. Not using the version script in this single case
dates back to the initial introduction of the version script in r236551, but this change
was just checked in without any explanation AFAICT.

Since I've not found any other workaround and no reason for not always using the
version script, I propose to do so.

Tested on x86_64-pc-linux-gnu.

Patch by Rainer Orth.

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

llvm-svn: 317738
2017-11-08 22:51:09 +00:00
Kamil Rytarowski 2fd314e2e2 Correct atexit(3) support in TSan/NetBSD
Summary:
The NetBSD specific implementation of cxa_atexit() does not
preserve the 2nd argument if dso is equal to NULL.

Changes:

 - Split paths of handling intercepted __cxa_atexit() and atexit(3).
   This affects all supported Operating Systems.
 - Add a local stack-like structure to hold the __cxa_atexit() context.
   atexit(3) is documented in the C standard as calling callback from the
   earliest to the oldest entry. This path also fixes potential ABI
   problem of passing an argument to a function from the atexit(3)
   callback mechanism.
 - Add new test to ensure LIFO style of atexit(3) callbacks: atexit3.cc

Proposal to change the behavior of __cxa_atexit() in NetBSD has been rejected.

With the above changes TSan/NetBSD with the current tsan_interceptors.cc
can bootstrap into operation.

Sponsored by <The NetBSD Foundation>

Reviewers: vitalybuka, dvyukov, joerg, kcc, eugenis

Reviewed By: dvyukov

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 317735
2017-11-08 22:34:17 +00:00
Teresa Johnson c707c6f3a7 [ThinLTO] New test needs to require LTO
Fix buildbot failures:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/5262/steps/annotate/logs/stdio

llvm-svn: 317728
2017-11-08 21:48:27 +00:00
Teresa Johnson edf782f0d0 [ThinLTO] Ensure sanitizer passes are run
Recommit new test as linux-only.

llvm-svn: 317723
2017-11-08 20:27:28 +00:00
Teresa Johnson 67a781c4fc Revert "[ThinLTO] Ensure sanitizer passes are run"
This reverts commit r317715. It failed a Windows buildbot since
ThinLTO is presumably not supported, leading to a corrupt file error
on the object file:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/19395/steps/run%20check-asan/logs/stdio

Will re-commit the new ThinLTO part of the test to a linux only test
file.

llvm-svn: 317717
2017-11-08 20:08:15 +00:00
Teresa Johnson 0cfd530b2b [ThinLTO] Ensure sanitizer passes are run
Summary:
Test fix to pass manager for ThinLTO.

Depends on D39565.

Reviewers: pcc

Subscribers: kubamracek, mehdi_amini, llvm-commits, inglorion

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

llvm-svn: 317715
2017-11-08 19:46:25 +00:00
Marco Castelluccio ff4da375ae Implement flock for Windows in compiler-rt
Summary:
This patch implements flock for Windows, needed to make gcda writing work in a multiprocessing scenario.

Fixes https://bugs.llvm.org/show_bug.cgi?id=34923.

Reviewers: zturner

Reviewed By: zturner

Subscribers: rnk, zturner, llvm-commits

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

llvm-svn: 317705
2017-11-08 19:11:54 +00:00
Kostya Kortchinsky 6edadae34a [sanitizer] Add Scudo to the sanitizer lint checks.
Summary:
Scudo abides by the coding style enforced by the sanitizer_common
linter, but as of right now, it's not linter-enforced.

Add Scudo to the list of directories checked by check_lint.sh.

Also: fixes some linter errors found after getting this running.

Reviewers: cryptoad

Reviewed By: cryptoad

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 317699
2017-11-08 16:42:29 +00:00
Sylvestre Ledru a8c5460c8a Always use prctl(PR_SET_PTRACER)
Summary:
Sufficiently old Linux kernel headers don't provide the PR_SET_PTRACER, but we can still call prctl with it if the runtime kernel is newer. Even if it's not, prctl will only return EINVAL.

Patch by Mike Hommey <mh-llvm@glandium.org>

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: sylvestre.ledru, cfe-commits, kubamracek

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

llvm-svn: 317668
2017-11-08 07:25:19 +00:00
Reid Kleckner f7fdac4508 Revert "[scudo] Make getNumberOfCPUs Fuchsia compliant"
This reverts commit r317604.

Android doesn't have cpu_set_t.

llvm-svn: 317655
2017-11-08 01:33:15 +00:00
Evgeniy Stepanov 98fe207986 [sanitizer] Asm implementation of syscall() for arm32.
Summary:
These will be used in an ifunc resolver, when the binary may not be
completely relocated, and syscall() function from libc could not be
used.

Reviewers: dvyukov, vitalybuka

Subscribers: aemerson, kubamracek, javed.absar, llvm-commits, kristof.beyls

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

llvm-svn: 317640
2017-11-08 00:15:12 +00:00
Evgeniy Stepanov 0379d3f844 (NFC) Rename GetMax{,User}VirtualAddress.
Future change will introduce GetMaxVirtualAddress that will not take
the kernel area into account.

llvm-svn: 317638
2017-11-07 23:51:22 +00:00
Vitaly Buka fdc0795098 [sanitizer] Fix sanitizer_common compile errors on gcc trunk
Summary:
When testing a merge of compiler-rt r304709 into gcc trunk on x86-64-pc-linux-gnu,
I ran into two compile errors:
sanitizer_common/sanitizer_symbolizer_libbacktrace.cc:96:73: error: no matching function for call to '__sanitizer::AddressInfo::FillModuleInfo(char*&, __sanitizer::uptr&)'

All other files in sanitizer_common (with the exception of sanitizer_malloc_mac.inc
which is special) include sanitizer_platform.h without directory name.

Patch by Mike Jongen

Reviewers: kcc, vitalybuka

Reviewed By: kcc

Subscribers: kubamracek, fedor.sergeev, llvm-commits

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

llvm-svn: 317608
2017-11-07 20:10:17 +00:00
Kostya Kortchinsky 4e8ce0225f [scudo] Make getNumberOfCPUs Fuchsia compliant
Summary: This change allows Fuchsia to boot properly using the Scudo allocator.

Reviewers: cryptoad, alekseyshl, krytarowski

Reviewed By: cryptoad, krytarowski

Subscribers: krytarowski, kubamracek, llvm-commits

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

llvm-svn: 317604
2017-11-07 19:30:08 +00:00
Sam Clegg 12166ea1f2 [WebAssembly] Include GENERIC_TF_SOURCES in wasm builds
Differential Revision: https://reviews.llvm.org/D39748

llvm-svn: 317601
2017-11-07 19:03:11 +00:00
Dmitry Vyukov 3cd4022c39 tsan: allow usage of global vars with ctors in interceptors
We allow usage of global/per-thread data with non-trivial ctors/dtors
throughout tsan code base by placing all global/per-thread data into
Context/ThreadState and then explicitly constructing them with
placement new. This greatly simplifies code by restricting the
"linker initialized plague" to only these 2 objects.

Do the same for interceptors data.

This allows to use Vector instead of bunch of hand-written code in:
https://reviews.llvm.org/D39619

Reviewed in: https://reviews.llvm.org/D39721

llvm-svn: 317587
2017-11-07 16:31:08 +00:00
Kostya Kortchinsky c6f0ade6c3 Update sanitizer_allocator to use new API.
Summary:
Update sanitizer_allocator to use new API.
    
Second patch in a series.  First patch https://reviews.llvm.org/D39072
    
Updates MmapNoAccess / MmapFixed call sites in the saniziter_allocator
to use the new Init/Map APIs instead.


Reviewers: alekseyshl, cryptoad, phosek, mcgrathr, dvyukov

Reviewed By: alekseyshl, cryptoad

Subscribers: dvyukov, mcgrathr, kubamracek

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

llvm-svn: 317586
2017-11-07 16:19:24 +00:00
Alex Shlyapnikov 2093b94e70 [LSan] Detect dynamic loader by its base address.
Summary:
Relanding D38600, which was reverted due to various PPC bot failures.

If it breaks something again, please provide some pointers to broken
bots, not just revert it, otherwise it's very hard to reason what's
wrong with this commit.

Whenever possible (Linux + glibc 2.16+), detect dynamic loader module by
its base address, not by the module name matching. The current name
matching approach fails on some configurations.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 317512
2017-11-06 21:27:06 +00:00
Alex Shlyapnikov adbf476a88 [Sanitizers] Check pthread_setcancel{state|type} interceptor arguments for != nullptr.
Summary:
According to man, pthread_setcancelstate's oldstate and
pthread_setcanceltype's oldtype parameters can be nullptr.
Check these parameters for != nullptr before attempting to
access their shadow memory.

Reviewers: dvyukov

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 317494
2017-11-06 17:43:28 +00:00
Mehdi Amini a2a539e4c5 Fix CMake definitions of tsan runtime to make it installed by "install-compiler-rt"
Summary: The PARENT_TARGET was correctly set under APPLE but not under linux.

Reviewers: kubamracek, samsonov

Subscribers: dberris, mgorny, llvm-commits

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

llvm-svn: 317391
2017-11-04 00:07:20 +00:00
Kostya Kortchinsky 4a0ebbfe97 [scudo] Rearrange #include order
Summary:
To be compliant with https://llvm.org/docs/CodingStandards.html#include-style,
system headers have to come after local headers.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 317390
2017-11-03 23:48:25 +00:00
Alex Shlyapnikov 32224fe842 [Sanitizers] Call NanoTime() conditionally.
Summary:
Call NanoTime() in primary 64 bit allocator only when necessary,
otherwise the unwarranted syscall causes problems in sandbox environments.
ReleaseToOSIntervalMs() conditional allows them to turn the feature off
with allocator_release_to_os_interval_ms=-1 flag.

Reviewers: eugenis

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 317386
2017-11-03 23:31:00 +00:00
Kamil Rytarowski e6b53dad42 Late fixup in _lwp_exit on TSan/NetBSD
Call DestroyThreadState() before REAL(_lwp_exit)();

This variation is less racy.

Sponsored by <The NetBSD Foundation>

llvm-svn: 317369
2017-11-03 21:08:52 +00:00
Kamil Rytarowski 55435b7427 Correct detection of a thread termination
Summary:
Stop using the Linux solution with pthread_key_create(3).
This approach does not work on NetBSD, because calling
the thread destructor is not the latest operation on a POSIX
thread entity. NetBSD's libpthread still calls at least
pthread_mutex_lock and pthread_mutex_unlock.

Detect _lwp_exit(2) call as it is really the latest operation
called from a detaching POSIX thread.

This resolves one set of crashes observed in
the Thread Sanitizer execution.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka, dvyukov, eugenis

Reviewed By: vitalybuka

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

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

llvm-svn: 317363
2017-11-03 20:48:19 +00:00
Kamil Rytarowski 99a91f6744 Disable detection of on_exit()/TSan on NetBSD
Summary:
NetBSD does not ship with on_exit() function.

Introduce TSAN_MAYBE_INTERCEPT_ON_EXIT.
It looks like this addition fixes build for Darwin.

Sponsored by <The NetBSD Foundation>

Reviewers: vitalybuka, joerg, eugenis, dvyukov, kcc

Reviewed By: vitalybuka

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

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

llvm-svn: 317361
2017-11-03 20:39:51 +00:00
Vitaly Buka 7d22324b87 [fuzzer] Fix nested mallocs
Summary: Nested mallocs are possible with internal symbolizer.

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 317186
2017-11-02 04:12:10 +00:00
Vitaly Buka ca9075272b [fuzzer] Script to detect unbalanced allocation in -trace_malloc output
Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 317119
2017-11-01 20:27:06 +00:00
Kostya Kortchinsky a2cdb2d541 [scudo] Fix standlone build -lrt requirement
Summary:
The split in D39461 introduced separate C++ flags, but `cxx_flags` needs `-lrt` as well for the standalone build.


Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 317103
2017-11-01 17:00:26 +00:00
Kostya Kortchinsky d937b0a10c [scudo] Implement stricter separation of C vs C++
Summary:
Initially, Scudo had a monolithic design where both C and C++ functions were
living in the same library. This was not necessarily ideal, and with the work
on -fsanitize=scudo, it became more apparent that this needed to change.

We are splitting the new/delete interceptor in their own C++ library. This
allows more flexibility, notably with regard to std::bad_alloc when the work is
done. This also allows us to not link new & delete when using pure C.

Additionally, we add the UBSan runtimes with Scudo, in order to be able to have
a -fsanitize=scudo,undefined in Clang (see work in D39334).

The changes in this patch:
- split the cxx specific code in the scudo cmake file into a new library;
  (remove the spurious foreach loop, that was not necessary)
- add the UBSan runtimes (both C and C++);
- change the test cmake file to allow for specific C & C++ tests;
- make C tests pure C, rename their extension accordingly.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, mgorny, llvm-commits

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

llvm-svn: 317097
2017-11-01 15:28:20 +00:00
Vitaly Buka 7dbc1d8433 [fuzzer] Fix threaded stack printing
Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 317071
2017-11-01 03:02:59 +00:00
Vitaly Buka df00e89cdc Revert "[fuzzer] Fix threaded stack printing and nested mallocs"
Fails on darwin

Revert "[fuzzer] Script to detect unbalanced allocation in -trace_malloc output"
Needs previous one.

This reverts commit r317034, r317036.

llvm-svn: 317061
2017-11-01 00:55:52 +00:00
Vitaly Buka 0747700ce1 [fuzzer] Script to detect unbalanced allocation in -trace_malloc output
Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 317036
2017-10-31 20:50:07 +00:00
Vitaly Buka 58da33e35c [fuzzer] Fix threaded stack printing and nested mallocs
Summary: Nested mallocs are possible with internal symbolizer.

Reviewers: kcc

Subscribers: llvm-commits

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

llvm-svn: 317034
2017-10-31 20:49:48 +00:00
Petr Hosek 29476f759b [sanitizer][Fuchsia] Add a missing semicolon
Differential Revision: https://reviews.llvm.org/D39433

llvm-svn: 316959
2017-10-30 21:29:26 +00:00
Kostya Kortchinsky 264e1b73eb Fix warning + death test + failing test on Windows (D39072).
Summary: Fixes https://reviews.llvm.org/D39072

Reviewers: cryptoad

Reviewed By: cryptoad

Subscribers: kubamracek

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

llvm-svn: 316943
2017-10-30 19:06:59 +00:00
Kostya Kortchinsky 8c39ccf10c [sanitizer] Fixing an error introduced in D39072
Summary: This should fix the Windows bots after D39072.

Reviewers: alekseyshl, flowerhack

Reviewed By: flowerhack

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 316937
2017-10-30 18:16:05 +00:00
Kostya Kortchinsky 96da9fa4ca Introduce ReservedAddressRange to sanitizer_common.
Summary:
Fixed version of https://reviews.llvm.org/D38437 (fixes Win/Fuchsia failures).

Creating a new revision, since the old one was getting a bit old/crowded.

    In Fuchsia, MmapNoAccess/MmapFixedOrDie are implemented using a global
    VMAR, which means that MmapNoAccess can only be called once. This works
    for the sanitizer allocator but *not* for the Scudo allocator.
    
    Hence, this changeset introduces a new ReservedAddressRange object to
    serve as the new API for these calls. In this changeset, the object
    still calls into the old Mmap implementations.
    
    The next changeset two changesets will convert the sanitizer and scudo
    allocators to use the new APIs, respectively. (ReservedAddressRange will
    replace the SecondaryHeader in Scudo.)
    
    Finally, a last changeset will update the Fuchsia implementation.


Reviewers: alekseyshl, cryptoad, phosek

Reviewed By: alekseyshl, cryptoad

Subscribers: kubamracek

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

llvm-svn: 316934
2017-10-30 17:56:24 +00:00
Reid Kleckner 86fca5d058 Fix clang warnings in winasan code
There are two instances of -Wcast-qual and one of -Wsign-compare.

llvm-svn: 316930
2017-10-30 17:26:57 +00:00
Reid Kleckner af86cba0cf [asan] Intercept heap routines in VS2010 CRT
Users have requested that we add it to the list:
https://github.com/google/sanitizers/issues/864

llvm-svn: 316929
2017-10-30 17:26:13 +00:00