13525 Commits

Author SHA1 Message Date
Vitaly Buka
c7e4065aad
[NFC][sanitizer] Add consts to SkipInternalFrames (#77162) 2024-01-05 18:42:06 -08:00
Vitaly Buka
23aabdd66f
[NFC][sanitizer] Move SymbolizedStackHolder into sanitizer_common (#77152)
And replace most `ClearAll()` uses.
2024-01-05 18:40:40 -08:00
Vitaly Buka
09e0d71ad3
[ubsan] Drop terminal "in " from reports without functions (#77163) 2024-01-05 17:05:25 -08:00
Vitaly Buka
2652243f19
[NFC][tsan] Move SkipInternalFrames into sanitizer_common (#77146) 2024-01-05 16:53:48 -08:00
Vitaly Buka
f74ce00075
[tsan] Fallback to top frame (#77145)
Probably it's not important, as it should not happen often,
but if all frames are internal we should pick top, not
the bottom frame.
2024-01-05 14:48:37 -08:00
Vitaly Buka
9cf4f10609
[NFC][tsan] ptr != 0 to implicit check (#77144) 2024-01-05 14:32:18 -08:00
Vitaly Buka
5b54dd4f5e
[tsan] Generalize FrameIsInternal (#77143)
Prepare to move this into sanitizer_common.
2024-01-05 14:30:52 -08:00
Ben Langmuir
40b4ac278e
[ORC] Refactor executor symbol lookup to use ExecutorSymbolDef (NFC) (#76989)
This migrates the dylib manager lookup and related APIs to replace
ExecutorAddress with ExecutorSymbolDef so that in the future we can
model JITSymbolFlags for these symbols. The current change should be NFC
as we are only setting the Exported symbol flag.
2024-01-04 13:13:22 -08:00
David CARLIER
e32b1d15f7
[compiler-rt] enable pwritev interception on freebsd/netbsd. (#76759) 2024-01-02 23:37:05 +00:00
David Carlier
9943cd7c7d [compiler-rt] unbreak android build 2024-01-02 22:11:17 +00:00
David CARLIER
619a006924
[compiler-rt] eventfd api interception on freebsd. (#76564) 2024-01-02 20:01:54 +00:00
Dimitry Andric
0b3a89f121
[builtins] Avoid using long double in FreeBSD standalone environment (#76175)
After 05a4212cc76d a number of long double related declarations are
enabled in `int_types.h`, whenever the CPU architecture and platform
support it. However, this does not work with FreeBSD's standalone
environment, which disallows any use of floating point.

In add98b246290 this was made conditional with `CRT_HAS_FLOATING_POINT`,
so extend the block guarded by that define to include all floating point
related declarations.
2024-01-02 19:23:56 +01:00
Aiden Grossman
3ddf368524 [X86] Fix warning in cpu detection due to unsigned comparison
a15532d7647a8a4b7fd2889bd97f6f72f273c4bf landed a patch that added
support for detecting more AMD znver2 CPUs and cleaned up some of the
surrounding code, including the znver3 detection. Since one model group
is 00h-0fh, I adjusted the check to include checking if the value is
greater than zero. Since the value is unsigned, this is always true and
gcc warns on it. This patch removes the comparison with zero to get rid
of the compiler warning.
2023-12-29 17:58:53 -08:00
Rainer Orth
1da9d8aea0
[asan] Ignore vDSO on FreeBSD (#76223)
Most asan tests `FAIL` on FreeBSD 14.0/amd64 with
```
==17651==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
```
With `ASAN_OPTIONS=verbosity=2` one sees:
```
==4880==info->dlpi_name = [vdso]	info->dlpi_addr = 0xffffe780
==4880==info->dlpi_name = lib/clang/18/lib/freebsd/libclang_rt.asan-i386.so	info->dlpi_addr = 0x2808a000
```
Ignoring the vDSO as on Linux fixes this.

Tested on `amd64-pc-freebsd14.0`.
2023-12-29 21:39:27 +01:00
Dimitry Andric
953ae94149
[builtins] Fix CPU feature detection for FreeBSD on AArch64 (#76532)
[builtins] Fix CPU feature detection for FreeBSD on AArch64

This is a follow-up to #75635 which broke the build for FreeBSD on
AArch64:

```
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc:3:16: error: call to undeclared function 'elf_aux_info'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    3 |   int result = elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
      |                ^
```

Using `elf_aux_info()` requires including `<sys/auxv.h>` first. To
prevent redeclaration issues with `hwcap.inc` attempting to define
`HWCAP_xxx` macros before `<sys/auxv.h>` does so, include `<sys/auxv.h>`
before any of the `.inc` files on FreeBSD.
2023-12-29 11:13:40 +01:00
Brad Smith
450be89136
[compiler-rt] Remove a few workarounds for FreeBSD 9.x (#76263)
Support for FreeBSD 11.x was dropped so garbage collect a few FreeBSD
9.x workarounds and make 12.x the oldest supported releases.
2023-12-29 05:10:13 -05:00
David CARLIER
44089c21c1
[compiler-rt] intercept sched_getaffinity on freebsd. (#76509)
freebsd releases up to 13.1 are eol and sched_getaffinity wrapper is
available since 13.1.
2023-12-28 11:55:16 -08:00
abner chenc
9d3fbf97be
[tsan] Add support for linux/loongarch64 in lib/tsan/go/buildgo.sh (#72819)
Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
2023-12-28 18:54:35 +08:00
Vitaly Buka
7962bd5719
[hwasan] Make stack variables output consistent with globals (#76197) 2023-12-26 13:45:24 -08:00
Vitaly Buka
01bf29b9d0
[sanitizers] Optimize locking StackDepotBase for fork (#76280)
Locking StackDepotBase fully is very expensive, as 2^20 buckets needs to
be locked. Not locking, but only unlocking buckets, needed to be
unlocked to avoid deadlocks, increases a chance of data race, when the
value with same hash can be inserted into table twice, but one is lost.
However this is just a small additional memory usage by forked process.
2023-12-26 11:21:06 -08:00
Dan McGregor
966d564e43
asan_static x86-64: Support 64-bit ASAN_SHADOW_OFFSET_CONST redux (#76185)
Similar to b9935bb02a50, but also apply a similar change to
ACCESS_CHECK_ADD.

If ASAN_SHADOW_OFFSET_CONST cannot be encoded as a displacement, switch
to `movabsq` and the register offset variant of cmp.
2023-12-24 20:37:35 -08:00
Petr Hosek
09e6f12cba
[builtins] Fix CPU feature detection for Zircon (#76276)
This is a follow up to #75635 which broke the build on Fuchsia. We don't
support ifunc on Fuchsia so we shouldn't define __init_cpu_features. For
__init_cpu_features_resolver we have to use _zx_system_get_features as a
Zircon native solution.
2023-12-24 15:10:40 -08:00
Vitaly Buka
0e07bf91f7
[NFC][sanitizer] Rename to Lock{Before,After}Fork StackDepotBase locking (#76303)
Followup to #76279
2023-12-23 16:23:55 -08:00
Vitaly Buka
f78a742ab8
[NFC][sanitizer] Rename Lock{Before,After}Fork suffixes locking StackDepotBase (#76279)
This is preparation for performance optimization.

We need to highlight that this is very specific lock, and should not be
used for other purposes.
Add `fork_child` parameter to distinguish processes after fork.
2023-12-22 23:38:01 -08:00
Rainer Orth
5cb7534a7d
[tsan] Only intercept pthread_mutex_clocklock on Linux (#76220)
`tsan_interceptors_posix.cpp` doesn't compile on FreeBSD 14.0/amd64:
```
In file included from /vol/llvm/src/llvm-project/local-freebsd/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:25:
/vol/llvm/src/llvm-project/local-freebsd/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp: In function ‘void __tsan::InitializeInterceptors()’:
/vol/llvm/src/llvm-project/local-freebsd/compiler-rt/lib/tsan/rtl/../../interception/interception.h:243:25: error: ‘real_pthread_mutex_clocklock’ is not a member of ‘__interception’; did you mean ‘real_pthread_mutex_unlock’?
```
Fixed by wrapping the `TSAN_INTERCEPT` invocation with `SANITIZER_LINUX`
as is already done for the interceptor definition.

Tested on `amd64-pc-freebsd14.0`.
2023-12-22 15:58:03 +01:00
Aiden Grossman
a15532d764
[X86] Add CPU detection for more znver2 CPUs (#74955)
This patch adds proper detection support for more znver2 CPUs.

Specifically, this adds in support for CPUs codenamed Renoir, Lucienne,
and Mendocino.

This was originally proposedfor Renoir in
https://reviews.llvm.org/D96220 and
got approved, but slipped through the cracks. However, there is still a
demand for this feature.

In addition to adding support for more znver2 CPUs, this patch also includes
some additional refactoring and comments related to cpu model
information for zen CPUs.

Fixes https://github.com/llvm/llvm-project/issues/74934.
2023-12-21 23:39:28 -08:00
Vitaly Buka
7db28dd3f8
[hwasan] Classify stack overflow, and use after scope (#76133)
We can't distinguish UAR and UAS, but by definition
UAR is already UAS.
2023-12-21 17:51:14 -08:00
Vitaly Buka
7c3b67d203
[hwasan] Respect strip_path_prefix printing locals (#76132) 2023-12-21 16:03:06 -08:00
Vitaly Buka
528150b90b
[hwasan] Separate sections in report (#76130)
It makes them easier to read.
2023-12-21 12:37:17 -08:00
Vitaly Buka
5e92fa69ea [NFC][sanitizer] Fix typo in comment 2023-12-20 18:40:26 -08:00
kda
9e012c76fb
[sanitizer] Add graceful handling of exceeding StackStore limit. (#76115) 2023-12-20 17:58:03 -08:00
Vitaly Buka
3dca63a32f
[symbolizer] Don't threat symbolizer API as optional (#76103)
There is an assumption that we dont need to to mix sanitizer with
symbolizer from different LLVM revison. If so we can detect it by
`__sanitizer_symbolize_code` and assume that the rest is present.
2023-12-20 15:38:43 -08:00
Zequan Wu
688fa35df0
[Profile] Dump binary id to raw profiles on Windows. (#75618)
#74652 adds `__buildid` symbol which allows us to dump it at runtime.
2023-12-20 10:41:36 -05:00
Jon Roelofs
394e481a38
fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI
https://github.com/llvm/llvm-project/pull/75635#issuecomment-1863662913
2023-12-19 17:48:24 -07:00
Ben Langmuir
dc58f781b6
[ORC-RT] Fix ptrauth signing for dlsym return value (#75972)
dlsym signs text symbols as functions rather than data in dyld, so match
that for orc runtime dlsym. This fixes run_program on arm64e.
2023-12-19 14:56:42 -08:00
Jon Roelofs
52e7b6f5c5
fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI
https://github.com/llvm/llvm-project/pull/75635#issuecomment-1863433937

```
/b/s/w/ir/x/w/llvm_build/./bin/clang --target=aarch64-unknown-linux-gnu --sysroot=/b/s/w/ir/x/w/cipd/linux -DHAS_ASM_LSE -DVISIBILITY_HIDDEN  --target=aarch64-unknown-linux-gnu -O2 -g -DNDEBUG -fno-lto -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -DCOMPILER_RT_HAS_FLOAT16 -MD -MT CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o -MF CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o.d -o CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model/aarch64.c.o -c /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c
In file included from /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c:43:
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc:5:41: error: use of undeclared identifier 'HWCAP_ATOMICS'
    5 |   __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0;
      |                                         ^
1 error generated.
```
2023-12-19 14:20:27 -07:00
Shoaib Meenai
85d5ed81b1 [compiler-rt] Fix obvious syntax error
This is breaking Android compiler-rt builds.
2023-12-19 12:59:05 -08:00
Jon Roelofs
c88e74c26d
fixup! fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI 2023-12-19 11:46:40 -07:00
Jon Roelofs
a5a17e8fad
fixup! [builtins] Refactor cpu_model support to reduce #if nesting. NFCI 2023-12-19 11:39:13 -07:00
Jon Roelofs
256b214b6b
[builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636)
This is a re-land of https://github.com/llvm/llvm-project/pull/73685
2023-12-19 11:20:03 -07:00
Jon Roelofs
9237cfa65b
[builtins] Refactor cpu_model support to reduce #if nesting. NFCI
Reviewers: petrhosek, DavidSpickett

Pull Request: https://github.com/llvm/llvm-project/pull/75635
2023-12-19 11:19:51 -07:00
Jon Roelofs
b72e160914
Revert "[builtins] Refactor cpu_model support to reduce #if nesting. NFCI"
This reverts commit 025d048b1cac1183c85acc9d58941b9909f6ec11.

It broke one of the sanitizer bots:

https://lab.llvm.org/buildbot/#/builders/240/builds/20666
2023-12-19 11:17:24 -07:00
Jon Roelofs
b8b40e2fb9
Revert "[builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636)"
This reverts commit 17aa5201710325ac4b8ccc95bb7954fea8e14849.
2023-12-19 11:17:04 -07:00
Jon Roelofs
17aa520171
[builtins][arm64] Implement __init_cpu_features_resolver on Apple platforms (#75636)
This is a re-land of https://github.com/llvm/llvm-project/pull/73685
2023-12-19 11:11:42 -07:00
Jon Roelofs
025d048b1c
[builtins] Refactor cpu_model support to reduce #if nesting. NFCI
Reviewers: petrhosek, DavidSpickett

Pull Request: https://github.com/llvm/llvm-project/pull/75635
2023-12-19 11:09:50 -07:00
David Spickett
849c951191 [compiler-rt][asan] Remove reference to asan_lock.h which was removed.
By commit 12ed2c90a105f29b9b2f6056d936f47534d31624.

Fixes #75736
2023-12-19 09:26:14 +00:00
Florian Mayer
4f9ad0f856 [scudo] [NFC] remove unused method 2023-12-18 18:54:32 -08:00
Thomas Schenker
3effc191e3
[sanitizers] improve debug output for failed suppression parse (#72066)
If a sanitizer suppression file can not be parsed, add the supported
suppression types to the error message.

See https://github.com/llvm/llvm-project/issues/72060.

---------

Co-authored-by: Vitaly Buka <vitalybuka@gmail.com>
2023-12-18 17:10:55 -08:00
Fangrui Song
e777317227 [tsan] Make pthread_mutex_clocklock Linux only
Many systems (glibc<2.30, Bionic before 2019, musl, macOS, etc) do not have the function.
2023-12-18 15:01:25 -08:00
Fangrui Song
b9935bb02a
asan_static x86-64: Support 64-bit ASAN_SHADOW_OFFSET_CONST (#75748)
Fix #57086: when ASAN_SHADOW_OFFSET_CONST >= 0x80000000 (FreeBSD,
NetBSD, etc), `movsbl ASAN_SHADOW_OFFSET_CONST(%r10),%r10d` has an
invalid displacement (not representable as a signed 32-bit integer),
which will be diagnosed by GNU assembler.

```
% cat a.s
movsbl 0x80000000(%r10),%r10d
% as a.s
a.s: Assembler messages:
a.s:1: Error: 0x80000000 out of range of signed 32bit displacement
% clang -c a.s
```

The integrated assembler after #75747 will diagnose the invalid
displacement as well.
```
% clang -c a.s
a.s:1:19: error: displacement 2147483648 is not within [-2147483648, 2147483647]
movsbl 0x80000000(%r10),%r10d
                  ^
```

If ASAN_SHADOW_OFFSET_CONST cannot be encoded as a displacement, switch
to `movabsq+movsbl`.
2023-12-18 13:48:46 -08:00