Commit Graph

15603 Commits

Author SHA1 Message Date
Vitaly Buka c36fbe05a7 Revert "[sanitizer] Don't run malloc hooks for stacktraces"
Msan crashes on clang-s390x-linux bot

This reverts commit d3531fc7f0.
2022-04-13 23:52:36 -07:00
Blue Gaston e0c4454465 [Darwin][ASan][Sanitizer] Fixes Sanitizer NonUnique Identifier to Account for Mac arm64 architectures.
Current check assumes iOS as the only Apple devices running arm64.
    ```#if SANITIZER_MAC && !(defined(__arm64__) && SANITIZER_IOS)```
    Stops Apple Silicon from being flagged as requiring unique RTTI.
    This introduced unexpected behavior within the sanitizer.

    rdar://91446703

Differential Revision: https://reviews.llvm.org/D123736
2022-04-13 21:11:37 -07:00
Florian Mayer ffd656a2fe [HWASan] symbolize: use buildid index for locals.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D123644
2022-04-13 19:09:04 -07:00
Vitaly Buka 3a54bbb0f2 [sanitizer] Disable malloc_hook_skip on Darwin
Followup to D123566
2022-04-13 18:34:29 -07:00
Vitaly Buka d3531fc7f0 [sanitizer] Don't run malloc hooks for stacktraces
Usually when we generated stacktraces the process is in error state, so
running hooks may crash the process and prevent meaningfull error report.

Symbolizer, unwinder and pthread are potential source of mallocs.

https://b.corp.google.com/issues/228110771

Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D123566
2022-04-13 16:33:53 -07:00
Julian Lettner 8887c63e32 Adapt "cross compile?" check for Apple Silicon
This piece of code tries to implement the semantics "cross compile?" to
determine CFLAGS used for test binary compilation.
```
if(ANDROID OR ${arch} MATCHES "arm|aarch64|riscv32|riscv64")
```

Since Apple Silicon, macOS runs on arm64e, so we take the wrong branch
when compiling and running tests locally "on the host" on an AS machine.

Furthermore, for Apple code, we use the separate
`get_test_cflags_for_apple_platform` function to determine these test
compiliation flags and `get_test_cc_for_arch` is only ever used in the
"compile & run on host" case, so we can short-curcuit the "cross
compile?" check here.

rdar://91446703

Differential Revision: https://reviews.llvm.org/D123633
2022-04-13 15:26:14 -07:00
Vitaly Buka 5d4df59de1 Revert "[sanitizer] Don't run malloc hooks for stacktraces"
Breaks android and iOS bots.
https://green.lab.llvm.org/green/job/clang-san-iossim/5229/consoleFull#711521816a1ca8a51-895e-46c6-af87-ce24fa4cd561
https://lab.llvm.org/buildbot/#/builders/77/builds/16456

This reverts commit 6345d7f2a8.
2022-04-13 13:13:33 -07:00
Vitaly Buka 6345d7f2a8 [sanitizer] Don't run malloc hooks for stacktraces
Usually when we generated stacktraces the process is in error state, so
running hooks may crash the process and prevent meaningfull error report.

Symbolizer, unwinder and pthread are potential source of mallocs.

https://b.corp.google.com/issues/228110771

Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D123566
2022-04-13 11:44:38 -07:00
Nico Weber ba4537b227 [compiler-rt] Don't explictly ad-hoc sign dylibs on APPLE if ld is new enough
ld64 implicitly ad-hoc code-signs as of Xcode 12, and `strip` and friends know
how keep this special ad-hoc signature valid.

So this should have no effective behavior change, except that you can now strip
libclang_rt.asan_osx_dynamic.dylib and it'll still have a valid ad-hoc
signature, instead of strip printing "warning: changes being made to the file
will invalidate the code signature in:" and making the ad-hoc code signature
invalid.

Differential Revision: https://reviews.llvm.org/D123475
2022-04-13 08:35:51 -04:00
Nikita Popov 69fcf6a79e Revert "[ubsan] Simplify ubsan_GetStackTrace"
This reverts commit 63f2d1f4d4.

I don't quite understand why, but this causes a linker error for
me and a number of buildbots:

/home/npopov/repos/llvm-project/compiler-rt/lib/ubsan/../sanitizer_common/sanitizer_stacktrace.h:130: error: undefined reference to '__sanitizer::BufferedStackTrace::UnwindImpl(unsigned long, unsigned long, void*, bool, unsigned int)'
2022-04-13 10:41:23 +02:00
Fangrui Song 63f2d1f4d4 [ubsan] Simplify ubsan_GetStackTrace
Suggested by Vitaly Buka
2022-04-13 00:32:10 -07:00
Vitaly Buka 12e137ab24 [NFC][sanitizer] Consolidate malloc hook invocations 2022-04-12 20:08:29 -07:00
Vitaly Buka b84673b3f4 [NFC][sanitizer] Remove unnececary HOOK macros 2022-04-12 19:47:44 -07:00
Vitaly Buka 47a9528fb4 [NFC][msan] Rename SymbolizerScope to UnwinderScope and hide 2022-04-12 18:57:54 -07:00
Vitaly Buka ce1cb9d2c1 [NFC][sanitizer] Clang format some code 2022-04-12 18:45:50 -07:00
Fangrui Song 9f526057d6 [ubsan][test] Unsupport Android for new test diag-stacktrace.cpp
https://reviews.llvm.org/D123562#3446485 reported that the test failed
on arm-linux-android.
2022-04-12 12:55:44 -07:00
Fangrui Song fdd424e37a [ubsan] Fix print_stacktrace=1:fast_unwind_on_fatal=0 to correctly fallback to fast unwinder
ubsan_GetStackTrace (from 52b751088b) called by
~ScopeReport leaves top/bottom zeroes in the
`!WillUseFastUnwind(request_fast_unwind)` code path.
When BufferedStackTrace::Unwind falls back to UnwindFast,
`if (stack_top < 4096) return;` will return early, leaving just one frame in the stack trace.

Fix this by always initializing top/bottom like 261d6e05d5.

Reviewed By: eugenis, yln

Differential Revision: https://reviews.llvm.org/D123562
2022-04-12 11:24:19 -07:00
Vitaly Buka 6ddaf0ee71 [sanitizer] Fix internal_mmap in internal symbolizer 2022-04-12 00:39:04 -07:00
Vitaly Buka d5f8b8b6e9 [sanitizer] Fix typo in test 2022-04-11 21:11:28 -07:00
Vitaly Buka 7d6528fc37 [sanitizer] Update undefined symbols of symbolizer 2022-04-11 18:58:56 -07:00
Vitaly Buka 678ef2fbd5 [sanitizer] Make test pass with InternalSymbolizer 2022-04-11 17:36:01 -07:00
Vitaly Buka b87b642aa6 [sanitizer] Fix arg types of internal functions
They didn't match sanitizer_common for 32bit.
2022-04-11 17:36:01 -07:00
Florian Mayer a0570e7750 [HWASan] allow symbolizer script to index binaries by build id.
Tested on an example callstack with misplaced binaries from Android.
Tested Regex against callstack without Build ID to confirm it still works.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D123437
2022-04-11 14:12:31 -07:00
Arthur Eubanks 61d418f971 [test] Remove references to -fexperimental-new-pass-manager in tests
This has been the default for a while and we're in the process of removing the legacy PM optimization pipeline.
2022-04-11 13:29:08 -07:00
Ulrich Weigand f018a5f6e0 [compiler-rt][SystemZ] Skip fuzzer/coverage.test
This test is currently marked as XFAIL on s390x, but it is randomly
passing, causing build bot issues.  Setting as UNSUPPORTED for now.
2022-04-11 16:18:09 +02:00
Aaron Ballman bdbfaf0ca7 Giving a lot more functions prototypes; NFC
This should address https://lab.llvm.org/buildbot/#/builders/37/builds/12315
and speculatively fix other similar diagnostics.
2022-04-09 17:25:10 -04:00
Aaron Ballman 40ef3e6df6 Add some prototypes to these functions; NFC
This is expected to fix the issues in this build bot:
https://lab.llvm.org/buildbot/#/builders/37/builds/12312
2022-04-09 10:53:48 -04:00
Aaron Ballman 5af1ca841f Add some prototypes to these checks; NFC
This should address a build bot failure:
https://lab.llvm.org/buildbot/#/builders/18/builds/4495
2022-04-09 08:38:29 -04:00
Vitaly Buka e03c350eee [sanitizer] Disable new test on Android to fix a bot 2022-04-09 00:57:48 -07:00
Fangrui Song bbb72122aa [scudo][test] Link with -no-pie to be agnostic of CLANG_DEFAULT_PIE_ON_LINUX
This keeps the test behavior unchanged when CLANG_DEFAULT_PIE_ON_LINUX switches
to ON by default.

Note: current clang --target=mips64el-linux-gnu -fpie -pie -fuse-ld=lld
does not link with C++ exceptions, using -pie would lead to

```
ld.lld: error: cannot preempt symbol: DW.ref.__gxx_personality_v0
...
ld.lld: error: relocation R_MIPS_64 cannot be used against local symbol; recompile with -fPIC
...
```

when linking `ScudoUnitTests`: https://lab.llvm.org/buildbot/#/builders/169/builds/7311/steps/18/logs/stdio
2022-04-08 23:30:07 -07:00
Kevin Athey e9c8d0ff71 [MSAN] add __b64_pton and __b64_ntop intercepts
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D122849
2022-04-08 15:22:37 -07:00
Fangrui Song 2aa575fd7f Revert D120327 "compiler-rt: Add udivmodei5 to builtins and add bitint library"
It has several problems like not-compilable weak attribute with MSVC
(and the usage needs further scrutiny), and " different types for formal and actual parameter"
https://lab.llvm.org/buildbot/#/builders/127/builds/27760/steps/7/logs/stdio

This reverts commit 8843245ddd, 492c5c05e1, bf2dc4b376.
2022-04-08 12:39:42 -07:00
Jorge Gorbe Moya 8843245ddd Use portable formatting specified in test. NFCI. 2022-04-08 10:43:20 -07:00
Kevin Athey b401d2a43c Add one more definition for symbols in prctl unit test.
one more follow up to: https://reviews.llvm.org/D122851

Differential Revision: https://reviews.llvm.org/D123404
2022-04-08 09:46:15 -07:00
Kevin Athey 5562d9b3c0 Add definitions for symbols in unit test for prctl.
Follow up to: https://reviews.llvm.org/D122851

Differential Revision: https://reviews.llvm.org/D123395
2022-04-08 08:56:14 -07:00
Nikita Popov 7d2a1b6de4 [Sanitizer] Add -no-opaque-pointers to IR test (NFC)
This test is currently looking for specific typed-pointer IR,
so explicitly disable opaque pointers.
2022-04-08 15:42:05 +02:00
Nikita Popov 3876cd10ae [Profile] Add -no-opaque-pointers to IR tests (NFC)
The output differs slightly with opaque pointers (no GEP constexpr),
add -no-opaque-pointers for now.
2022-04-08 15:42:05 +02:00
Matthias Gehre 492c5c05e1 compiler-rt/lib/builtins/udivmodei5.c: Fix missing macro argument 2022-04-08 10:55:35 +01:00
Matthias Gehre bf2dc4b376 compiler-rt: Add udivmodei5 to builtins and add bitint library
According to the RFC [0], this review contains the compiler-rt parts of large integer divison for _BitInt.

It adds the functions
```
/// Computes the unsigned division of a / b for two large integers
/// composed of n significant words.
/// Writes the quotient to quo and the remainder to rem.
///
/// \param quo The quotient represented by n words. Must be non-null.
/// \param rem The remainder represented by n words. Must be non-null.
/// \param a The dividend represented by n + 1 words. Must be non-null.
/// \param b The divisor represented by n words. Must be non-null.

/// \note The word order is in host endianness.
/// \note Might modify a and b.
/// \note The storage of 'a' needs to hold n + 1 elements because some
///       implementations need extra scratch space in the most significant word.
///       The value of that word is ignored.
COMPILER_RT_ABI void __udivmodei5(su_int *quo, su_int *rem, su_int *a,
                                  su_int *b, unsigned int n);

/// Computes the signed division of a / b.
/// See __udivmodei5 for details.
COMPILER_RT_ABI void __divmodei5(su_int *quo, su_int *rem, su_int *a, su_int *b,
                                 unsigned int words);
```
into builtins.
In addition it introduces a new "bitint" library containing only those new functions,
which is meant as a way to provide those when using libgcc as runtime.

[0] https://discourse.llvm.org/t/rfc-add-support-for-division-of-large-bitint-builtins-selectiondag-globalisel-clang/60329

Differential Revision: https://reviews.llvm.org/D120327
2022-04-08 07:43:15 +01:00
Michael Forney 795b07f549 [asan] Always skip first object from dl_iterate_phdr
All platforms return the main executable as the first dl_phdr_info.
FreeBSD, NetBSD, Solaris, and Linux-musl place the executable name
in the dlpi_name field of this entry. It appears that only Linux-glibc
uses the empty string.

To make this work generically on all platforms, unconditionally
skip the first object (like is currently done for FreeBSD and NetBSD).
This fixes first DSO detection on Linux-musl. It also would likely
fix detection on Solaris/Illumos if it were to gain PIE support
(since dlpi_addr would not be NULL).

Additionally, only skip the Linux VDSO on linux.

Finally, use the empty string as the "seen first dl_phdr_info"
marker rather than (char *)-1. If there was no other object, we
would try to dereference it for a string comparison.

Reviewed By: MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D119515
2022-04-07 22:35:24 -07:00
Kevin Athey 0713053e4a [MSAN] extend prctl interceptor to support PR_SCHED_CORE
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D122851
2022-04-07 16:49:25 -07:00
Pengxuan Zheng 1c9415806b [compiler-rt][builtins] Move DMB definition to syn-ops.h
Compiler-rt cross-compile for ARMv5 fails because D99282 made it an error if DMB
is used for any pre-ARMv6 targets. More specifically, the "#error only supported
on ARMv6+" added in D99282 will cause compilation to fail when any source file
which includes assembly.h are compiled for pre-ARMv6 targets. Since the only
place where DMB is used is syn-ops.h (which is only included by
arm/sync_fetch_and_* and these files are excluded from being built for older
targets), this patch moves the definition there to avoid the issues described
above.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D123105
2022-04-07 14:57:41 -07:00
Fangrui Song 2edd903c05 [crt][test] Fix dso_handle.cpp for Linux systems which default to PIE 2022-04-07 09:37:59 -07:00
Petr Hosek f5e48a2ad3 [CMake][compiler-rt] Include the missing variables
This includes the missing variables as pointed out in
https://reviews.llvm.org/rGb0e2ffe151c3
2022-04-06 17:40:29 -07:00
Blue Gaston fc4c872d8f [Darwin][ASan] Fix "interceptor working?" check for DriverKit platform
The previous check for interceptors used `pthread_create()` which is not
available on DriverKit.  We need an intercepted symbol that satisfies
the following constraints:

- Symbol is available in DriverKit
- Symbol is provided by simulator runtime dylibs (`dlsym()` fails to
  look up host-provided symbols)

`puts()` satisfies all of the above constraints.

rdar://87895539

Reviewed By: yln

Differential Revision: https://reviews.llvm.org/D123245
2022-04-06 15:49:22 -07:00
Petr Hosek b0e2ffe151 [CMake][compiler-rt] Make CRT separately buildable
This is useful when building a complete toolchain to ensure that CRT
is built after builtins but before the rest of the compiler-rt.

Differential Revision: https://reviews.llvm.org/D120682
2022-04-06 00:48:49 -07:00
Petr Hosek 1558cddedb Revert "[CMake][compiler-rt] Make CRT separately buildable"
This reverts commit b89b18e350 since
it broke the sanitizer bots.
2022-04-06 00:01:06 -07:00
Petr Hosek b89b18e350 [CMake][compiler-rt] Make CRT separately buildable
This is useful when building a complete toolchain to ensure that CRT
is built after builtins but before the rest of the compiler-rt.

Differential Revision: https://reviews.llvm.org/D120682
2022-04-05 22:58:38 -07:00
Roy Sundahl 47e7a22471 [Darwin][ASan][Sanitizer] Enable dlclose-test for all darwin targets.
Test was being skipped on non-x86 darwin architectures.

rdar://79795770

Differential Revision: https://reviews.llvm.org/D123099
2022-04-05 12:21:36 -07:00
Andrew Browne 5748219fd2 [DFSan] Add dfsan-combine-taint-lookup-table option as work around for
false negatives when dfsan-combine-pointer-labels-on-load=0 and
dfsan-combine-offset-labels-on-gep=0 miss data flows through lookup tables.

Example case:
628a2825f8/absl/strings/ascii.h (L182)

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D122787
2022-04-05 11:05:10 -07:00