16 Commits

Author SHA1 Message Date
Christopher Ferris
ed6edf262d
[scudo] Change isPowerOfTwo macro to return false for zero. (#87120)
Clean-up all of the calls and remove the redundant == 0 checks.

There is only one small visible change. For non-Android, the memalign
function will now fail if alignment is zero. Before this would have
passed.
2024-04-01 13:35:29 -07:00
Christopher Ferris
7a87902684
[scudo] Fix stack depot validation. (#87024)
In the StackDepot::isValid function, there is work to validate the
TabMask variable. Unfortunately, if TabMask is set to the maximum
allowed value, TabSize = TabMask + 1 becomes zero and validation passes.

Disallow that case to prevent invalid reads into the Tab structure.
2024-03-28 17:35:46 -07:00
Florian Mayer
b4e0890458
[NFC] [scudo] move static_assert closer to class it relates to (#84257)
delete other static_assert
2024-03-11 11:46:45 -07:00
Florian Mayer
3da0166331 Reland^2 "[scudo] resize stack depot for allocation ring buffer"
Fix some warnings by matching types.

This reverts commit e1164d063558b1e89f20109d83c079caae1825d8.
2024-02-16 22:59:53 -08:00
Florian Mayer
e1164d0635
Revert "Reland "[scudo] resize stack depot for allocation ring buffer"" (#82088)
Reverts llvm/llvm-project#81028
2024-02-16 17:58:54 -08:00
Florian Mayer
aff6cb4957
Reland "[scudo] resize stack depot for allocation ring buffer" (#81028)
First commit of the stack is a clean reland, second is  the fix.

There was a typo in the `static_assert` that meant we were asserting the
size of the pointer, not the struct.

Also changed `alignas` to be more intuitive, but that is NFC.

Ran builds in Android here: https://r.android.com/2954411
2024-02-16 17:10:54 -08:00
Florian Mayer
c3291253c3
Revert "[scudo] [MTE] resize stack depot for allocation ring buffer" (#80777)
Reverts llvm/llvm-project#74515

Broke build: https://lab.llvm.org/buildbot/#/builders/75/builds/42512
2024-02-05 16:56:39 -08:00
Florian Mayer
eff77d8456
[scudo] [MTE] resize stack depot for allocation ring buffer (#74515)
Co-authored-by: ChiaHungDuan <f103119@gmail.com>
2024-02-05 16:47:02 -08:00
Evgenii Stepanov
c82f3caf56
[scudo] Add StackDepot lock to enable/disable. (#79670)
Scudo grabs all allocator locks in a pthread_atfork before the fork, and releases them after. This allows malloc to be used in a fork child of a multithreaded process, which is expressly forbidden by the standard, but very widely used. For example, Android's init uses std::string after fork when spawning services in android::init::EnterNamespaces and other places.

Any lock that is necessary to serve an allocator call must be handled this way. Otherwise there is a possibility that the lock is held during the call to fork, which results in it being held forever in the child process, and the next operation that needs it deadlocks.
2024-01-29 14:22:24 -08:00
Andrei Homescu
2dc5862cfe [scudo] Limit stack depot size on Trusty
The stack depot uses several megabytes of memory
which is a lot for Trusty.

Reviewed By: Chia-hungDuan

Differential Revision: https://reviews.llvm.org/D156392
2023-08-21 18:32:34 +00:00
Vitaly Buka
d56ef8523c [scudo] Use require_constant_initialization
Attribute guaranties safe static initialization of globals.

Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D101514
2021-05-01 01:46:47 -07:00
Vitaly Buka
ea7618684c Revert "[scudo] Use require_constant_initialization"
This reverts commit 7ad4dee3e733d820115f44cecce73ceb64c76450.
2021-04-29 09:55:54 -07:00
Vitaly Buka
7ad4dee3e7 [scudo] Use require_constant_initialization
Attribute guaranties safe static initialization of globals.

Differential Revision: https://reviews.llvm.org/D101514
2021-04-29 09:47:59 -07:00
Kostya Kortchinsky
b3420adf5a [scudo][standalone] Code tidying (NFC)
- we have clutter-reducing helpers for relaxed atomics that were barely
  used, use them everywhere we can
- clang-format everything with a recent version

Differential Revision: https://reviews.llvm.org/D90649
2020-11-02 16:00:31 -08:00
kpdev
1b0436cd4b [scudo] Silent warning for u64 -> u32 convertion
Error is raised because of using -Werror=convertion
2020-04-17 09:29:55 +03:00
Peter Collingbourne
21d50019ca scudo: Add support for diagnosing memory errors when memory tagging is enabled.
Introduce a function __scudo_get_error_info() that may be called to interpret
a crash resulting from a memory error, potentially in another process,
given information extracted from the crashing process. The crash may be
interpreted as a use-after-free, buffer overflow or buffer underflow.

Also introduce a feature to optionally record a stack trace for each
allocation and deallocation. If this feature is enabled, a stack trace for
the allocation and (if applicable) the deallocation will also be available
via __scudo_get_error_info().

Differential Revision: https://reviews.llvm.org/D77283
2020-04-17 17:26:30 -07:00