Commit Graph

14162 Commits

Author SHA1 Message Date
Evgenii Stepanov d693957e58 [scudo] Handle predefined M_MEMTAG_TUNING_* constants (NFC).
Bionic <malloc.h> may provide the definitions of M_MEMTAG_TUNING_* constants.
Do not redefine them in that case.

Differential Revision: https://reviews.llvm.org/D104758
2021-06-22 17:39:55 -07:00
Petr Hosek 959dbd1761 Revert "Revert "[cmake] [compiler-rt] Call llvm_setup_rpath() when adding shared libraries.""
This reverts commit 21c008d5a5 since
it broke the build on macOS and Windows with the following error:

  The install of the clang_rt.<na,e> target requires changing an
  RPATH from the build tree, but this is not supported with the Ninja
  generator unless on an ELF-based platform.  The
  CMAKE_BUILD_WITH_INSTALL_RPATH variable may be set to avoid this relinking
  step.
2021-06-22 16:11:29 -07:00
Petr Hosek cadfaf2df4 [compiler-rt] Make use of undefined symbols configurable
We want to disable the use of undefined symbols on Fuchsia, but there
are cases where it might be desirable so may it configurable.

Differential Revision: https://reviews.llvm.org/D104728
2021-06-22 14:25:36 -07:00
Petr Hosek 21c008d5a5 Revert "[cmake] [compiler-rt] Call llvm_setup_rpath() when adding shared libraries."
This reverts commit 78fd93e039 as
a follow up to D91099.
2021-06-22 12:42:39 -07:00
Nikita Popov ae1093921f Revert "[compiler-rt] Make use of undefined symbols configurable"
This reverts commit ed7086ad46.
This reverts commit b9792638b0.

This breaks cmake with message:

    CMake Error at llvm-project/compiler-rt/CMakeLists.txt:449:
      Parse error.  Expected "(", got newline with text "
2021-06-22 21:20:20 +02:00
Petr Hosek ed7086ad46 [CMake] Fix the option declaration
This addresses build issue introduced in
b9792638b0.
2021-06-22 11:58:26 -07:00
Petr Hosek b9792638b0 [compiler-rt] Make use of undefined symbols configurable
We want to disable the use of undefined symbols on Fuchsia, but there
are cases where it might be desirable so may it configurable.

Differential Revision: https://reviews.llvm.org/D104728
2021-06-22 11:49:31 -07:00
Petr Hosek fa5f425209 [compiler-rt][CMake] Drop flags that are set by default for Fuchsia
-Wl,-z,now is set by the Fuchsia driver, -Wl,-z,relro is the default
in LLD.
2021-06-22 11:49:30 -07:00
Andrew Browne 759e797767 [DFSan][NFC] Refactor Origin Address Alignment code.
Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104565
2021-06-21 14:52:02 -07:00
Petr Hosek d4c2b973ed [profile] Fix variable name
This fixes a bug introduced in d85c258fd1.
2021-06-19 14:55:32 -07:00
Fangrui Song 8ea2a58a2e [llvm-profdata] Make diagnostics consistent with the (no capitalization, no period) style
The format is currently inconsistent. Use the https://llvm.org/docs/CodingStandards.html#error-and-warning-messages style.

And add `error:` or `warning:` to CHECK lines wherever appropriate.
2021-06-19 14:54:25 -07:00
Petr Hosek d85c258fd1 [profile] Don't publish VMO if there are no counters
If there are no counters, there's no need to publish the VMO.

Differential Revision: https://reviews.llvm.org/D102786
2021-06-19 14:47:57 -07:00
George Balatsouras 070556237e [libfuzzer] Disable failing DFSan-related tests
These have been broken by https://reviews.llvm.org/D104494.
However, `lib/fuzzer/dataflow/` is unused (?) so addressing this is not a priority.

Added TODOs to re-enable them in the future.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104568
2021-06-19 01:09:19 +00:00
Fangrui Song 5540470f64 [profile][test] Delete profraw directory so that tests are immune to format version upgrade 2021-06-18 16:44:03 -07:00
Leonard Chan f7999e73ca [NFC][compiler-rt][hwasan] Move hwasanThreadList().CreateCurrentThread() into InitThreads
Once D104553 lands, CreateCurrentThread will be able to accept optional
parameters for initializing the hwasan thread object. On fuchsia, we can get
stack info in the platform-specific InitThreads and pass it through
CreateCurrentThread. On linux, this is a no-op.

Differential Revision: https://reviews.llvm.org/D104561
2021-06-18 13:40:55 -07:00
Andrew Browne 14407332de [DFSan] Cleanup code for platforms other than Linux x86_64.
These other platforms are unsupported and untested.
They could be re-added later based on MSan code.

Reviewed By: gbalats, stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104481
2021-06-18 11:21:46 -07:00
Florian Mayer e0b68f7149 [hwasan] Clarify report for allocation-tail-overwritten.
Explain what the given stack trace means before showing it, rather than
only in the paragraph at the end.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104523
2021-06-18 18:52:41 +01:00
Leonard Chan 88d93923e6 [compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp
This allows for other implementations to define their own version of `Thread::Init`.
This will be the case for Fuchsia where much of the thread initialization can be
broken up between different thread hooks (`__sanitizer_before_thread_create_hook`,
`__sanitizer_thread_create_hook`, `__sanitizer_thread_start_hook`). Namely, setting
up the heap ring buffer and stack info and can be setup before thread creation.
The stack ring buffer can also be setup before thread creation, but storing it into
`__hwasan_tls` can only be done on the thread start hook since it's only then we
can access `__hwasan_tls` for that thread correctly.

Differential Revision: https://reviews.llvm.org/D104248
2021-06-18 10:32:41 -07:00
Matt Morehouse 493565a4aa [HWASan] Run LAM tests with -hwasan-generate-tags-with-calls.
The default callback instrumentation in x86 LAM mode uses ASLR bits
to randomly choose a tag, and thus has a 1/64 chance of choosing a
stack tag of 0, causing stack tests to fail intermittently.  By using
__hwasan_generate_tag to pick tags, we guarantee non-zero tags and
eliminate the test flakiness.

aarch64 doesn't seem to have this problem using thread-local addresses
to pick tags, so perhaps we can remove this workaround once we implement
a similar mechanism for LAM.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104470
2021-06-18 08:10:51 -07:00
George Balatsouras c6b5a25eeb [dfsan] Replace dfs$ prefix with .dfsan suffix
The current naming scheme adds the `dfs$` prefix to all
DFSan-instrumented functions.  This breaks mangling and prevents stack
trace printers and other tools from automatically demangling function
names.

This new naming scheme is mangling-compatible, with the `.dfsan`
suffix being a vendor-specific suffix:
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-structure

With this fix, demangling utils would work out-of-the-box.

Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104494
2021-06-17 22:42:47 -07:00
Andrew Browne 39295e92f7 Revert "[DFSan] Cleanup code for platforms other than Linux x86_64."
This reverts commit 8441b993bd.

Buildbot failures.
2021-06-17 14:19:18 -07:00
Andrew Browne 8441b993bd [DFSan] Cleanup code for platforms other than Linux x86_64.
These other platforms are unsupported and untested.
They could be re-added later based on MSan code.

Reviewed By: gbalats, stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104481
2021-06-17 14:08:40 -07:00
Yabin Cui ac35ed5d34 [compiler-rt][hwasan]: undefine new/delete operators with alignment on Android.
This is to fix build on Android. And we don't want to intercept more new/delete operators on Android.

Differential Revision: https://reviews.llvm.org/D104313
2021-06-17 09:28:12 -07:00
Kevin Athey 249d9b051f Revert "Remove obsolete call to AsyncSignalSafeLazyInitiFakeStack."
This reverts commit 07481b3796.

Differential Revision: https://reviews.llvm.org/D104469
2021-06-17 09:27:02 -07:00
Florian Mayer ccc0f777f6 [hwasan] Improve report for addresses within regions.
Before: ADDR is located -320 bytes to the right of 1072-byte region
After: ADDR is located 752 bytes inside 1072-byte region

Reviewed By: eugenis, walli99

Differential Revision: https://reviews.llvm.org/D104412
2021-06-17 12:01:30 +01:00
Florian Mayer 18070723ef [hwasan] Do not use short granule tags as poison tags.
Short granule tags as poison cause a UaF to read the referenced
memory to retrieve the tag, and means we do not detect the UaF
if the last granule's tag is still around.

This only increases the change of not catching a UaF from
0.39 % (1 / 256) to 0.42 % (1 / (256 - 17)).

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104304
2021-06-17 11:59:37 +01:00
Florian Mayer b18f30fb2d [NFC] test commit, fix namespace ending comment. 2021-06-17 11:18:36 +01:00
Kristof Beyls 6f0e74cd58 Avoid unnecessary AArch64 DSB in __clear_cache in some situations.
The dsb after instruction cache invalidation only needs to be executed
if any instruction cache invalidation did happen.
Without this change, if the CTR_EL0.DIC bit indicates that instruction
cache invalidation is not needed, __clear_cache would execute two dsb
instructions in a row; with the second one being unnecessary.

Differential Revision: https://reviews.llvm.org/D104371
2021-06-17 07:45:06 +01:00
Kevin Athey 07481b3796 Remove obsolete call to AsyncSignalSafeLazyInitiFakeStack.
Code was originally added for Myriad D46626 which was removed
with D104279.

related to: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka, morehouse

Differential Revision: https://reviews.llvm.org/D104419
2021-06-16 18:26:33 -07:00
Kostya Kortchinsky 8b062b6160 [scudo] Ensure proper allocator alignment in TSD test
The `MockAllocator` used in `ScudoTSDTest` wasn't allocated
properly aligned, which resulted in the `TSDs` of the shared
registry not being aligned either. This lead to some failures
like: https://reviews.llvm.org/D103119#2822008

This changes how the `MockAllocator` is allocated, same as
Vitaly did in the combined tests, properly aligning it, which
results in the `TSDs` being aligned as well.

Add a `DCHECK` in the shared registry to check that it is.

Differential Revision: https://reviews.llvm.org/D104402
2021-06-16 14:21:58 -07:00
Kevin Athey c4992bf593 [NFC][sanitizer] Remove calls to __asan_get_current_fake_stack
Unnecessary with -fsanitize-address-use-after-return=never.

for issue: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D104154
2021-06-15 18:52:22 -07:00
Vitaly Buka 6478ef61b1 [asan] Remove Asan, Ubsan support of RTEMS and Myriad
Differential Revision: https://reviews.llvm.org/D104279
2021-06-15 12:59:05 -07:00
Leonard Chan fc006b3e5d [compiler-rt][hwasan] Add GetShadowOffset function
Similar to SHADOW_OFFSET on asan, we can use this for hwasan so platforms that
use a constant value for the start of shadow memory can just use the constant
rather than access a global.

Differential Revision: https://reviews.llvm.org/D104275
2021-06-15 10:46:11 -07:00
Alex Richardson 13f0b85212 Fix Windows builders after 244601f472
Apparently __builtin_abort() is not supported when targetting Windows.
This should fix the following builder errors:
clang_rt.builtins-x86_64.lib(int_util.c.obj) : error LNK2019: unresolved
external symbol __builtin_abort referenced in function __compilerrt_abort_impl
2021-06-15 09:47:29 +01:00
Alex Richardson 244601f472 [builtins] Allow compiling the builtins without libc headers
When compiled with -ffreestanding, we should not assume that headers
declaring functions such as abort() are available. While the compiler may
still emit calls to those functions [1], we should not require the headers
to build compiler-rt since that can result in a cyclic dependency graph:
The compiler-rt functions might be required to build libc.so, but the libc
headers such as stdlib.h might only be available once libc has been built.

[1] From https://gcc.gnu.org/onlinedocs/gcc/Standards.html:
GCC requires the freestanding environment provide memcpy, memmove,
memset and memcmp. Finally, if __builtin_trap is used, and the target
does not implement the trap pattern, then GCC emits a call to abort.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D103876
2021-06-15 09:08:59 +01:00
Lang Hames 68c161090e [ORC-RT] Fix void function handling in the WrapperFunction utility.
Handlers returning void previously caused compile errors. Fix that by
substituting SPSEmpty placeholder values.
2021-06-15 15:49:40 +10:00
Vitaly Buka 51ed1c6ccc [NFC][hwasan] Fix "implicitly declaring library function" 2021-06-14 21:58:59 -07:00
Vitaly Buka b8919fb0ea [NFC][sanitizer] clang-format some code 2021-06-14 18:05:22 -07:00
Leonard Chan 312011899a [compiler-rt][hwasan] Add newline between record_addr lines on frame record dumps
If SymbolizePC failes, it's possible for the newline to not be emitted.

Differential Revision: https://reviews.llvm.org/D103845
2021-06-14 17:13:13 -07:00
Matt Morehouse b87894a1d2 [HWASan] Enable globals support for LAM.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D104265
2021-06-14 14:20:44 -07:00
George Balatsouras 98504959a6 [dfsan] Add stack-trace printing functions to dfsan interface
Reviewed By: stephan.yichao.zhao

Differential Revision: https://reviews.llvm.org/D104165
2021-06-14 14:09:00 -07:00
Lang Hames ba9e28064b [ORC-RT] Fix an error check. 2021-06-14 11:59:20 +10:00
Khem Raj 60e32a1f34 [fuzzer] Fix build on musl
cstddef is needed for size_t definition.
(Multiple headers can provide size_t but none of them exists.)

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D96213
2021-06-13 12:32:07 -07:00
Lang Hames a7c3105adb [ORC-RT] Remove unused header in unit test. 2021-06-13 20:45:20 +10:00
Lang Hames e405db075b [ORC-RT] Fix a comment. 2021-06-13 20:26:51 +10:00
Lang Hames 49f4a58d53 [ORC-RT] Split Simple-Packed-Serialization code into its own header.
This will simplify integration of this code into LLVM -- The
Simple-Packed-Serialization code can be copied near-verbatim, but
WrapperFunctionResult will require more adaptation.
2021-06-13 10:17:13 +10:00
Kai Luo 6393164cf2 [AIX][compiler-rt] Fix cmake build of libatomic for cmake-3.16+
cmake-3.16+ for AIX changes the default behavior of building a `SHARED` library which breaks AIX's build of libatomic, i.e., cmake-3.16+ builds `SHARED` as an archive of dynamic libraries. To fix it, we have to build `libatomic.so.1` as `MODULE` which keeps `libatomic.so.1` as an normal dynamic library.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D103786
2021-06-12 00:12:29 +00:00
Reid Kleckner b9af157fd1 [ASan/Win] Hide index from compiler to avoid new clang warning 2021-06-11 16:12:28 -07:00
Kevin Athey 60084d4900 [sanitizer] Replace -mllvm -asan-use-after-return in compile-rt tests with -fsanitize-address-use-after-return (NFC)
for issue: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D104146
2021-06-11 15:13:22 -07:00
John Paul Adrian Glaubitz 27ef43d279 [compiler-rt] Add platform detection support for x32
Currently, the compiler-rt build system checks only whether __X86_64
is defined to determine whether the default compiler-rt target arch
is x86_64. Since x32 defines __X86_64 as well, we must also check that
the default pointer size is eight bytes and not four bytes to properly
detect a 64-bit x86_64 compiler-rt default target arch.

Reviewed By: hvdijk, vitalybuka

Differential Revision: https://reviews.llvm.org/D99988
2021-06-11 19:44:04 +01:00