19174 Commits

Author SHA1 Message Date
Alexander Richardson
bbac349341
[compiler-rt] Install libc++ and libc++abi in build_symbolizer.sh (#123104)
This ensures that the directory layout of the libc++/libc++abi matches
exactly what we would get on a real installation. Currently the build
directory happens to match the install directory layout, but this will
no longer be true in the future.
2025-01-15 15:13:06 -08:00
David CARLIER
d15d410a35
[compiler-rt][rtsan] Fix fseek test build (unused variable warning). (#123116) 2025-01-15 20:33:18 +00:00
Wael Yehia
6ffc445103 [PGO][AIX] Disable multi-process continuous mode test in 32-bit
In PGO continuous mode, we mmap the profile file into shared memory, which
allows multiple processes to be updating the same memory.

The -fprofile-update=atomic option forces the counter increments to be atomic,
but the counter size is always 64-bit (in -m32 and -m64), so in 32-bit mode the
atomic operations are function calls to libatomic.a and these function calls use
locks.

The lock based libatomic.a functions are per-process, so two processes will race
on the same shared memory because each will acquire their own lock.
2025-01-15 19:21:14 +00:00
David CARLIER
c4443a1be4
[compiler-rt][rtsan] fseek api interception. (#122163) 2025-01-15 18:31:27 +00:00
David CARLIER
da4551aad0
[compiler-rt][sanitizer_common] Fix for solaris and *BSD platforms proposal. (#122956)
To fix llvm#122795 build failures for these.
2025-01-15 13:31:14 +00:00
Lang Hames
2a5281d0e0 [ORC-RT] Fix missing '\' line continuations in objc-imageinfo.S test.
These missing continuations were causing commands in this testcase to fail.
2025-01-15 13:21:28 +11:00
Paul Kirth
44d9beef7d
[rtsan][test] Prevent test check from being optimized out in LTO builds (#122524)
In LTO builds, some test checks can be optimized away, since the
compiler can
see through the memory accesses after inlining across TUs. This causes
the existing death tests to fail, since the functions are completely
optimized out and things like copying a lambda will no longer occur and
trigger the sanitizer.

To prevent that, we can use an empty inline assembly block to tell the
compiler that memory is modified, and prevent it from doing that.
2025-01-14 11:55:19 -08:00
David CARLIER
8d9dcd111e
[compiler-rt] fseek interception update. (#122795)
fseek api is POSIX.

to also address #122163
2025-01-14 16:56:32 +00:00
Zack Johnson
c33486954b
[ASan] Change strdup interceptor to allow null input on Windows (#122803)
[These are the MS
Docs](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strdup-wcsdup-mbsdup?view=msvc-170)
regarding `strdup`, but they don't explicitly mention this. The SAL
annotations on `strdup` do, though, with the input parameter being
marked `_In_opt_z_`.
2025-01-14 11:53:01 -05:00
ChiaHungDuan
a8d2aeec87
[scudo] Fix the format of getStats() (#121608)
This is a quick fix for b71c44b9be17dc6295eb733d685b38e797f3c846

"last released" was removed by accident in primary64.h and the update of
"NumReleasesAttempted" was missing.
2025-01-13 14:17:48 -08:00
gbMattN
09a8b7cbc2
[TySan] Fix struct access with different bases (#120412)
Original pull request
[here](https://github.com/llvm/llvm-project/pull/108385)
Fixes issue https://github.com/llvm/llvm-project/issues/105960

If a member in a struct is also a struct, accessing a member partway
through this inner struct currently causes a false positive. This is
because when checking aliasing, the access offset is seen as greater
than the starting offset of the inner struct, so the loop continues one
iteration, and believes we are accessing the member after the inner
struct.

The next member's offset is greater than the offset we are looking for,
so when we subtract the next member's offset from what we are looking
for, the offset underflows.

To fix this, we check if the member we think we are accessing has a
greater offset than the offset we are looking for. If so, we take a step
back. We cannot do this in the loop, since the loop does not check the
final member. This means the penultimate member would still cause false
positives.
2025-01-13 15:28:37 +00:00
bernhardu
99612a3a18
[win/asan] GetInstructionSize: Support some more 2 byte instructions. (#120235)
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

```
Related: https://github.com/llvm/llvm-project/issues/96270

Co-authored-by: Roman Pišl <rpisl@seznam.cz>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <eric.pouech@gmail.com>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
```

CC: @zmodem
2025-01-13 15:21:03 +01:00
bernhardu
9a9e41ca89
[win/asan] GetInstructionSize: Add test for 8D A4 24 .... (#119794)
This adds a test line and updates a comment.
2025-01-11 18:54:35 +01:00
Lang Hames
99d2ff54ab [ORC-RT] Use llvm-jitlink -num-threads=0 for objc-imageinfo.S tests.
These testcases depend on debugging output, which isn't stable under concurrent
linking.
2025-01-10 17:53:56 +11:00
Florian Hahn
e8c8543a1c
[TySan] Intercept malloc_size on Apple platforms. (#122133)
After https://github.com/llvm/llvm-project/pull/120563 malloc_size also
needs intercepting on Apple platforms, otherwise all type-sanitized
binaries crash on startup with an objc error:
realized class 0x12345 has corrupt data pointer: malloc_size(0x567) = 0

PR: https://github.com/llvm/llvm-project/pull/122133
2025-01-09 20:55:36 +00:00
Nikita Popov
4847395c54
[Clang] Adjust pointer-overflow sanitizer for N3322 (#120719)
N3322 makes NULL + 0 well-defined in C, matching the C++ semantics.
Adjust the pointer-overflow sanitizer to no longer report NULL + 0 as a
pointer overflow in any language mode. NULL + nonzero will of course
continue to be reported.

As N3322 is part of
https://www.open-std.org/jtc1/sc22/wg14/www/previous.html, and we never
performed any optimizations based on NULL + 0 being undefined in the
first place, I'm applying this change to all C versions.
2025-01-09 09:23:23 +01:00
Tristan Ross
783dc59b3b
[compiler-rt] Check codesign in path before using (#99837)
Fixes an issue discovered with Nix where codesign is executed but Nix
cannot use codesign without faults. Use `find_program` in CMake to
ensure it is in `$PATH`.

Can be tested on macOS and change your path in such a way that
`codesign` isn't in it.

Related: https://github.com/NixOS/nixpkgs/pull/329058
2025-01-08 18:57:32 -08:00
David CARLIER
7004d6815b
[compiler-rt][rtsan] adding setlinebuf/setbuffer interception. (#122018)
catering to platform differences as those calls are not posix.
2025-01-08 13:22:09 +00:00
gbMattN
20d7fa1cc3
[TySan] Added a 'print_stacktrace' flag for more detailed errors (#121756)
Raised in issue #121697
2025-01-08 10:20:20 +00:00
thetruestblue
75325c658e
[Darwin][CompilerRT] Set compiler ID to 'Clang' for Compiler RT Tests for Apple Clang (#121858)
This patch restores previous behavior. Even when the Compiler ID is set
to AppleClang, we expect Compiler RT Tests to use Clang as the compiler
ID. This impacts various make and lit commands.

Caused by: https://github.com/llvm/llvm-project/pull/117812/files

rdar://141548700
2025-01-07 13:19:55 -08:00
Caslyn Tonelli
478648e2c0
[gwp_asan] Soft-transition ZXTEST_USE_STREAMABLE_MACROS removal (#121887)
Soft-transition the removal of setting ZXTEST_USE_STREAMABLE_MACROS, by
only setting the macro if not already defined. A future PR will remove
setting the macro entirely in harness.h.
2025-01-07 10:03:31 -08:00
David CARLIER
937445365a
[compiler-rt][rtsan] Reland posix part of #121616 setbuf, setvbuf. (#121658) 2025-01-07 16:21:45 +00:00
earnol
b7a6e9da12
[ubsan] Use internal_memcpy to copy ubsan bits size (#121586)
While fetching amounts of bits used to correctly display ubsan value
reinterpret_cast was used, however as noted by Jakub Jelínek in
https://github.com/llvm/llvm-project/pull/96240 discussion it might
cause issues due to potentially unaligned memory access. The patch
addresses this problem.

Co-authored-by: Vladislav Aranov <vladislav.aranov@ericsson.com>
2025-01-07 10:59:53 -05:00
Amara Emerson
cb5d866fee [AArch64][SME] Add Darwin specific SME ABI routines.
Our platform has some constraints that allow us to make assumptions that
aren't generally applicable to other platforms. We keep an entirely separate
.s file for the routines.
2025-01-06 09:51:41 -08:00
Amara Emerson
3c8344f7ba
[AArch64][SME] Fix broken compiler check for SME2 support in compiler-rt (#121625)
This compile time test uses inline asm with `.arch` directives to set
the target feature. It is however broken and always fails, since each
`asm()` construct in LLVM sets up a new AsmParser, and therefore the
`.arch` directive has no effect on later `asm()` contents. To fix this
we need to use a single inline `asm()` call with the entire code chunk
to emit contained inside.
2025-01-06 01:37:56 -08:00
David CARLIER
d1d400372a
[compiler-rt][rtsan] fix unit tests by sanitizer-aarch64-linux report. (#121666) 2025-01-04 21:46:08 +00:00
David CARLIER
59354a865f
[compiler-rt][rtsan] intercept fflush. (#121643) 2025-01-04 20:15:05 +00:00
David CARLIER
c7fa3cf620
Revert "[compiler-rt][rtsan] intercept setbuf, setvbuf, setlinebuf an… (#121639)
…d setbuffer (#121616)"

This reverts commit 95db1116c5718004e0bd7c3b79d39987fdbbff32.
2025-01-04 11:35:31 +00:00
David CARLIER
95db1116c5
[compiler-rt][rtsan] intercept setbuf, setvbuf, setlinebuf and setbuffer (#121616) 2025-01-04 10:52:41 +00:00
David CARLIER
85849917f7
[compiler-rt][rtsan] Reland "fopencookie support." (#120864) (#121547) 2025-01-03 11:16:34 +00:00
Fangrui Song
82fecab85a [gcov] Bump default version to 11.1
The gcov version is set to 11.1 (compatible with gcov 9) even if
`-Xclang -coverage-version=` specified version is less than 11.1.

Therefore, we can drop producer support for version < 11.1.
2025-01-02 23:01:28 -08:00
gulfemsavrun
e8cf41311f
Revert "[compiler-rt][rtsan] fopencookie support." (#121537)
Reverts llvm/llvm-project#120864 because it broke building compiler-rt
on Mac.

https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-mac-arm64/b8726812736235038609/overview
2025-01-02 18:34:02 -08:00
David CARLIER
4b57783003
[compiler-rt][rtsan] fopencookie support. (#120864) 2025-01-02 22:30:39 +00:00
B I Mohammed Abbas
8e8d0c1499
Fix integer suffix in truncxfhf2_test (#121388)
Fixes error introduced by #120372.
2024-12-31 09:27:15 -08:00
B I Mohammed Abbas
28ae2ff2a4
Add truncxfhf2 with tests to compiler-rt (#120372)
Fixes #105181
2024-12-30 14:14:43 -08:00
Muhammad Omair Javaid
5373ed0e79 [fuzzer][test] Disable noasan-strcmp test for AArch64
This patch disables the `noasan-strcmp.test` for AArch64 Linux as it
consistently fails on the buildbot machine while passing on other
AArch64 Linux systems.

We have seen similar issues on noasan-strncmp.test in past which had
random failures on certain machines/environments.

Following buildbot is failing in both check stage1 and stage2:
https://lab.llvm.org/buildbot/#/builders/121/builds/711
2024-12-31 00:52:03 +05:00
Petr Hosek
9a88edeb49
[TYSan][CMake] CMake build fixes (#121224)
TYSan CMake build follows patterns used by other sanitizers, but there's
also a number of issues, like referring to undefined variables, which
breaks the build in some cases (such as cross-compiling). This change
addresses the issues.
2024-12-30 11:51:44 -08:00
Stefan Schulze Frielinghaus
65a2eb0b15
[sanitizer] Fix type in some Min() calls (#119248)
This is a follow-up to 6dec33834d1fd89f16e271dde9607c1de9554144 and
#116957 and #119114.
2024-12-30 10:24:55 -08:00
NAKAMURA Takumi
de294c968b
[profile] Enable testing Continuous mode on Linux (#121238)
Based on #115987, with the introduction of `REQUIRES: continuous-mode`.
Also Linux assumes `runtime_reloc`.

FIXME: image-with-no-counters.c is still excluded.
2024-12-29 12:02:13 +09:00
Vitaly Buka
74496b03f7 [asan][hwasan] Link RTUbsan_cxx into shared runtime
There is no shared version RTUbsan_cxx.
Fix android after #121006.
2024-12-24 23:37:59 -08:00
Vitaly Buka
32962f2b77 [ubsan] Try to fix Windows 2024-12-24 23:08:20 -08:00
Vitaly Buka
a1328c077c [ubsan] Fix android build
Broken by #121006.
2024-12-24 20:26:31 -08:00
Vitaly Buka
1de228fa9b
[ubsan] Remove UBSAN_CAN_USE_CXXABI (#121082)
It's should be enough to provide weak implementation.

Fixes solaris and android linking after #121006.
2024-12-24 20:21:40 -08:00
Vitaly Buka
cd66c9b6a0
[Ubsan][Driver] Remove UBSAN C++ runtime from other sanitizers (#121006)
Linking this runtime requires C++ ABI, which breaks -nostdlib++ builds.
However, UBSAN C++ runtime is only needed for CFI and VPTR checks.

Unblocks #120370.
2024-12-24 13:57:03 -08:00
Mingjie Xu
34d55df73b
[tysan] Replace HandleEarlyAlloc with DlsymAlloc (#120563) 2024-12-23 09:04:00 +08:00
Thurston Dang
d8e10d13d7 [rtsan] Fix-forward TEST(TestRtsanInterceptors, PpollDiesWhenRealtime)
Buildbot breakage:
home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp:1090:19: error: missing field 'tv_nsec' initializer [-Werror,-Wmissing-field-initializers]
 1090 |   timespec ts = {0};

introduced by https://github.com/llvm/llvm-project/pull/120366/files
2024-12-20 20:53:24 +00:00
David CARLIER
f39ecb7b28
[compiler][rtsan] stream based on memory buffer interception. (#120672) 2024-12-20 17:29:30 +00:00
David CARLIER
adfef2a753
[compiler-rt][rtsan] ppoll interception. (#120366) 2024-12-20 17:28:53 +00:00
Sander de Smalen
811f2a652b
[Compiler-rt] Add AArch64 routines for __arm_agnostic("sme_za_state") (#120059)
The specification of these routines can be found here:

https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#sme-support-routines
2024-12-20 15:49:33 +00:00
Hans Wennborg
69ebac7ad6
[win/asan] Don't intercept memset etc. in ntdll (#120397)
When ntdll was added to the list of of "interesting DLLs" list (in
d58230b9dcb3b312a2da8f874daa0cc8dc27da9b), the intention was not to
intercept the "mini CRT" functions it exports. OverrideFunction would
only intercept the *first* function it found when searching the list of
DLLs, and ntdll was put last in that list.

However, after 42cdfbcf3e92466754c175cb0e1e237e9f66749e,
OverrideFunction intercepts *all* matching functions in those DLLs. As
a side-effect, the runtime would now intercept functions like memset
etc. also in ntdll.

This causes a problem when ntdll-internal functions like
RtlDispatchException call the intercepted memset, which tries to
inspect uncommitted shadow memory, raising an exception, and getting
stuck in that loop until the stack overflows.

Since we never intended to intercept ntdll's memset etc., the simplest
fix seems to be to actively ignore ntdll when intercepting those
functions.

Fixes #114793
2024-12-20 11:03:17 +01:00