0

[PartitionAlloc] Don't memset() direct-mapped alloocations

These are unmapped right away, so memset() is a needless cost, and
doesn't help security, nor debuggability.

Bug: 374946475
Change-Id: I558d00c50fbb4337be38f1b15b86aaee801964b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5952195
Reviewed-by: Mikihito Matsuura <mikt@google.com>
Commit-Queue: Benoit Lize <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1372749}
This commit is contained in:
Benoît Lizé
2024-10-23 16:12:25 +00:00
committed by Chromium LUCI CQ
parent 337cb5d31a
commit d1ce125a37

@ -1486,7 +1486,11 @@ PA_ALWAYS_INLINE void PartitionRoot::FreeInline(void* object) {
PA_PREFETCH(slot_span);
if constexpr (ContainsFlags(flags, FreeFlags::kZap)) {
if (settings.zapping_by_free_flags) {
// No need to zap direct mapped allocations, as they are unmapped right
// away. This also ensures that we don't needlessly memset() very large
// allocations.
if (settings.zapping_by_free_flags &&
!IsDirectMappedBucket(slot_span->bucket)) {
internal::SecureMemset(object, internal::kFreedByte,
GetSlotUsableSize(slot_span));
}