16582 Commits

Author SHA1 Message Date
Frank Dischner
ef45c12f9e [compiler-rt][builtins] Support builtins for armv8m.base
This allows building the compiler builtins library for the Armv8-M
Baseline architecture. It can be built in the same way as other
baremetal targets using the appropriate '--target' flag
(e.g. --target=armv8m.base-eabi).

NOTE: As with the other Cortex-M targets, only the builtins library is
supported. There is no support for sanitizers, etc.

The armv8m.base architecture is a superset of armv6m, so adding it to
the cmake files using thumb1_SOURCES is almost enough for it to compile.
Minor changes are needed to divsi3 and udivsi3, because armv8m.base does
have support for div instructions but not mov with an immediate operand.

Reviewed By: MaskRay, peter.smith

Differential Revision: https://reviews.llvm.org/D143297
2023-03-14 17:20:54 -07:00
Snehasish Kumar
a1bbf5ac3c [memprof] Record BuildIDs in the raw profile.
This patch adds support for recording BuildIds usng the sanitizer
ListOfModules API. We add another entry to the SegmentEntry struct and
change the memprof raw version.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D145190
2023-03-14 18:16:38 +00:00
Snehasish Kumar
debe80cb8d Revert "[memprof] Record BuildIDs in the raw profile."
This reverts commit 287177a47a396ca6cc0bef7696108cdaa0c68e5f.
2023-03-13 20:09:46 +00:00
Snehasish Kumar
287177a47a [memprof] Record BuildIDs in the raw profile.
This patch adds support for recording BuildIds usng the sanitizer
ListOfModules API. We add another entry to the SegmentEntry struct and
change the memprof raw version.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D145190
2023-03-13 19:28:38 +00:00
Chia-hung Duan
2aa99771b6 [scudo] Reduce the times of holding MapAllocatorCache::Mutex (NFC)
Also fix few lints

Reviewed By: cryptoad

Differential Revision: https://reviews.llvm.org/D145427
2023-03-13 17:09:47 +00:00
Dmitry Vyukov
bb53249884 asan: disable odd_stack_size test for powerpc
Fail on powerpc64 bots with:
AddressSanitizer: CHECK failed: asan_thread.cpp:315 "((AddrIsInStack((uptr)&local))) != (0)"
https://lab.llvm.org/buildbot/#/builders/18/builds/8162
Disable to unbreak bots.

Differential Revision: https://reviews.llvm.org/D145902
2023-03-13 08:45:26 +01:00
Vitaly Buka
a8cd84d328 [test][asan] Fix test on MacOS 12+
Reviewed By: rsundahl

Differential Revision: https://reviews.llvm.org/D145810
2023-03-12 19:58:49 -07:00
Dmitry Vyukov
4989779d7a asan: fix crash on odd stack size
The test currently crashes as:

AddressSanitizer: CHECK failed: asan_poisoning.cpp:38 "((AddrIsAlignedByGranularity(addr))) != (0)"

Main stack address/size don't have to be aligned on asan shadow granularity.
Align stack bottom.

Reviewed By: melver, vitalybuka

Differential Revision: https://reviews.llvm.org/D145799
2023-03-12 11:21:33 +01:00
Vitaly Buka
8a386b2250 [sanitizer] Fix text in error message 2023-03-11 13:40:42 -08:00
Vitaly Buka
3b4cb1e96c Revert "[hwasan] Provide aliases for c allocation functions for Fuchsia"
Breaks build bots, details in D145718.

This reverts commit 7de775159660538449652ca442c34fd91feecef6.
2023-03-10 21:18:25 -08:00
Vitaly Buka
0458405a6b [sanitizer] Add diagnostics for munmap failure
We are seeing CHECK is triggered there, but it's unclear why.
2023-03-10 21:18:25 -08:00
Leonard Chan
7de7751596 [hwasan] Provide aliases for c allocation functions for Fuchsia
"Interceptors" in this file aren't like the traditional interceptors
used by other sanitizers like asan. They're simply aliases to the
equivalent __sanitizer_* functions.

This also removes the WRAP(FN) declaration since it just creates
declarations for __interceptor_* functions but they seem to be unused.

Differential Revision: https://reviews.llvm.org/D145718
2023-03-11 00:31:04 +00:00
Vitaly Buka
eb8ebabfb0 [test][asan] Fix requirement formatting 2023-03-10 09:52:55 -08:00
Chia-hung Duan
f0e3401740 Reland D144768 "[scudo] Mitigate page releasing thrashing"
This reverts commit e64fabf51e882cc8e6157b7d139005162adb947c.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D145543
2023-03-10 16:52:36 +00:00
Jie Fu
0b327814d8 [libfuzzer] Fix build error due to out-of-line definition of 'Fuzzer' does not match any declaration in 'fuzzer::Fuzzer' (NFC)
/data/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:138:9: error: out-of-line definition of 'Fuzzer' does not match any declaration in 'fuzzer::Fuzzer'
Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
        ^~~~~~
/data/llvm-project/compiler-rt/lib/fuzzer/FuzzerInternal.h:35:10: note: type of 4th parameter of member declaration does not match definition ('fuzzer::FuzzingOptions &' vs 'const fuzzer::FuzzingOptions &')
         FuzzingOptions &Options);
         ^
1 error generated.
2023-03-10 14:52:28 +08:00
Wu, Yingcong
513d9b9f3d [libfuzzer] avoid unneccessary copy
Avoid some unneccessary copy

Reviewed By: fmayer

Differential Revision: https://reviews.llvm.org/D145758
2023-03-09 22:11:48 -08:00
Christopher Ferris
32be3405f5 [scudo] Add a fast get time version.
On Android, the _COARSE version of clock_gettime is about twice as fast.
Therefore, add a getMonotonicTimeFast function that is used in the
releaseToOSMaybe functions.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D145636
2023-03-09 14:12:53 -08:00
Leonard Chan
ca0fab0c36 [hwasan] Suppress leaks from dlsym with hwasan+lsan just like with
asan+lsan

We should follow suite with how asan handles this now that lsan also
works with hwasan.

Differential Revision: https://reviews.llvm.org/D145613
2023-03-09 21:42:04 +00:00
Chia-hung Duan
e4efa88538 [scudo] Slightly improve the handling of last block in a region
Instead of going through all those trailing blocks, just count the
number and increase the counter at once.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D145419
2023-03-09 16:18:00 +00:00
Karl-Johan Karlsson
3032189c0b [compiler-rt] Avoid signed shift overflow in __muloXi4 and __mulvXi3
When compiling compiler-rt with -fsanitize=undefined and running testcases you
end up with the following warning:

UBSan: int_mulo_impl.inc:21:36: left shift of 1 by 63 places cannot be represented in type 'di_int' (aka 'long long')

This can be avoided by simply doing the shift in a matching unsigned variant of
the type.

The same kind of pattern seems to exist in int_mulv_impl.inc

This was found in an out of tree target.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D145556
2023-03-09 08:37:47 +01:00
Chia-hung Duan
849da03202 [scudo] Shuffle the regions
Shuffle the regions' base address so that the layout of all regions is
less predictable.

Reviewed By: cferris, cryptoad

Differential Revision: https://reviews.llvm.org/D145407
2023-03-08 22:58:08 +00:00
Vitaly Buka
023f8b08db [hwasan] Increase allocator space for non-android Linux
This is max acceptable value with pow of 2 for DefaultSizeClassMap, the
same as for ASAN.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D145536
2023-03-08 14:12:39 -08:00
Chia-hung Duan
c514198e4d [scudo] Adjust page map buffer size
Given the memory group, we are unlikely to need a huge page map to
record entire region. This CL reduces the size of default page map
buffer from 2048 to 512 and increase the number of static buffers to 2.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D144754
2023-03-08 21:19:43 +00:00
Snehasish Kumar
79ebb6385b [memprof] Simplify initialized flags.
As discussed in D145428, the memprof_init_is_running check can be moved
to the end of the initialization routine to avoid intercepting
allocations during initialization. Also, the memprof_init_done flag can
be removed and replaced with memprof_inited. Finally, memprof_inited can
also be moved to the end of the method.

Tested on the existing check-memprof tests; memprof profile collection
succeeded on a large internal workload.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D145528
2023-03-08 18:02:23 +00:00
Xi Ruoyao
23fcca822a [compiler-rt][builtins] Define AT_HWCAP2 for AArch64
Without the definition, build fails on AArch64 with

> error: 'AT_HWCAP2' undeclared (first use in this function);
> did you mean 'AT_HWCAP'?

with old Glibc versions.

Differential Revision: https://reviews.llvm.org/D145494
2023-03-08 16:26:57 +01:00
Ilya Leoshkevich
cc6b86e175 [sanitizer] Intercept glibc's argp_parse()
Glibc provides the argp_parse() function for parsing command line
arguments [1].

Indicate that argc/argv are read from and arg_index is written to.
Strictly speaking, we also need to indicate that argp is read from,
but this would require describing its layout, and most people use a
static initializer there, so it's not worth the effort.

[1] https://www.gnu.org/software/libc/manual/html_node/Argp.html

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143330
2023-03-08 16:08:19 +01:00
Alex Richardson
489bda6a9c [builtins] Only build float16/bfloat16 code if actually supported
When building compiler-rt builtins for x86_64 they library will by default
also be built for i386. We unconditionally add the Float16 compile flags
since the check for Float16 support will be done using x86_64 compiler
flags, but i386 does not actually support it. Fix this by moving the
COMPILER_RT_HAS_FLOAT16 and COMPILER_RT_HAS_FLOAT16 checks to a
per-target-architecture check inside the loop (using
`check_c_source_compiles` and `cmake_{push,pop}_check_state`).

Many of the checks in the builtin-config-ix file should probably also be
changed to per-target-arch checks, but so far only the Float16 one has
caused issues. This is an alternative to D136044 which added a special case
for i386 FreeBSD.

Fixes: https://github.com/llvm/llvm-project/issues/57224
Differential Revision: https://reviews.llvm.org/D145237
2023-03-08 14:58:15 +00:00
Vitaly Buka
e09b3be411 [fuzzer] Make sure we never delete Fuzzer 2023-03-07 22:26:07 -08:00
Wu, Yingcong
67f5b05cdc Add test for Flags.data_flow_trace
`CollectDataFlow()` uses `Flags.collect_data_flow` and
`Flags.data_flow_trace` at the same time. But in the null check before
the invocation, only `Flags.collect_data_flow` is checked, and there is
no other method to make sure `Flags.data_flow_trace` is not null, so
adding a null check for `Flags.data_flow_trace`.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D145040
2023-03-07 22:18:29 -08:00
Wu, Yingcong
91985c2ee3 Use the right printf format specifiers
Some printf format strings in libfuzzer are using the wrong specifizers, fix in this commit.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D145033
2023-03-07 21:59:09 -08:00
Bojun Seo
cbb9369b9e [lsan] Initialize uptr value with number not boolean
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D145354
2023-03-07 21:47:39 -08:00
Dave MacLachlan
71ab6eab72 [test] Remove fprintf argument after D144830
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D145461
2023-03-07 21:40:47 -08:00
Christopher Ferris
96a38b945e [scudo] Do not instantiate Android svelte allocator.
The Android svelte allocator is not used, and will likely require
some configuration and experimentation to find a balanced config.
Leave the svelte config and size map so they can be used as the
basis for the future Android svelte config.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D145525
2023-03-08 05:17:44 +00:00
Chia-hung Duan
657d297a92 [scudo] Simplify markFreeBlocks
With memory group, we always mark the free blocks from the same region.
Therefore, we don't need to calculate the offset from base and determine
the region index. Also improve the way we deal with the last block in
the region so that the loop body is simpler.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D143303
2023-03-07 21:55:04 +00:00
Leonard Chan
6b3b262585 [hwasan] Add non-exception variant of operator delete[] for hwasan
Differential Revision: https://reviews.llvm.org/D145459
2023-03-07 03:46:10 +00:00
Vitaly Buka
2f302ef6f8 [sanitizer] Disabled test for DLLs
Similar to compiler-rt/test/asan/TestCases/default_options.cpp
2023-03-06 19:32:57 -08:00
Dave MacLachlan
28dc3aa7bc [asan darwin] Allow clients to implement __sanitizer_report_error_summary
`__sanitizer_report_error_summary` is declared `llvm/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h` as being able to be overridden by the client. On darwin the sanitizer runtime uses this symbol to find references to the sanitizer libraries, so if you override it you end up with the error `=ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:` at launch time.

Replace uses of `__sanitizer_report_error_summary` for finding the sanitizer libraries with using the address of a local function.

Reviewed By: yln, vitalybuka

Differential Revision: https://reviews.llvm.org/D144830
2023-03-06 16:37:45 -08:00
Snehasish Kumar
e1b569b96a Revert "[memprof] Refactor tests to generate binaries and profiles on the fly."
This reverts commit 599b7690fa917ea4e9cd67275e34d0b5a0f51aa9. Since
adding a cross project dependency is a concern.
2023-03-06 23:48:52 +00:00
Chia-hung Duan
e64fabf51e Revert "[scudo] Mitigate page releasing thrashing"
This reverts commit 436ea5485d02c529e26a7a1007b82d581be016c4.
2023-03-06 23:27:19 +00:00
Snehasish Kumar
599b7690fa [memprof] Refactor tests to generate binaries and profiles on the fly.
This change replaces the binary profiles and executables used for
testing the memprof profile reader with tests where the profiles are
generated on the fly. This reduces toil when the profile version
changes. The tests are moved from tools/llvm-profdata to
compiler-rt/test/memprof due to the following reasons:
1. Adding dependency on memprof lit.cfg.py for llvm-profdata is
   preferable to adding a dependency on compiler-rt for llvm/test.
2. All the tests can now be run with `ninja check-memprof`.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D145023
2023-03-06 21:24:40 +00:00
Chia-hung Duan
a6e3bb9bfb [scudo] Make the boundary of memory group aligned with region begin
This alignment guarantee enables simpler group range check while page
releasing and a potential optimization which is, now all the pointers
from the same group are also inth same region, that means the complexity
in markFreeBlocks() can be reduced as well.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D142931
2023-03-06 19:26:40 +00:00
Chia-hung Duan
0bd4499b96 [scudo] Temporarily disable GetRssFromBuffer test
This is a flaky test and may not test the thing it expected to verify.
E.g., it doesn't dirty the pages so the memory usage may not be reflected
on the RSS.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D145126
2023-03-06 16:38:18 +00:00
Chia-hung Duan
436ea5485d [scudo] Mitigate page releasing thrashing
We have the heuristic to determine the threshold of doing page
releasing for smaller size classes. However, in a case that the
memory usage is bouncing between that threshold may result in
frequent try of page releasing but not returning much memory.

This CL add another heuristic to mitigate this problem by increasing
the minimum pages that potentially can be released. Note that this
heuristic is only applied on SizeClassAllocator64. SizeClassAllocator32
has a smaller group size so the overhead is smaller than 64-bit
platform.

Differential Revision: https://reviews.llvm.org/D144768
2023-03-06 16:38:18 +00:00
Chia-hung Duan
5b9d6097e7 Reland D144920 "[scudo] Only prepare PageMap entry for partial region
This reverts commit daaef4c49954cb04ea1831615e0876865a29a08a.

Differential Revision: https://reviews.llvm.org/D144920
2023-03-06 16:38:18 +00:00
usama hameed
665e32ee0f
[Sanitizers] Error out for -static-libsan on darwin
Differential Revision: https://reviews.llvm.org/D144672
2023-03-06 16:08:26 +05:00
Fangrui Song
e2e50fe8ef [sanitizer][NetBSD] Remove ioctl TIOCRCVFRAME and TIOCXMTFRAME
The two macros were removed by
https://mail-index.netbsd.org/source-changes/2022/12/21/msg142441.html

Close #61151
2023-03-05 17:46:42 +00:00
Mark de Wever
92523a35a8 Revert "[CMake] Bumps minimum version to 3.20.0."
Some build bots have not been updated to the new minimal CMake version.
Reverting for now and ping the buildbot owners.

This reverts commit 44c6b905f8527635e49bb3ea97dea315f92d38ec.
2023-03-04 18:28:13 +01:00
Mark de Wever
44c6b905f8 [CMake] Bumps minimum version to 3.20.0.
This partly undoes D137724.

This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193

Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.

Reviewed By: mehdi_amini, MaskRay, ChuanqiXu, to268, thieta, tschuett, phosek, #libunwind, #libc_vendors, #libc, #libc_abi, sivachandra, philnik, zibi

Differential Revision: https://reviews.llvm.org/D144509
2023-03-04 12:40:57 +01:00
Daniel Thornburgh
072e07a9d5 [llvm-cov] Optionally fail on missing binary ID
This adds the --check-binary-id flag that makes sure that an object file
is available for every binary ID mentioned in the given profile. This
should help make the tool more robust in CI environments where it's
expected that coverage mappings should be available for every object
contributing to the profile.

Reviewed By: gulfem

Differential Revision: https://reviews.llvm.org/D144308
2023-03-03 10:24:21 -08:00
Chia-hung Duan
daaef4c499 Revert "Revert "Revert "[scudo] Only prepare PageMap entry for partial region"""
ScudoReleaseTest.ReleaseFreeMemoryToOSAndroid failed on Fuchsia

This reverts commit c6ef6bbd8d964028ee6c2f03441604d7a7ba5375.
2023-03-02 20:37:55 +00:00