Commit Graph

8930 Commits

Author SHA1 Message Date
Evgeniy Stepanov c4bfa0d662 [hwasan] Fix HWASAN_WITH_INTERCEPTORS=OFF build on not-android.
Summary:
I'm not aware of any platforms where this will work, but the code should at least compile.
HWASAN_WITH_INTERCEPTORS=OFF means there is magic in libc that would call __hwasan_thread_enter /
__hwasan_thread_exit as appropriate.

Reviewers: pcc, winksaville

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

Tags: #sanitizers, #llvm

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

llvm-svn: 359914
2019-05-03 18:20:16 +00:00
Martin Storsjo b1f3910283 Avoid duplicate function aliases on MinGW after SVN r359835
On MinGW, the same alias mechanism as for ELF, using
__attribute__((__alias__())), is used.

llvm-svn: 359865
2019-05-03 07:43:23 +00:00
Fangrui Song 3947968e7f [crtbegin] Fix an off-by-1 bug in __do_fini
Differential Revision: https://reviews.llvm.org/D61367

llvm-svn: 359850
2019-05-03 00:11:53 +00:00
Reid Kleckner 3961507ba1 Fix check-builtins on Windows after alias changes
llvm-svn: 359835
2019-05-02 22:11:55 +00:00
Petr Hosek 156226bb70 [compiler-rt] Set the ZX_VMO_RESIZABLE option for zx_vmo_create
Currently VMO in Zircon create using the zx_vmo_create is resizable
by default, but we'll be changing this in the future, requiring an
explicit flag to make the VMO resizable.

Prepare for this change by passing ZX_VMO_RESIZABLE option to all
zx_vmo_create calls that need resizable VMO.

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

llvm-svn: 359803
2019-05-02 17:24:53 +00:00
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 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
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 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
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
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
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 d61084901c change order
llvm-svn: 359587
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 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
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
Vitaly Buka 83c6d10b62 [sanitizer] NFC: add static_assert to confirm that we use reasonable ByteMap type
Summary: If bots work we can replace #ifs with template specialization by TwoLevelByteMapSize1.

There is known users of TwoLevelByteMap with TwoLevelByteMapSize1 equal 8,
and users of FlatByteMap with TwoLevelByteMapSize1 equal 2.

Reviewers: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359364
2019-04-27 02:13:26 +00:00
Julian Lettner c1008e4d3d [NFC][Sanitizer] Remove GetRealFunctionAddress and replace usages
Reviewers: vitalybuka

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

llvm-svn: 359362
2019-04-27 00:49:14 +00:00
JF Bastien 8504b5f64f Revert "[sanitizer] NFC: add static_assert to confirm that we use optimal ByteMap type"
Fails on bots with:

/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h:69:3: error: static_assert failed due to requirement 'TwoLevelByteMapSize1 > 128' "TwoLevelByteMap should be used"
  static_assert(TwoLevelByteMapSize1 > 128, "TwoLevelByteMap should be used");
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h:29:34: note: in instantiation of template class '__sanitizer::SizeClassAllocator32<__sanitizer::AP32>' requested here
                        typename PrimaryAllocator::AddressSpaceView>::value,
                                 ^

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/13960/console

llvm-svn: 359352
2019-04-26 22:29:49 +00:00
Julian Lettner 93c05f097a [Sanitizer][Windows] Speculative fix for broken build on Windows
llvm-svn: 359339
2019-04-26 19:06:55 +00:00
Julian Lettner 74967cb4e0 [Sanitizer] Fix test
I broke the build, panicked and applied the wrong fix in my previous
commit. The ASSERT was obsolete, but not the call INTERCEPT_FUNCTION.

llvm-svn: 359336
2019-04-26 18:39:02 +00:00
Julian Lettner d0e5830017 [Sanitizer] Fix compliation error in test
Remove obsolete assert. I missed this in my previous patch:
https://reviews.llvm.org/D61145

llvm-svn: 359335
2019-04-26 18:27:35 +00:00
Vitaly Buka 077c502ddc Implement __sanitizer::conditional<B, T, F>
llvm-svn: 359334
2019-04-26 18:22:55 +00:00
Vitaly Buka 85dcdae5e3 [sanitizer] NFC: add static_assert to confirm that we use optimal ByteMap type
Summary: If bots work we can replace #ifs with template specialization by TwoLevelByteMapSize1.

Reviewers: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359333
2019-04-26 18:22:47 +00:00
Julian Lettner aebd3014a5 [NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to void
This temporary change tells us about all the places where the return
value of the INTERCEPT_FUNCTION macro is actually used. In the next
patch I will cleanup the macro and remove GetRealFuncAddress.

Reviewed By: vitalybuka

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

llvm-svn: 359325
2019-04-26 17:29:22 +00:00
Vitaly Buka efc94feef9 [NFC] Remove ::kForTest from AP64, it does not use it.
llvm-svn: 359323
2019-04-26 17:04:05 +00:00