Commit Graph

11661 Commits

Author SHA1 Message Date
Stephan Bergmann 2f0ef58e53 Fix for Windows
...after 5745eccef5 "Adapt -fsanitize=function to
SANITIZER_NON_UNIQUE_TYPEINFO"

llvm-svn: 359760
2019-05-02 07:05:29 +00:00
Stephan Bergmann 5745eccef5 Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO
This follows up after b7692bc3e9 "[UBSan] Fix
isDerivedFromAtOffset on iOS ARM64" fixed the RTTI comparison in
isDerivedFromAtOffset on just one platform and then
a25a2c7c9a "Always compare C++ typeinfo (based on
libstdc++ implementation)" extended that fix to more platforms.

But there is another RTTI comparison for -fsanitize=function generated in
clang's CodeGenFunction::EmitCall as just a pointer comparison.  For
SANITIZER_NON_UNIQUE_TYPEINFO platforms this needs to be extended to also do
string comparison.  For that, __ubsan_handle_function_type_mismatch[_abort]
takes the two std::type_info pointers as additional parameters now, checks them
internally for potential equivalence, and returns without reporting failure if
they turn out to be equivalent after all.  (NORETURN needed to be dropped from
the _abort variant for that.)  Also these functions depend on ABI-specific RTTI
now, so needed to be moved from plain UBSAN_SOURCES (ubsan_handlers.h/cc) to
UBSAN_CXXABI_SOURCES (ubsan_handlers_cxx.h/cc), but as -fsanitize=function is
only supported in C++ mode that's not a problem.

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

llvm-svn: 359759
2019-05-02 06:40:33 +00:00
Hubert Tong 50721b27c4 [compiler-rt][tests] Propagate COMPILER_RT_UNITTEST_LINK_FLAGS
`COMPILER_RT_UNITTEST_LINK_FLAGS` is dropped in many places, unlike
`COMPILER_RT_UNITTEST_CFLAGS`. This patch attempts to remove that
inconsistency.

Previously reviewed as part of D58951.

Reviewers: sfertile, peter.smith, pzheng, phosek, Hahnfeld, nemanjai, jasonliu

Reviewed By: sfertile

Subscribers: jsji, kubamracek, dberris, mgorny, delcypher, jdoerfert, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 359733
2019-05-01 22:25:16 +00:00
Vitaly Buka fbcec6cad0 [tsan] Fix and re-enable user_malloc.cc test
Summary: no_sanitize_thread is not enough as it still puts some tsan instrumentation

Reviewers: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359731
2019-05-01 21:53:39 +00:00
Vitaly Buka 9ef838761e [sanitizer][NFC] Remove unneeded SizeClassAllocatorLocalCache
llvm-svn: 359729
2019-05-01 21:23:07 +00:00
Vitaly Buka 59bcb788ec [sanitizer][NFC] Add const/static into a couple of methods
llvm-svn: 359728
2019-05-01 21:22:59 +00:00
Julian Lettner 91c166cbb0 [Sanitizer] Reland "Cleanup INTERCEPT_FUNCTION macro"
On Linux both version of the INTERCEPT_FUNCTION macro now return true
when interception was successful. Adapt and cleanup some usages.

Also note that `&(func) == &WRAP(func)` is a link-time property, but we
do a runtime check.

Tested on Linux and macOS.

Previous attempt reverted by: 5642c3feb0

This attempt to bring order to the interceptor macro goes the other
direction and aligns the Linux implementation with the way things are
done on Windows.

Reviewed By: vitalybuka, rnk

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

llvm-svn: 359725
2019-05-01 20:57:59 +00:00
Vitaly Buka 20c5676416 [sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocator
They need to have same AddressSpaceView and MapUnmapCallback.

Reviewers: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359719
2019-05-01 19:41:54 +00:00
Vitaly Buka 7780f51614 [scudo][NFC] Remove unneeded template from scudo::CombinedAllocator
Reviewers: cryptoad, eugenis

Reviewed By: cryptoad

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359718
2019-05-01 19:36:26 +00:00
Vitaly Buka 76931df40f [sanitizer][NFC] Get type of AllocatorCache from CombinedAllocator
Reviewers: eugenis, cryptoad, kcc

Reviewed By: kcc

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

Tags: #sanitizers, #llvm

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

llvm-svn: 359715
2019-05-01 19:30:49 +00:00
Evgeniy Stepanov d1a710047b [sanitizer] Implement reallocarray.
Summary:
It's a cross of calloc and realloc. Sanitizers implement calloc-like check for size
overflow.

Reviewers: vitalybuka, kcc

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359708
2019-05-01 17:33:01 +00:00
Peter Smith 101bf520d1 [libFuzzer] Add --dump-input-on-failure to help diagnose AArch64 failures
The fork-siguser.test and fork.test intermittently fail on the AArch64
buildbot. Unfortunately these failures are not reproducible on a similar
machine and seem to fail when the machines are under load. Before
suggesting the tests be marked unsupported for AArch64 we'd like to see
if we can get some more information about the failures to see if it helps
us reproduce. This patch adds --dump-input-on-failure to the FileCheck
commands to see if we can get some more information about the failures.

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

llvm-svn: 359675
2019-05-01 12:30:04 +00:00
Petr Hosek 3e28075ecc [compiler-rt] Use correct spelling of the -Wno-pedantic variable
This addresses the issue introduced in r359646 which is causing
sanitizer bots to fail.

llvm-svn: 359659
2019-05-01 07:00:27 +00:00
Fangrui Song 99055b9c38 Use __extension__ to suppress __EH_FRAME_LIST__ warnings
gcc -pedantic => warning: ISO C forbids empty initializer braces
clang -pedantic => -Wzero-length-array + -Wgnu-empty-initializer

llvm-svn: 359655
2019-05-01 06:25:21 +00:00
Petr Hosek ad3faadc87 [compiler-rt] Cleanup the --target and --sysroot handling
This addresses issue introduced in r359646.

llvm-svn: 359650
2019-05-01 05:41:58 +00:00
Petr Hosek 738697ea4e [compiler-rt] Pass sysroot and disable pedantic for crtbegin.o/crtend.o
These are needed to make bots happy.

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

llvm-svn: 359646
2019-05-01 03:30:51 +00:00
Petr Hosek a890919745 [compiler-rt] Rework the object build support
The initial implementation didn't properly support cross-compilation
via the runtime build, the updated implementation should address that
by expanding the CMAKE_C_COMPILE_OBJECT variable with correct values.

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

llvm-svn: 359644
2019-05-01 02:49:45 +00:00
Jonathan Metzman a5147e0e15 [libFuzzer] Disable i386 on non-Linux platforms
Summary: Disable i386 on non-Linux platforms since it is unwanted and broken on Windows.

Reviewers: morehouse, rnk

Reviewed By: morehouse

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359641
2019-05-01 01:40:31 +00:00
Jonathan Metzman c0806e0d24 [libFuzzer] Fix failing test: sigint.test
Summary:
Fix sigint.test by making it require msan rather
than enumerating unsupported platforms.

Reviewers: kcc

Reviewed By: kcc

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359638
2019-04-30 23:46:52 +00:00
Mitch Phillips 40f98d4b78 Added test.
llvm-svn: 359632
2019-04-30 23:07:12 +00:00
Mitch Phillips 84ea3f2a48 [sanitizer_common] Added 64-bit signed flag parser.
Summary: Adds a 64-bit signed flag parser for GWP-ASan's use.

Reviewers: vlad.tsyrklevich, eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits, vitalybuka, morehouse, pcc, kcc

Tags: #sanitizers, #llvm

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

llvm-svn: 359631
2019-04-30 23:07:10 +00:00
Kostya Serebryany 905e60c422 [libFuzzer] temporarily disable a test on windows, where there is no memmem in the usual place
llvm-svn: 359624
2019-04-30 22:27:38 +00:00
Kostya Serebryany c239eda8a0 [libFuzzer] add MagicSeparatorTest
llvm-svn: 359620
2019-04-30 22:05:55 +00:00
Reid Kleckner 5642c3feb0 Revert r359325 "[NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to void"
Changing INTERCEPT_FUNCTION to return void is not functionally correct.
IMO the best way to communicate failure or success of interception is
with a return value, not some external address comparison.

This change was also creating link errors for _except_handler4_common,
which is exported from ucrtbase.dll in 32-bit Windows.

Also revert dependent changes r359362 and r359466.

llvm-svn: 359611
2019-04-30 20:59:56 +00:00
Jonathan Metzman f3ee97731e [libFuzzer] Replace -seed_corpus to better support fork mode on Win
Summary:
Pass seed corpus list in a file to get around argument length limits on Windows.
This limit was preventing many uses of fork mode on Windows.

Reviewers: kcc, morehouse

Reviewed By: kcc

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359610
2019-04-30 20:56:18 +00:00
Amy Kwan 31dbbf1df9 [compiler-rt][builtins][sanitizers] Update compiler-rt test cases for
compatibility with system's toolchain

This patch aims to:
- Guard ompiler-rt/test/builtins/Unit/compiler_rt_logb_test.c with macros, so
the test runs on GLIBC versions >= 2.23. This is because the test relies on
comparing its computed values to libm. Oolder versions might not compute to the
same value as the compiler-rt value.
- Update compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cc
so that std::string is not used, since false positives may be detected.

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

llvm-svn: 359606
2019-04-30 20:09:00 +00:00
Petr Hosek 999bb5ac27 Reland "[compiler-rt] Simple crtbegin.o and crtend.o implementation"
Clang relies on existence of certain symbols that are normally
provided by crtbegin.o/crtend.o. However, LLVM does not currently
provide implementation of these files, instead relying on either
libgcc or implementations provided as part of the system.

This change provides an initial implementation of crtbegin.o/crtend.o
that can be used on system that don't provide crtbegin.o/crtend.o as
part of their C library.

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

llvm-svn: 359591
2019-04-30 18:13:22 +00:00
Jonathan Metzman 7a2ce3790b fix broken test
llvm-svn: 359590
2019-04-30 17:58:59 +00:00
Jonathan Metzman 17bd74d406 remove extra zeros
llvm-svn: 359589
2019-04-30 17:58:58 +00:00
Jonathan Metzman 5a271cd758 remove stale comment
llvm-svn: 359588
2019-04-30 17:58:58 +00:00
Jonathan Metzman d61084901c change order
llvm-svn: 359587
2019-04-30 17:58:57 +00:00
Jonathan Metzman 1fbc6116e1 fix comment
llvm-svn: 359586
2019-04-30 17:58:57 +00:00
Jonathan Metzman 2697664582 [libFuzzer] Enable for i386
Summary: Get libFuzzer to build on i386 and fix tests.

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359585
2019-04-30 17:58:56 +00:00
Jonathan Metzman 6fa864b7a6 Fix issues with testing for i386
llvm-svn: 359584
2019-04-30 17:58:55 +00:00
Jonathan Metzman f721230831 Enable x86 builds
llvm-svn: 359583
2019-04-30 17:58:54 +00:00
Petr Hosek 9300f60c8c Revert "[compiler-rt] Simple crtbegin.o and crtend.o implementation"
This reverts commit r359576 since it's failing on Windows bots.

llvm-svn: 359579
2019-04-30 17:32:05 +00:00
Petr Hosek c8be6e670e [compiler-rt] Simple crtbegin.o and crtend.o implementation
Clang relies on existence of certain symbols that are normally
provided by crtbegin.o/crtend.o. However, LLVM does not currently
provide implementation of these files, instead relying on either
libgcc or implementations provided as part of the system.

This change provides an initial implementation of crtbegin.o/crtend.o
that can be used on system that don't provide crtbegin.o/crtend.o as
part of their C library.

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

llvm-svn: 359576
2019-04-30 17:21:13 +00:00
Kostya Kortchinsky 21c31f5e7b [scudo][standalone] Add the memory reclaiming mechanism
Summary:
This CL implements the memory reclaiming function `releaseFreeMemoryToOS`
and its associated classes. Most of this code was originally written by
Aleksey for the Primary64 in sanitizer_common, and I made some changes to
be able to implement 32-bit reclaiming as well. The code has be restructured
a bit to accomodate for freelist of batches instead of the freearray used
in the current sanitizer_common code.

Reviewers: eugenis, vitalybuka, morehouse, hctim

Reviewed By: vitalybuka

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

Tags: #llvm, #sanitizers

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

llvm-svn: 359567
2019-04-30 14:56:18 +00:00
Reid Kleckner bb92282b29 Fix FIXME added in r359339
We have windows.h in asan_win.cc, so we can just use the correct
prototypes for these EH-related interceptors without worrying.

Also fix an unused variable warning while I'm here.

llvm-svn: 359500
2019-04-29 20:44:26 +00:00
Reid Kleckner c69cd30455 Pacify sanitizer lint script after r359498
llvm-svn: 359499
2019-04-29 20:40:08 +00:00
Matthew G McGovern d62416dfcd [AddressSanitizer] [Windows] Fix HeapReAlloc and _recalloc bugs in asan_malloc_win.cc
HeapReAlloc should allow for 0 sized reallocations without freeing the memory block provided by the user.

_recalloc previously did not zero new memory after reallocation.
https://reviews.llvm.org/D61268

llvm-svn: 359498
2019-04-29 20:26:19 +00:00
Julian Lettner 1f10f6ea51 [Sanitizer] Cleanup {ASAN, MSAN}_INTERCEPT_FUNC[_VER] macro
Note that this change is not strictly NFC since we add the
`(&(name) != &WRAP(name)` part to the conditional for the `_VER` variant
of the macro.

Reviewers: vitalybuka

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

llvm-svn: 359466
2019-04-29 16:39:18 +00:00
Petr Hosek e62915bcc1 [builtins] Use __APPLE__ instead of __MACH__ in check
The latter doesn't seem to be working for all targets. This addresses
the issue introduced in r359413.

llvm-svn: 359423
2019-04-29 08:38:43 +00:00
Petr Hosek cb929dcebe [builtins] Fix the missing assembly on Darwin
This was introduced in r359413.

llvm-svn: 359421
2019-04-29 07:45:15 +00:00
Petr Hosek ba45daab14 [builtins] Fix the typo in the preprocessor check
This was introduced in r359413.

llvm-svn: 359419
2019-04-29 06:30:50 +00:00
Petr Hosek 84da0e1bb7 [builtins] Use aliases for function redirects
Symbol aliases are supported by all platforms that compiler-rt builtins
target, and we can use these instead of function redirects to avoid the
extra indirection.

This is part of the cleanup proposed in "[RFC] compiler-rt builtins
cleanup and refactoring".

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

llvm-svn: 359413
2019-04-29 00:46:23 +00:00
Petr Hosek 0ba22f51d1 [builtins] Use single line C++/C99 comment style
Use the uniform single line C++/99 style for code comments.

This is part of the cleanup proposed in "[RFC] compiler-rt builtins
cleanup and refactoring".

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

llvm-svn: 359411
2019-04-28 22:47:49 +00:00
Petr Hosek 082b89b25f [builtins] Reformat builtins with clang-format
Update formatting to use the LLVM style.

This is part of the cleanup proposed in "[RFC] compiler-rt builtins
cleanup and refactoring".

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

llvm-svn: 359410
2019-04-28 21:53:32 +00:00
Dan Liew 8651edf898 [CMake] Don't modify `FUZZER_SUPPORTED_ARCH` is place.
On a Darwin host we were modifying the `FUZZER_SUPPORTED_ARCH` in place
which would strip out non-x86 architectures. This unhelpful if we
want to use `FUZZER_SUPPORTED_ARCH` later.

To fix this we introduce `FUZZER_TEST_ARCH` which is similar to what we
have for for the other sanitizers. For non-Darwin host platforms
`FUZZER_TEST_ARCH` is the same as `FUZZER_SUPPORTED_ARCH` but for Darwin
host platforms we use `darwin_filter_host_archs(...)` as the previous
code did.

llvm-svn: 359394
2019-04-28 09:44:53 +00:00
Vitaly Buka 0f21545a3c [sanitizer] Calculate SizeClassAllocator32::ByteMap type from Params::kSpaceSize and Params::kRegionSizeLog
Reviewers: eugenis

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

Tags: #sanitizers, #llvm

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

llvm-svn: 359374
2019-04-27 06:30:52 +00:00