// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Lightweight Quarantine (LQ) provides a low-cost quarantine mechanism with // following characteristics. // // - Built on PartitionAlloc: only supports allocations in a known root // - As fast as PA: LQ just defers `Free()` handling and may benefit from thread // cache etc. // - Thread-safe // - No allocation time information: triggered on `Free()` // - Don't use quarantined objects' payload - available for zapping // - Don't allocate heap memory. // - Flexible to support several applications // // `LightweightQuarantineRoot` represents one quarantine system // (e.g. scheduler loop quarantine). // `LightweightQuarantineBranch` provides a quarantine request interface. // It belongs to a `LightweightQuarantineRoot` and there can be multiple // instances (e.g. one per thread). By having one branch per thread, it requires // no lock for faster quarantine. // ┌────────────────────────────┐ // │PartitionRoot │ // └┬──────────────────────────┬┘ // ┌▽────────────────────────┐┌▽────────────────────┐ // │LQRoot 1 ││LQRoot 2 │ // └┬───────────┬───────────┬┘└──────────────┬──┬──┬┘ // ┌▽─────────┐┌▽─────────┐┌▽─────────┐ ▽ ▽ ▽ // │LQBranch 1││LQBranch 2││LQBranch 3│ // └──────────┘└──────────┘└──────────┘ #ifndef PARTITION_ALLOC_LIGHTWEIGHT_QUARANTINE_H_ #define PARTITION_ALLOC_LIGHTWEIGHT_QUARANTINE_H_ #include <array> #include <atomic> #include <cstdint> #include <limits> #include <memory> #include <type_traits> #include <vector> #include "partition_alloc/internal_allocator_forward.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/rand_util.h" #include "partition_alloc/partition_alloc_base/thread_annotations.h" #include "partition_alloc/partition_alloc_forward.h" #include "partition_alloc/partition_lock.h" #include "partition_alloc/partition_stats.h" namespace partition_alloc { struct PartitionRoot; struct LightweightQuarantineStats; namespace internal { struct LightweightQuarantineBranchConfig { … }; class LightweightQuarantineBranch; class PA_COMPONENT_EXPORT(PARTITION_ALLOC) LightweightQuarantineRoot { … }; class PA_COMPONENT_EXPORT(PARTITION_ALLOC) LightweightQuarantineBranch { … }; } // namespace internal } // namespace partition_alloc #endif // PARTITION_ALLOC_LIGHTWEIGHT_QUARANTINE_H_