Commit Graph

7189 Commits

Author SHA1 Message Date
Qin Zhao e24bc365e8 [esan|cfrag] Add the struct field size array in StructInfo
Summary:
Adds the struct field size array in the struct StructInfo.

Prints struct field size info in the report.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits, kubabrecka

Differential Revision: http://reviews.llvm.org/D21342

llvm-svn: 272988
2016-06-17 04:50:11 +00:00
Evgeniy Stepanov 3c17c73924 [msan] Intercept send/sendto/sendmsg.
send/sendmsg moved from tsan to sanitizer_common; sendto is new.

llvm-svn: 272980
2016-06-17 00:43:11 +00:00
Kostya Serebryany bf6a04fde8 [sanitizers] introduce yet another API function: __sanitizer_install_malloc_and_free_hooks
llvm-svn: 272943
2016-06-16 20:06:06 +00:00
Derek Bruening 91c88e6558 [esan] Use internal_mmap during initialization
Fixes another interceptor issue where an app with a static tcmalloc
library that prevents our early-calloc handling from triggering yet
does not have a static mmap crashes in our mmap interceptor.  The
solution is to call internal_mmap when REAL(mmap) is not yet set up.

llvm-svn: 272870
2016-06-16 03:19:58 +00:00
Evgeniy Stepanov 062c26f1f0 Merge two coverage tests undef UBSan into one.
Also replace mkdir -p with rm -rf && mkdir.

llvm-svn: 272839
2016-06-15 21:18:17 +00:00
Qin Zhao cd5fe14d89 [esan|cfrag] Minor cfrag report adjustment
Summary:
Reports the struct field access info only if it has been used at least
once.

Adds type printing size limit.

Formats the cache_frag.cpp with clang-format.

Reviewers: bruening

Subscribers: llvm-commits, eugenis, kcc, zhaoqin, vitalybuka, aizatsky, kubabrecka

Differential Revision: http://reviews.llvm.org/D21351

llvm-svn: 272810
2016-06-15 17:27:29 +00:00
Dmitry Vyukov 88f47d3521 tsan: intercept epoll_pwait
llvm-svn: 272779
2016-06-15 12:22:05 +00:00
Evgeniy Stepanov 9ea0833b6e Fix ubsan/coverage test to put coverage file in a subdirectory.
By default coverage is dumped to the current directory, which may not
always be writable.

llvm-svn: 272732
2016-06-14 22:53:29 +00:00
Evgeniy Stepanov c565cfaac9 Compiler-rt test for sanitizer coverage w/o sanitizers.
llvm-svn: 272718
2016-06-14 21:33:59 +00:00
Etienne Bergeron 89200ccefa In asan on Windows 64-bit, this is one of the broken things
that makes allocation fail. "UL" is 32-bit and shift by 40 will make
the value overflow and become 0.

Patch by Wei Wang

Differential Revision: http://reviews.llvm.org/D21310

llvm-svn: 272689
2016-06-14 18:05:45 +00:00
Vedant Kumar 8e2dd518af [profile] Update a warning message (NFC)
It's possible for a merge pool specifier to appear anywhere in a
filename pattern. Update the warning to reflect this.

llvm-svn: 272685
2016-06-14 17:23:13 +00:00
Adhemerval Zanella c0c6835096 [sanitizer] Revert new GLIBC msghdr/cmsghdr definitions
GLIBC reverted the POSIX conformance changes for msghdr/cmsghdr [1],
so there is no need to fix it on sanitizers.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=78880cc185dc521855a58001a28e3059722d8e85

llvm-svn: 272678
2016-06-14 15:22:37 +00:00
Derek Bruening f6f149da29 [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

Differential Revision: http://reviews.llvm.org/D21083

llvm-svn: 272676
2016-06-14 15:15:38 +00:00
Nico Weber be7aa544f0 Revert r272591, http://lab.llvm.org:8011/builders/clang-x64-ninja-win7 has been broken since this landed.
llvm-svn: 272659
2016-06-14 12:39:22 +00:00
Derek Bruening c4c649e25a [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

Differential Revision: http://reviews.llvm.org/D21083

llvm-svn: 272591
2016-06-13 21:50:00 +00:00
Derek Bruening db176c11dc Revert "[sanitizer][esan] Add internal_sigaction_syscall"
This reverts commit r272553.

The iOS build fails to link.

llvm-svn: 272557
2016-06-13 16:16:49 +00:00
Derek Bruening 19a4b8d8f8 [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

Differential Revision: http://reviews.llvm.org/D21083

llvm-svn: 272553
2016-06-13 15:42:39 +00:00
Jeroen Ketema af0bbd92a2 [builtins] Make SOFT_FP versions of floatdidf and floatundidf compile
llvm-svn: 272551
2016-06-13 15:24:16 +00:00
Jeroen Ketema 0b748f220b [builtins] replace tabs by spaces and remove whitespace at end of line NFC
llvm-svn: 272550
2016-06-13 15:21:04 +00:00
Sean Silva 537b146798 [libprofile] Define an expansion `%clang_profgen=`
llvm-svn: 272498
2016-06-12 04:17:57 +00:00
Xinliang David Li 153e8b6c85 [profile] cleanup file setting code
Differential Revision: http://reviews.llvm.org/D21219

llvm-svn: 272428
2016-06-10 20:35:01 +00:00
Xinliang David Li df5843a532 [profile] fix bot failure on darwin
Profile setting accross shared lib is broken on darwin (to be investigated).
Move the test to Linux only for now

llvm-svn: 272404
2016-06-10 16:23:32 +00:00
Xinliang David Li 1d58b8d95e [profile] add profile path tests for shared lib
Test that __llvm_profile_set_filename invoked in
main program is 'visible' to shared lib (overriding
shared libary's profile path set on command line)

llvm-svn: 272375
2016-06-10 06:14:17 +00:00
Xinliang David Li af053d8b97 [profile] add profile path tests
Testing profile path setter predendence.

llvm-svn: 272372
2016-06-10 05:19:38 +00:00
Qin Zhao a4a7220db1 [esan|cfrag] Add the struct field offset array in StructInfo
Summary:
Adds the struct field offset array in the struct StructInfo.

Prints struct size and field offset info in the report.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits, kubabrecka

Differential Revision: http://reviews.llvm.org/D21191

llvm-svn: 272363
2016-06-10 02:10:34 +00:00
Xinliang David Li 5846d08a2c Fix win bot failure
llvm-svn: 272316
2016-06-09 21:52:24 +00:00
Chris Bieneman d31a728d76 [CMake] Cleanup CMake version checking
CMAKE_VERSION is always greater than 3.0 now. No reason not to remove the extra compatibility code.

llvm-svn: 272315
2016-06-09 21:35:37 +00:00
Chris Bieneman bae0eeaf2e [CMake] Cleanup CMake version checking for 2.8.12
Now that we're on CMake 3.4.3 this stuff isn't needed anymore.

The cmake_2_8_12_* variables were unused in Compiler-RT, and the policies being set to NEW are all NEW by default now.

llvm-svn: 272313
2016-06-09 21:32:17 +00:00
Vedant Kumar 2494d18f84 [profile] Fix test to bail on failed waitpid in instrprof-file_ex.c
This resolves PR28066.

Patch by David Binderman!

llvm-svn: 272268
2016-06-09 15:29:59 +00:00
Xinliang David Li e2ce2e0020 [profile] in-process merging support part-3
Differential Revision: http://reviews.llvm.org/D21056

llvm-svn: 272227
2016-06-08 23:43:56 +00:00
Derek Bruening c45e51c891 [esan|wset] Reduce flakiness in samples test
Generalizes the workingset-samples test to pass when a sample has a
size of 0, which can happen on a loaded machine.

llvm-svn: 272175
2016-06-08 17:35:52 +00:00
Vedant Kumar 17af892d6f [profile] Hide some external symbols in InstrProfData.inc
Differential Revision: http://reviews.llvm.org/D21116

llvm-svn: 272167
2016-06-08 16:39:43 +00:00
Xinliang David Li f88d3b9afb [profile] Pass extra build flags (feature enabling macros) to Darwin build
Differential Revision: http://reviews.llvm.org/D21119

llvm-svn: 272162
2016-06-08 16:21:35 +00:00
Vedant Kumar 33b8b64aef [profile] Un-hide two symbols
- lprofCurFilename was intended to have external visibility. This is
  pending further discussion.
- The raw version number doesn't need to be hidden: hiding it may make
  it easier to accidentally combine FE/IR profiles.

See the mailing list discussion on r272081.

llvm-svn: 272089
2016-06-08 01:33:15 +00:00
Vedant Kumar b202ad6518 [profile] Hide a few external symbols (NFCI)
There are still a few external symbols visible from InstrProfData.inc.
The plan for dealing with those isn't as straightforward, so I'll try it
in a separate commit.

llvm-svn: 272081
2016-06-08 00:44:38 +00:00
Derek Bruening ff5cafa2ec [esan] Intercept calloc to avoid deadlocks with tcmalloc
Summary:
When tcmalloc initializes before esan, esan's initialization ends up
calling back into tcmalloc due to the calloc done by dlsym.  This results
in a deadlock.  We avoid this by special-casing this single allocation.

Intercepting calloc also gives us the opportunity to act on its zeroing as
stores by the application.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

Differential Revision: http://reviews.llvm.org/D21086

llvm-svn: 272076
2016-06-08 00:00:27 +00:00
Kostya Serebryany 86020ba32b [scudo] trying to fix the bot: aligned_alloc is not known there; attempt 3
llvm-svn: 272074
2016-06-07 23:49:11 +00:00
Kostya Serebryany 8aa0d7332a [scudo] trying to fix the bot: aligned_alloc is not known there; attempt 2
llvm-svn: 272051
2016-06-07 20:09:49 +00:00
Kuba Brecka 688c3d3bf1 [asan] Turn LSan-related #if’s into regular if’s in ASan initializer
Removing some preprocessor #if’s in favor of regular if’s. However, we need to declare empty stub functions to avoid linker errors.

Differential Revision: http://reviews.llvm.org/D20911

llvm-svn: 272047
2016-06-07 19:13:38 +00:00
Kostya Serebryany 86f8d33442 [scudo] trying to fix the bot: aligned_alloc is not known there
llvm-svn: 272037
2016-06-07 18:29:10 +00:00
Kostya Serebryany 422ea24d45 [asan] make print_memory_profile_test more reliable by using large allocation sizes. Hoping to fix the llvm-clang-lld-x86_64-debian-fast bot
llvm-svn: 272020
2016-06-07 16:08:59 +00:00
Adhemerval Zanella 2c8fc6f8c9 [sanitizer] Fix build for new GLIBC msghdr/cmsghdr definition
GLIBC now follows POSIX [1] for both msghdr and cmsghdr definitions,
which means that msg_iovlen, msg_controllen, and cmsg_len are no
longer size_t but sockelen_t for 64-bits architectures. The final struct
size does not change, since paddings were added.

This patch fixes the build issue against GLIBC 2.24 socket.h header by
using the same definition for internal __sanitizer_msghdr and
__sanitizer_cmsghdr.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/

llvm-svn: 272008
2016-06-07 13:19:38 +00:00
Kostya Serebryany 712fc9803a [sanitizer] Initial implementation of a Hardened Allocator
Summary:
This is an initial implementation of a Hardened Allocator based on Sanitizer Common's CombinedAllocator.
It aims at mitigating heap based vulnerabilities by adding several features to the base allocator, while staying relatively fast.
The following were implemented:
- additional consistency checks on the allocation function parameters and on the heap chunks;
- use of checksum protected chunk header, to detect corruption;
- randomness to the allocator base;
- delayed freelist (quarantine), to mitigate use after free and overall determinism.
Additional mitigations are in the works.

Reviewers: eugenis, aizatsky, pcc, krasin, vitalybuka, glider, dvyukov, kcc

Subscribers: kubabrecka, filcab, llvm-commits

Differential Revision: http://reviews.llvm.org/D20084

llvm-svn: 271968
2016-06-07 01:20:26 +00:00
David Blaikie 7d492c4ff8 add -f to rm so the test passes the first time it's run the file file is not present
(otherwise it just keeps failing at the rm step and never passes... )

llvm-svn: 271959
2016-06-06 23:31:58 +00:00
Sean Silva 7e4e69abe2 [libprofile] Also use `env` for this test.
(necessary on Windows)

llvm-svn: 271955
2016-06-06 23:19:23 +00:00
Sean Silva d7caf5889b [libprofile] Add %run to a couple tests.
llvm-svn: 271947
2016-06-06 22:19:49 +00:00
Xinliang David Li 0891b6d59b [profile] code cleanup /NFC
Address review feedback for better
readability.

llvm-svn: 271922
2016-06-06 18:31:29 +00:00
Kuba Brecka 304b2c2a45 [tsan] Switch to InternalAlloc everywhere __libc_malloc is currently used
This patch replaces all uses of __libc_malloc and friends with the internal allocator.

It seems that the only reason why we have calls to __libc_malloc in the first place was the lack of the internal allocator at the time. Using the internal allocator will also make sure that the system allocator is never used (this is the same behavior as ASan), and we don’t have to worry about working with unknown pointers coming from the system allocator.

Differential Revision: http://reviews.llvm.org/D21025

llvm-svn: 271916
2016-06-06 18:18:47 +00:00
Etienne Bergeron 7a1bafd6ae This patch attempts to primitive support for Win64 asan
Some known issues are:

When "head" include instructions that involve branching, the "cut and paste" approach may break down in a way that function interception still work but calling back the original function does not work.
The jmp [rip -8] saves some bytes in the "head" but finding the safe zone of 0xCC is not implemented yet. So it may stomp on preceding codes.
The shadow offset is not working yet on Win64. More complexity maybe involved since there are some differences regarding virtual address space between Window 8 and Windows 8.1/10.

Patch by: Wang Wei

Differential Revision: http://reviews.llvm.org/D20884

llvm-svn: 271915
2016-06-06 18:09:54 +00:00
Kuba Brecka cdf3492191 [tsan] On OS X, optimize main thread’s ThreadState accesses
This is a very simple optimization that gets about 10% speedup for certain programs. We’re currently storing the pointer to the main thread’s ThreadState, but we can store the state directly in a static variable, which avoid the load acquire.

Differential Revision: http://reviews.llvm.org/D20910

llvm-svn: 271906
2016-06-06 16:27:38 +00:00