16568 Commits

Author SHA1 Message Date
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
usama hameed
e277d6adf8
[Sanitizers] Disable armv7* sanitizers slice for ios
rdar://104059106

Differential Revision: https://reviews.llvm.org/D145000
2023-03-02 21:08:33 +05:00
Wu, Yingcong
9a77a6f802 [memprof] Avoid meaningless pod copy
The pointer `Buffer` is not changed, so there is no need to use reference, and the `Pod` here should use reference to avoid meaningless copy.

Reviewed By: snehasish

Differential Revision: https://reviews.llvm.org/D145024
2023-03-02 01:39:01 +00:00
Alex Brachet
21fc42b2d5 [GWP-ASan][Fuchsia] Use more modern zxtest testing macros 2023-03-01 18:54:05 +00:00
Alex Brachet
b27f657f89 [GWP-ASan] Stop using type aliases for ::testing:: types 2023-03-01 18:49:18 +00:00
Wu, Yingcong
17718a2cff Move close() to the proper else block
`LogWriter::Close(LW)` is outside the null check if-else block, which, when `LW == nullptr`, will causing a NULL dereference.
I think the close() means to be in else block, which is when `LW != nullptr`.

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D145039
2023-03-01 19:09:11 +05:30
Shoaib Meenai
c2d6cc9ac4 [builtins] Add option to always build int128 routines
32-bit targets don't build these by default, but e.g. armv7 and x86 can
build them just fine, and it's useful to have the int128 routines
available for certain applications. Add a CMake option to let us include
the int128 routines for architectures which would otherwise lack them.

Reviewed By: compnerd, MaskRay, phosek

Differential Revision: https://reviews.llvm.org/D145003
2023-02-28 16:38:24 -08:00
Mitch Phillips
bc949f923e [GWP-ASan] Handle wild touches of the guarded pool.
AllocMeta could be null when returned from __gwp_asan_get_metadata() for
a bad access into the GuardedPagePool that was never allocated.
Currently, then we dereference the null pointer, oops.

Hoist the check up and print a message (only once in recoverable mode)
about the bad memory access.

Reviewed By: fmayer

Differential Revision: https://reviews.llvm.org/D144973
2023-02-28 14:05:51 -08:00
Chia-hung Duan
c6ef6bbd8d Revert "Revert "[scudo] Only prepare PageMap entry for partial region""
Fixed the bug in merging BatchGroups back to the FreeList. Added DCHECKs
to ensure the order of BatchGroups

This reverts commit 387452ec591c81def6d8869b23c2ab2f1c56f999.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D144920
2023-02-28 16:55:48 +00:00
Chia-hung Duan
dbfc037e50 [scudo] Set name for reserved regions in SizeClassAllocator64
This improves the readability of address space

Reviewed By: enh

Differential Revision: https://reviews.llvm.org/D144898
2023-02-28 03:20:39 +00:00
Chia-hung Duan
387452ec59 Revert "[scudo] Only prepare PageMap entry for partial region"
This reverts commit 0a0b6fa4fbdf3bdeb300ddd58859f66b714b8bdf.
2023-02-27 21:12:28 +00:00
Chia-hung Duan
0a0b6fa4fb [scudo] Only prepare PageMap entry for partial region
This reduces the size of PageMap and we are more likely to use the
static local buffer. Note that now this is only supported for single
region case, i.e. on SizeClassAllocator64. For SizeClassAllocator32,
it needs a different way to save the PageMap.

Differential Revision: https://reviews.llvm.org/D142659
2023-02-27 18:49:10 +00:00
Vitaly Buka
773e5dfbc6 [docs] Update compiler-rt/CODE_OWNERS.TXT
D135617 leftovers

Reviewed By: browneee, cryptoad

Differential Revision: https://reviews.llvm.org/D136308
2023-02-24 15:07:09 -08:00
Ilya Leoshkevich
0ce057c592 [sanitizer] Support v2 and v3 capabilities
capget() and capset() may read or write more than one cap_user_data_t,
depending on the version field of cap_user_header_t. Currently the
code assumes it's just one, so MSan complains if an application uses
version 2 or 3, where two cap_user_data_ts are used.

Parse the header in order to determine the number of cap_user_data_ts.
Also add a test.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D143660
2023-02-24 14:12:11 +01:00
Martin Liska
8f5962b1cc ASAN: keep support for Global::location
We as GCC still emit __asan_global_source_location for global variables
and we would like to use it in the future. On other hand, we don't
support llvm-symbolizer and the default libbacktraace symbolizer
does not support location info.

Differential Revision: https://reviews.llvm.org/D144424
2023-02-24 09:10:56 +01:00