Commit Graph

7522 Commits

Author SHA1 Message Date
Alex Shlyapnikov 5ca33a137a [MSan,TSan] Add aligned new/delete interceptors.
Summary:
Providing aligned new/delete implementations to match ASan.
Unlike ASan, MSan and TSan do not perform any additional checks
on overaligned memory, hence no sanitizer specific tests.

Reviewers: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

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

llvm-svn: 321365
2017-12-22 17:02:17 +00:00
Reid Kleckner d0711dfba1 Include process.h for getpid on Windows in instr profiling
llvm-svn: 321313
2017-12-21 21:48:55 +00:00
Simon Dardis 6e62834fef Revert "[mips][compiler-rt] Provide 64bit atomic add and sub"
This reverts commit r321260. It appears to have broken the sanitizer
bot sanitizer-ppc64be-linux.

http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/5029

Reverting to see if the buildbot turns green.

llvm-svn: 321292
2017-12-21 19:01:32 +00:00
Simon Dardis 70cd933ff8 [mips][compiler-rt] Provide 64bit atomic add and sub
r318733 introduced a build failure for native MIPS32 systems for xray due
to the lack of __sync_fetch_and_add / __syn_fetch_and_sub support. This patch
extends the existing support providing atomics so that xray can be
successfully built.

Reviewers: atanasyan, dberris

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

llvm-svn: 321260
2017-12-21 13:05:41 +00:00
Vedant Kumar 8f4976bb7b [ubsan] Diagnose noreturn functions which return (compiler-rt)
This is paired with the clang change: https://reviews.llvm.org/D40698

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

llvm-svn: 321232
2017-12-21 00:10:36 +00:00
Max Moroz a40ce7bc36 [libfuzzer] Fix UB when calculating Log(0) in StackDepthStepFunction().
Summary:
__builtin_clz used for Log calculation returns an undefined result
when argument is 0. I noticed that issue when was testing some fuzzers:

```
/src/libfuzzer/FuzzerTracePC.h:282:33: runtime error: shift exponent 450349 is too large for 32-bit type 'uint32_t' (aka 'unsigned int')
  #0 0x43d83f in operator() /src/libfuzzer/FuzzerTracePC.h:283:33
  #1 0x43d83f in void fuzzer::TracePC::CollectFeatures<fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*)::$_1>(fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*)::$_1) const /src/libfuzzer/FuzzerTracePC.h:290
  #2 0x43cbd4 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:445:7
  #3 0x43e5f1 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:706:5
  #4 0x43e9e1 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:739:3
  #5 0x432f8c in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:754:6
  #6 0x42ee18 in main /src/libfuzzer/FuzzerMain.cpp:20:10
  #7 0x7f17ffeb182f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
  #8 0x407838 in _start (/out/rotate_fuzzer+0x407838)

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits, #sanitizers

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

llvm-svn: 321211
2017-12-20 19:31:51 +00:00
Evgeniy Stepanov 3fd1b1a764 [hwasan] Implement -fsanitize-recover=hwaddress.
Summary: Very similar to AddressSanitizer, with the exception of the error type encoding.

Reviewers: kcc, alekseyshl

Subscribers: cfe-commits, kubamracek, llvm-commits, hiraditya

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

llvm-svn: 321203
2017-12-20 19:05:44 +00:00
Martin Storsjo f8e19b3799 [builtins] Implement __chkstk for arm64 windows
Differential Revision: https://reviews.llvm.org/D41134

llvm-svn: 321151
2017-12-20 06:52:52 +00:00
Evgeniy Stepanov b74d731fb0 [hwasan] Fix handling of store errors.
llvm-svn: 321121
2017-12-19 22:57:02 +00:00
Dimitry Andric e4f5d01033 Fix more inconsistent line endings. NFC.
llvm-svn: 321016
2017-12-18 19:46:56 +00:00
Maxim Ostapenko de74bdb3d2 [asan] Add interceptor for printf_chk
There could be a situation when a specific DSO was built with FORTIFY_SOURCE option. In case asan-ed binary link against that DSO,
libasan can't handle the possible memory error because it does not have interceptors for spinrtf_chk, snprintf_chk, vprintf_chk,
vsnprintf_chk, __fprintf_chk functions. Let's interceptors for them.

Patch by Denis Khalikov.

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

llvm-svn: 320990
2017-12-18 15:31:26 +00:00
Stephan Bergmann 2635ea6601 Revert r320977 "No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17"
At least <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/
builds/6013/steps/annotate/logs/stdio> complains about
__ubsan::__ubsan_handle_function_type_mismatch_abort (compiler-rt
lib/ubsan/ubsan_handlers.cc) returning now despite being declared 'noreturn', so
looks like a different approach is needed for the function_type_mismatch check
to be called also in cases that may ultimately succeed.

llvm-svn: 320981
2017-12-18 13:51:46 +00:00
Stephan Bergmann c7121f6d28 No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17
As discussed in the mail thread <https://groups.google.com/a/isocpp.org/forum/
#!topic/std-discussion/T64_dW3WKUk> "Calling noexcept function throug non-
noexcept pointer is undefined behavior?", such a call should not be UB.
However, Clang currently warns about it.

There is no cheap check whether two function type_infos only differ in noexcept,so pass those two type_infos as additional data to the function_type_mismatch 
handler (with the optimization of passing a null "static callee type" info when that is already noexcept, so the additional check can be avoided anyway).  For
the Itanium ABI (which appears to be the only one that happens to be used on
platforms that support -fsanitize=function, and which appears to only record
noexcept information for pointer-to-function type_infos, not for function
type_infos themselves), we then need to check the mangled names for occurrence
of "Do" representing "noexcept".

This is the compiler-rt part of a patch covering both cfe and compiler-rt.

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

llvm-svn: 320977
2017-12-18 13:05:41 +00:00
Kostya Kortchinsky 8bcbcea929 [sanitizer] Define __sanitizer_clockid_t on FreeBSD
Summary:
https://reviews.llvm.org/D41121 broke the FreeBSD build due to that type not
being defined on FreeBSD. As far as I can tell, it is an int, but I do not have
a way to test the change.

Reviewers: alekseyshl, kparzysz

Reviewed By: kparzysz

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

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

llvm-svn: 320931
2017-12-16 23:01:14 +00:00
Filipe Cabecinhas 237d4c2eab [ubsan-minimal] Add a path for non-POSIX (and bare-metal) use of the library
Summary:
Hook on -DKERNEL_USE (which is also used in lib/builtins) to not import
strlen and not rely on write() being implemented with the stderr on fd 2.

With this, the only requirements to use this library are:
  - "Good enough" std::atomic<void*> and std::atomic<int>
  - abort() being implemented
  - ubsan_message(const char*) being implemented

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 320831
2017-12-15 17:30:50 +00:00
Kostya Kortchinsky efe3d3436a [scudo] Refactor ScudoChunk
Summary:
The initial implementation used an ASan like Chunk class that was deriving from
a Header class. Due to potential races, we ended up working with local copies
of the Header and never using the parent class fields. ScudoChunk was never
constructed but cast, and we were using `this` as the pointer needed for our
computations. This was meh.

So we refactored ScudoChunk to be now a series of static functions within the
namespace `__scudo::Chunk` that take a "user" pointer as first parameter (former
`this`). A compiled binary doesn't really change, but the code is more sensible.

Clang tends to inline all those small function (in -O2), but GCC left a few not
inlined, so we add the `INLINE` keyword to all.

Since we don't have `ScudoChunk` pointers anymore, a few variables were renamed
here and there to introduce a clearer distinction between a user pointer
(usually `Ptr`) and a backend pointer (`BackendPtr`).

Reviewers: alekseyshl, flowerhack

Reviewed By: alekseyshl

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 320745
2017-12-14 21:32:57 +00:00
Kamil Rytarowski 271018d216 [Sanitizers] Basic sanitizer Solaris support (PR 33274)
Summary:
This is the first mostly working version of the Sanitizer port to 32-bit Solaris/x86.
It is currently based on Solaris 11.4 Beta.

This part was initially developed inside libsanitizer in the GCC tree and should apply to
both.  Subsequent parts will address changes to clang, the compiler-rt build system
and testsuite.

I'm not yet sure what the right patch granularity is: if it's profitable to split the patch
up, I'd like to get guidance on how to do so.

Most of the changes are probably straightforward with a few exceptions:

* The Solaris syscall interface isn't stable, undocumented and can change within an
  OS release.  The stable interface is the libc interface, which I'm using here, if possible
  using the internal _-prefixed names.

* While the patch primarily target 32-bit x86, I've left a few sparc changes in.  They
  cannot currently be used with clang due to a backend limitation, but have worked
  fine inside the gcc tree.

* Some functions (e.g. largefile versions of functions like open64) only exist in 32-bit
  Solaris, so I've introduced a separate SANITIZER_SOLARIS32 to check for that.

The patch (with the subsequent ones to be submitted shortly) was tested
on i386-pc-solaris2.11.  Only a few failures remain, some of them analyzed, some
still TBD:

    AddressSanitizer-i386-sunos :: TestCases/Posix/concurrent_overflow.cc
    AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc
    AddressSanitizer-i386-sunos :: TestCases/log-path_test.cc
    AddressSanitizer-i386-sunos :: TestCases/malloc-no-intercept.c
    AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/concurrent_overflow.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/start-deactivated.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/default_options.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/log-path_test.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/malloc-no-intercept.c

   SanitizerCommon-Unit :: ./Sanitizer-i386-Test/MemoryMappingLayout.DumpListOfModules
    SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerCommon.PthreadDestructorIterations

Maybe this is good enough the get the ball rolling.

Reviewers: kcc, alekseyshl

Reviewed By: alekseyshl

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

Tags: #sanitizers

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

llvm-svn: 320740
2017-12-14 20:14:29 +00:00
Vedant Kumar d7c9336a84 [profile] Port the runtime to Solaris (retry)
This includes a few nice bits of refactoring (e.g splitting out the
exclusive locking code into a common utility).

Hopefully the Windows support is fixed now.

Patch by Rainer Orth!

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

llvm-svn: 320731
2017-12-14 19:01:04 +00:00
Vedant Kumar e8e8599ade Revert "(HEAD -> master, origin/master, origin/HEAD) [profile] Port the runtime to Solaris"
This reverts commit r320726. It looks like flock isn't available on
Windows:

http://lab.llvm.org:8011/builders/sanitizer-windows/builds/21317/steps/build%20compiler-rt/logs/stdio

llvm-svn: 320728
2017-12-14 18:50:13 +00:00
Vedant Kumar 5b0d5b45a2 [profile] Port the runtime to Solaris
This includes a few nice bits of refactoring (e.g splitting out the
exclusive locking code into a common utility).

Patch by Rainer Orth!

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

llvm-svn: 320726
2017-12-14 18:43:14 +00:00
Dean Michael Berris 504b0c28f3 [XRay][compiler-rt] Coalesce calls to mprotect to reduce patching overhead
Summary:
Before this change, XRay would conservatively patch sections of the code
one sled at a time. Upon testing/profiling, this turns out to take an
inordinate amount of time and cycles. For an instrumented clang binary,
the cycles spent both in the patching/unpatching routine constituted 4%
of the cycles -- this didn't count the time spent in the kernel while
performing the mprotect calls in quick succession.

With this change, we're coalescing the number of calls to mprotect from
being linear to the number of instrumentation points, to now being a
lower constant when patching all the sleds through `__xray_patch()` or
`__xray_unpatch()`. In the case of calling `__xray_patch_function()` or
`__xray_unpatch_function()` we're now doing an mprotect call once for
all the sleds for that function (reduction of at least 2x calls to
mprotect).

Reviewers: kpw, eizan

Subscribers: llvm-commits

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

llvm-svn: 320664
2017-12-14 02:51:20 +00:00
Kamil Rytarowski 6c18f027ff Set of corrections for MSan/NetBSD
Summary:
Changes:

 - Don't attempt to intercept GLIBC specific functions like __strtol_internal.
   This is required to stop intercepting it as we leak dlerror(3) for dlsym(3)
   that cannot manage to find a symbol.
 - Correct interception of fstatat(2).
 - Don't run a test for fgetgrent_r() that is missing on NetBSD.
 - Correct link_map location (offset) in Obj_Entry on x86_64 and i386.
 - Stop intercepting getpshared-like functions in pthread(3). This is feature
   is not enabled by default on NetBSD as it's unfinished.
 - Switch intercepting from UTMP to UTMPX functions.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, eugenis, kcc

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 320663
2017-12-14 01:20:16 +00:00
Kuba Mracek 2c1fa4feb1 [asan] Use linker initialization for the allocator
This saves ~2 MB of dirty memory footprint. Can be a big deal on mobile devices especially when running multiple processes with ASan.

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

llvm-svn: 320660
2017-12-14 00:07:15 +00:00
Kuba Mracek eb18bc5d22 [sanitizer] Use MADV_FREE on Darwin/BSD to release pages to the OS
MADV_DONTNEED on Linux actually mark the pages as free to be overwritten with zeroes, but on Darwin and BSD, it's just an advisory flag (the OS cannot discard the content). We should use MADV_FREE on Darwin and BSD.

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

llvm-svn: 320659
2017-12-14 00:04:30 +00:00
Matt Morehouse 6e294952b6 [libFuzzer] Add dummy call of LLVMFuzzerTestOneInput to afl_driver.
Summary:
Add dummy call of LLVMFuzzerTestOneInput to afl_driver before it starts
executing on actual inputs. Do this so that first time initialization
performed by LLVMFuzzerTestOneInput is not considered code covered by
a particular input.

Patch By: metzman

Reviewers: kcc, morehouse

Reviewed By: kcc

Subscribers: llvm-commits, Sanitizers

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

llvm-svn: 320643
2017-12-13 22:02:44 +00:00
Kostya Kortchinsky f22f5fe910 [scudo] Adding a public Scudo interface
Summary:
The first and only function to start with allows to set the soft or hard RSS
limit at runtime. Add associated tests.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: mgorny, #sanitizers, llvm-commits

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

llvm-svn: 320611
2017-12-13 20:41:35 +00:00
Kostya Kortchinsky f50246da65 [sanitizer] Introduce a vDSO aware timing function
Summary:
See D40657 & D40679 for previous versions of this patch & description.

A couple of things were fixed here to have it not break some bots.
Weak symbols can't be used with `SANITIZER_GO` so the previous version was
breakin TsanGo. I set up some additional local tests and those pass now.

I changed the workaround for the glibc vDSO issue: `__progname` is initialized
after the vDSO and is actually public and of known type, unlike
`__vdso_clock_gettime`. This works better, and with all compilers.

The rest is the same.

Reviewers: alekseyshl

Reviewed By: alekseyshl

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

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

llvm-svn: 320594
2017-12-13 16:23:54 +00:00
Kostya Kortchinsky 4ac0b1e6e9 [scudo] Inline getScudoChunk function.
Summary:
getScudoChunk function is implicitly inlined for optimized builds on
clang, but not on gcc. It's a small enough function that it seems
sensible enough to just inline it by default.

Reviewers: cryptoad, alekseyshl

Reviewed By: cryptoad

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

llvm-svn: 320592
2017-12-13 16:10:39 +00:00
Dean Michael Berris eec462f0e8 [XRay][compiler-rt] Reduce XRay log spam
This change makes XRay print the log file output only when the verbosity
level is higher than 0. It reduces the log spam in the default case when
we want XRay running silently, except when there are actual
fatal/serious errors.

We also update the documentation to show how to get the information
after the change to the default behaviour.

llvm-svn: 320550
2017-12-13 06:37:13 +00:00
Evgeniy Stepanov ecb48e523e [hwasan] Inline instrumentation & fixed shadow.
Summary: This brings CPU overhead on bzip2 down from 5.5x to 2x.

Reviewers: kcc, alekseyshl

Subscribers: kubamracek, hiraditya, llvm-commits

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

llvm-svn: 320538
2017-12-13 01:16:34 +00:00
Kostya Serebryany e9ed2327b6 [libFuzzer] change the strategy for -experimental_len_control to grow max_len slower
llvm-svn: 320531
2017-12-12 23:11:28 +00:00
Petr Hosek 95d7a4197a [CMake] Support runtimes and monorepo layouts when looking for libcxx
This also slightly refactors the code that's checking the directory
presence which allows eliminating one unnecessary variable.

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

llvm-svn: 320446
2017-12-12 01:20:52 +00:00
Kostya Kortchinsky ab5f6aaa75 [sanitizer] Revert rL320409
Summary: D40679 broke a couple of builds, reverting while investigating.

Reviewers: alekseyshl

Reviewed By: alekseyshl

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

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

llvm-svn: 320417
2017-12-11 21:03:12 +00:00
Kostya Kortchinsky d276d72441 [sanitizer] Introduce a vDSO aware time function, and use it in the allocator [redo]
Summary:
Redo of D40657, which had the initial discussion. The initial code had to move
into a libcdep file, and things had to be shuffled accordingly.

`NanoTime` is a time sink when checking whether or not to release memory to
the OS. While reducing the amount of calls to said function is in the works,
another solution that was found to be beneficial was to use a timing function
that can leverage the vDSO.

We hit a couple of snags along the way, like the fact that the glibc crashes
when clock_gettime is called from a preinit_array, or the fact that
`__vdso_clock_gettime` is mangled (for security purposes) and can't be used
directly, and also that clock_gettime can be intercepted.

The proposed solution takes care of all this as far as I can tell, and
significantly improve performances and some Scudo load tests with memory
reclaiming enabled.

@mcgrathr: please feel free to follow up on
https://reviews.llvm.org/D40657#940857 here. I posted a reply at
https://reviews.llvm.org/D40657#940974.

Reviewers: alekseyshl, krytarowski, flowerhack, mcgrathr, kubamracek

Reviewed By: alekseyshl, krytarowski

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

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

llvm-svn: 320409
2017-12-11 19:23:12 +00:00
Kostya Serebryany de891a1946 [libFuzzer] even less aggressive step function for stack depth. Also don't use asan in one test to speed it up
llvm-svn: 320259
2017-12-09 19:18:10 +00:00
Kostya Serebryany f94d87aadf [libFuzzer] make the stack depth signal less agressive, otherwise we are sometimes exploding the corpus size. This still needs more analysis and tuning
llvm-svn: 320237
2017-12-09 02:45:23 +00:00
Kamil Rytarowski f6510a01a6 Correct handling of the TLS/NetBSD block of the main program
Summary:
Include <sys/tls.h> for:

 - struct tls_tcb - thread control block structure
 - __HAVE___LWP_GETTCB_FAST - __lwp_gettcb_fast() is available
 - __HAVE___LWP_GETPRIVATE_FAST -  __lwp_getprivate_fast() is available
 - __HAVE_TLS_VARIANT_I - TLS Variant I for this architecture
 - __HAVE_TLS_VARIANT_II - TLS Variant II for this architecture

Rename ThreadSelfSegbase() to ThreadSelfTlsTcb and switch it
to retrieve in a portable way TCB.

Switch ThreadSelf() to retrieve pthread from struct tcb_tls.

Use dl_iterate_phdr() to find out the size of TLS block of
the main program.

Correct the index of the  TLS block of the main program
(dlpi_tls_modid); it's 1, not 2.

New NetBSD code is now CPU (NetBSD port) agnostic.

Stop sharing the same code with FreeBSD.

Sponsored by <The NetBSD Foundation>

Reviewers: dvyukov, joerg, vitalybuka

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 320234
2017-12-09 02:23:33 +00:00
Evgeniy Stepanov 9595d16893 Hardware-assisted AddressSanitizer (compiler-rt)
Summary:
Runtime library for HWASan, initial commit.
Does not randomize tags yet, does not handle stack or globals.

Reviewers: kcc, pcc, alekseyshl

Subscribers: srhines, kubamracek, dberris, mgorny, llvm-commits, krytarowski

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

llvm-svn: 320231
2017-12-09 01:31:51 +00:00
Kamil Rytarowski fb22504594 NetBSD ships with POSIX strerror_r(3)
Summary:
Switch NetBSD from GNU to the POSIX strerror_r(3) interceptor.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, eugenis, vitalybuka

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 320221
2017-12-09 00:35:44 +00:00
Kamil Rytarowski 9ecd493129 Add NetBSD/x86_64 mapping in MSan
Summary:
Reuse the Linux new mapping as it is.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, eugenis

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 320218
2017-12-09 00:27:52 +00:00
Matt Morehouse ffb1132e52 [libFuzzer] Add support for Fuchsia OS.
Summary:
This patch adds the initial support for Fuchsia.

- LIBFUZZER_FUCHSIA is added as an OS type in FuzzerDefs.h
- Fuchsia is, by design, not POSIX compliant. However, it does use ELF and
  supports common POSIX I/O functions. Thus, FuzzerExtFunctions.h and
  FuzzerIO.h are implemented by extending the header guards in
  FuzzerExtFunctionsWeak.cpp and FuzzerIOPosix.cpp to include
  LIBFUZZER_FUCHSIA.
- The platform-specific portions of FuzzerUtil.h are implemented by
  FuzzerUtilFuchsia.cpp, which makes use of exception ports, syscalls, and
  the launchpad library.
- The experimental equivalence server is not currently supported, so
  FuzzerShmem.h is implemented by stub methods in FuzzerShmemFuchsia.cpp.
  Any future implementation will likely involve VMOs.

Tested with ASAN/SanCov on Fuchsia/x86-64 with the canonical toy fuzzer.

Patch By: aarongreen

Reviewers: kcc, morehouse, flowerhack, phosek

Reviewed By: kcc, phosek, Eugene.Zelenko

Subscribers: srhines, mgorny, Eugene.Zelenko

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

llvm-svn: 320210
2017-12-08 22:54:44 +00:00
Kostya Serebryany 2659c63e2e [libFuzzer] honor -use_counters, sligntly change the meaning of -experimental_len_control, call UpdateFeatureFrequency only if instructed by the flag
llvm-svn: 320205
2017-12-08 22:21:42 +00:00
Kostya Kortchinsky 9fcb91b3eb [scudo] Minor code generation improvement
Summary:
It looks like clang was generating somewhat weird assembly with the current
code. `FromPrimary`, even though `const`,  was replaced every time with the code
generated for `size <= SizeClassMap::kMaxSize` instead of using a variable or
register, and `FromPrimary` didn't induce `ClassId != 0` for the compiler, so a
dead branch was generated for `getActuallyAllocatedSize(Ptr, ClassId)` since
it's never called for `ClassId = 0` (Secondary backed allocations) [this one
was more wishful thinking on my side than anything else].

I rearranged the code bit so that the generated assembly is less clunky.

Also changed 2 whitespace inconsistencies that were bothering me.

Reviewers: alekseyshl, flowerhack

Reviewed By: flowerhack

Subscribers: llvm-commits, #sanitizers

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

llvm-svn: 320160
2017-12-08 16:36:37 +00:00
Bill Seurer c776a9f5a8 [PowerPC][asan] Update asan 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 address sanitizer to not work properly. This
patch adds support for 47 bit VMA kernels for powerpc64 and fixes up test
cases.

https://reviews.llvm.org/D40908

There is an associated patch for trunk.

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

llvm-svn: 320110
2017-12-07 22:53:49 +00:00
Kostya Serebryany a97bd9a7d3 [libFuzzer] Decrease stack usage in unit tests
Summary: With 3 Dictionary objects, each containing space of ~16k DictionaryEntry objects, the MutationDispatcher object is fairly memory heavy.  On platforms with a lower default stack size, this can cause panics in FuzzerUnittest as those tests stack-allocate the MutationDispatcher.  This may be especially problematic for platforms that do not (yet) have a way to programmatically change their stack size, aside from link-time flags.  In general, it seems more prudent to use the heap for an object of this size.

Reviewers: kcc, morehouse

Reviewed By: kcc

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

llvm-svn: 319988
2017-12-06 23:35:02 +00:00
Vlad Tsyrklevich 5407edd375 Update other SizeEnums to be of type uptr as well
llvm-svn: 319984
2017-12-06 23:02:02 +00:00
Kamil Rytarowski 0f5cb013d0 Revert SVN r, 319967
"Correct atexit(3) support in MSan/NetBSD"

This causes failures on Linux.

llvm-svn: 319981
2017-12-06 22:50:12 +00:00
Vlad Tsyrklevich 03ad4e7f46 Fix broken windows sanitizer buildbot
r319875 caused a sign comparison build failure. Explicitly set the
enum's type to be unsigned.

llvm-svn: 319977
2017-12-06 22:40:23 +00:00
Kostya Serebryany 7ac58ee3e1 [libFuzzer] fix a minor regression in printing
llvm-svn: 319975
2017-12-06 22:12:24 +00:00
Kamil Rytarowski 0192818ffe Correct atexit(3) support in MSan/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.
 - Allow usage of global vars with ctors in interceptors.
   This allows to use Vector without automatic cleaning up the structures.

This code has been modeled after TSan implementation for the same functions.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 319967
2017-12-06 21:57:39 +00:00