Commit Graph

15623 Commits

Author SHA1 Message Date
Dominic Chen fcbca197f2 [scudo] Disable memory tagging on arm64_32
arm64_32 is an ILP32 platform

Differential Revision: https://reviews.llvm.org/D124135
2022-04-21 17:22:10 -07:00
Roy Sundahl d179627ef0 Fix sanitizer stack traces on aarch64.
Fixes llvm-project/compiler-rt/test/asan/TestCases/null_deref.cpp on
macOS/aarch64.

The bp (base pointer) variable was being loaded from register LR and
not FP on aarch64 (except for this narrow case):
defined(__IPHONE_8_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0

Without a valid bp from the FP register, it is not possible to traverse
previous frames for a complete stack trace. The rationale for fetching
the LR as the bp for all cases except above is not clear but since the
FP register is the canonical register for use as the frame pointer, this
commit removes the restriction above for unconditional use all aarch64.

rdar://91587039

Differential Revision: https://reviews.llvm.org/D124140
2022-04-21 14:27:59 -07:00
Ulrich Weigand e4085a012c [sanitizer] Fix prctl unit test on non-SMT systems
On systems where the kernel supports the PR_SCHED_CORE
interface, but there is no SMT, the prctl call will set
errno to ENODEV, which currently causes the test to fail.

Fix by accepting ENODEV in addition to EINVAL.
2022-04-21 19:31:04 +02:00
Tyler Mandry d8c1d37ba3 [fuchsia] Don't include duplicate profiling symbols for Fuchsia
InstrProfilingPlatformLinux.c already provides these symbols. Linker order
saved us from noticing before.

Reviewed By: mcgrathr

Differential Revision: https://reviews.llvm.org/D124136
2022-04-21 15:44:37 +00:00
Byoungchan Lee 8a3afc6da5 [compiler-rt][Darwin] Add arm64 to simulator platforms
This patch is the reland of a8e5ce76b4,
which includes additional SDK version checks to ensure that
XCode's headers support arm64 builds.

Differential Revision: https://reviews.llvm.org/D119174
2022-04-21 17:42:31 +02:00
Aaron Ballman e5f025dad9 Speculatively fix build bot
This should fix the issue found by:
https://lab.llvm.org/buildbot/#/builders/37/builds/12606
2022-04-20 13:39:53 -04:00
Aaron Ballman 37a47aacba Speculatively fix build bot
This should address the issue in:
https://lab.llvm.org/buildbot/#/builders/77/builds/16683
2022-04-20 12:32:57 -04:00
Aaron Ballman 7661d3bc9d Speculatively fix build bots
This should address the issues found by:
https://lab.llvm.org/buildbot/#/builders/105/builds/24292
2022-04-20 12:02:16 -04:00
Aaron Ballman 7d644e1215 [C11/C2x] Change the behavior of the implicit function declaration warning
C89 had a questionable feature where the compiler would implicitly
declare a function that the user called but was never previously
declared. The resulting function would be globally declared as
extern int func(); -- a function without a prototype which accepts zero
or more arguments.

C99 removed support for this questionable feature due to severe
security concerns. However, there was no deprecation period; C89 had
the feature, C99 didn't. So Clang (and GCC) both supported the
functionality as an extension in C99 and later modes.

C2x no longer supports that function signature as it now requires all
functions to have a prototype, and given the known security issues with
the feature, continuing to support it as an extension is not tenable.

This patch changes the diagnostic behavior for the
-Wimplicit-function-declaration warning group depending on the language
mode in effect. We continue to warn by default in C89 mode (due to the
feature being dangerous to use). However, because this feature will not
be supported in C2x mode, we've diagnosed it as being invalid for so
long, the security concerns with the feature, and the trivial
workaround for users (declare the function), we now default the
extension warning to an error in C99-C17 mode. This still gives users
an easy workaround if they are extensively using the extension in those
modes (they can disable the warning or use -Wno-error to downgrade the
error), but the new diagnostic makes it more clear that this feature is
not supported and should be avoided. In C2x mode, we no longer allow an
implicit function to be defined and treat the situation the same as any
other lookup failure.

Differential Revision: https://reviews.llvm.org/D122983
2022-04-20 11:30:12 -04:00
Nico Weber 7d2cc882d5 [compiler-rt][sanitizers] build ubsan, asan etc libraries with Mac Catalyst support
Like D118875, but for ubsan, asan, etc.

With this, I can successfully run:

    bin/clang++ -target x86_64-apple-ios14.0-macabi foo.cc \
        -isysroot $(xcrun -show-sdk-path) -fsanitize=undefined

with a locally built libclang_rt.ubsan_osx_dynamic.dylib.

Differential Revision: https://reviews.llvm.org/D124059
2022-04-20 09:22:25 -04:00
Andrew Browne 204c12eef9 [DFSan] Print an error before calling null extern_weak functions, incase dfsan instrumentation optimized out a null check.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D124051
2022-04-19 17:01:41 -07:00
Kirill Stoimenov ab99a414ef [ASan] Removed checks if the tested functions were emitted.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D124030
2022-04-19 19:20:52 +00:00
Nico Weber f6b2ddbf38 [compiler-rt] Use ld64 flag -lto_library instead of DYLD_LIBRARY_PATH
Makes

 bin/llvm-lit \
  projects/compiler-rt/test/profile/Profile-arm64/instrprof-darwin-dead-strip.c

pass on my machine.

Without this change, ld64 complains that the bitcode was generated by LLVM 15
while the reader is 13.1 -- the version of Xcode on my machine. Looks like the
DYLD_LIBRARY_PATH technique isn't working.

-lto_library was added back in ld64-136, which was in Xcode 4.6, which was
released over 10 years ago. So relying on it should be safe by now.

Differential Revision: https://reviews.llvm.org/D124018
2022-04-19 13:54:57 -04:00
Kirill Stoimenov 64c929ec09 [ASan] Fixed a reporting bug in (load|store)N functions which would print unknown-crash instead of the proper error message when a the data access is unaligned.
Reviewed By: kda, eugenis

Differential Revision: https://reviews.llvm.org/D123643
2022-04-19 15:07:17 +00:00
Kirill Stoimenov 70f13bd752 Revert "[ASan] Fixed a reporting bug in (load|store)N functions which would print unknown-crash instead of the proper error message when a the data access is unaligned."
This reverts commit d81d317999.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D123966
2022-04-18 23:33:41 +00:00
Kirill Stoimenov d81d317999 [ASan] Fixed a reporting bug in (load|store)N functions which would print unknown-crash instead of the proper error message when a the data access is unaligned.
Reviewed By: kda, eugenis

Differential Revision: https://reviews.llvm.org/D123643
2022-04-18 22:46:37 +00:00
Blue Gaston a6efcf1c31 Format fix in recent change. Removed whitespace. [NFC] 2022-04-18 09:23:01 -07:00
Piotr Kubaj 315d792130 [PowerPC] Fix sanitizers build on FreeBSD
1. Add correct pc, sp and bp for FreeBSD.
2. Since there's no personality.h header on FreeBSD, move SANITIZER_PPC64V2
   case below FREEBSD case.
3. __ppc_get_timebase_freq() is glibc-specific. Add a shim for FreeBSD that
   does the same.
2022-04-18 07:16:13 -05:00
Vitaly Buka eb4d22917e [msan] Set poison_in_dtor=1 by default
It's still disabled by default at compile time.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D123875
2022-04-15 14:40:23 -07:00
Brad Smith 8cf83e9659 [VE][compiler-rt] Correct location of VE support in clear_cache function, NFC
Looks like when the VE support was added it was added a few lines below where it should have been.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D123439
2022-04-14 15:50:26 -04:00
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