003 File Manager
Current Path:
/usr/src/contrib/llvm-project/compiler-rt/lib/hwasan
usr
/
src
/
contrib
/
llvm-project
/
compiler-rt
/
lib
/
hwasan
/
📁
..
📄
hwasan.cpp
(15.25 KB)
📄
hwasan.h
(5.69 KB)
📄
hwasan.syms.extra
(21 B)
📄
hwasan_allocator.cpp
(13.71 KB)
📄
hwasan_allocator.h
(3.26 KB)
📄
hwasan_blacklist.txt
(282 B)
📄
hwasan_checks.h
(4.04 KB)
📄
hwasan_dynamic_shadow.cpp
(5.17 KB)
📄
hwasan_dynamic_shadow.h
(838 B)
📄
hwasan_exceptions.cpp
(2.68 KB)
📄
hwasan_flags.h
(799 B)
📄
hwasan_flags.inc
(3.27 KB)
📄
hwasan_globals.cpp
(3.03 KB)
📄
hwasan_globals.h
(1.85 KB)
📄
hwasan_interceptors.cpp
(11.1 KB)
📄
hwasan_interceptors_vfork.S
(409 B)
📄
hwasan_interface_internal.h
(6.32 KB)
📄
hwasan_linux.cpp
(15.83 KB)
📄
hwasan_malloc_bisect.h
(1.67 KB)
📄
hwasan_mapping.h
(2.01 KB)
📄
hwasan_memintrinsics.cpp
(1.6 KB)
📄
hwasan_new_delete.cpp
(2.29 KB)
📄
hwasan_poisoning.cpp
(1.89 KB)
📄
hwasan_poisoning.h
(756 B)
📄
hwasan_report.cpp
(24.11 KB)
📄
hwasan_report.h
(1.2 KB)
📄
hwasan_setjmp.S
(2.81 KB)
📄
hwasan_tag_mismatch_aarch64.S
(5.89 KB)
📄
hwasan_thread.cpp
(3.9 KB)
📄
hwasan_thread.h
(2.82 KB)
📄
hwasan_thread_list.cpp
(442 B)
📄
hwasan_thread_list.h
(6.2 KB)
📄
hwasan_type_test.cpp
(918 B)
Editing: hwasan_allocator.h
//===-- hwasan_allocator.h --------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file is a part of HWAddressSanitizer. // //===----------------------------------------------------------------------===// #ifndef HWASAN_ALLOCATOR_H #define HWASAN_ALLOCATOR_H #include "sanitizer_common/sanitizer_allocator.h" #include "sanitizer_common/sanitizer_allocator_checks.h" #include "sanitizer_common/sanitizer_allocator_interface.h" #include "sanitizer_common/sanitizer_allocator_report.h" #include "sanitizer_common/sanitizer_common.h" #include "sanitizer_common/sanitizer_ring_buffer.h" #include "hwasan_poisoning.h" #if !defined(__aarch64__) && !defined(__x86_64__) #error Unsupported platform #endif namespace __hwasan { struct Metadata { u32 requested_size : 31; // sizes are < 2G. u32 right_aligned : 1; u32 alloc_context_id; }; struct HwasanMapUnmapCallback { void OnMap(uptr p, uptr size) const { UpdateMemoryUsage(); } void OnUnmap(uptr p, uptr size) const { // We are about to unmap a chunk of user memory. // It can return as user-requested mmap() or another thread stack. // Make it accessible with zero-tagged pointer. TagMemory(p, size, 0); } }; static const uptr kMaxAllowedMallocSize = 2UL << 30; // 2G struct AP64 { static const uptr kSpaceBeg = ~0ULL; static const uptr kSpaceSize = 0x2000000000ULL; static const uptr kMetadataSize = sizeof(Metadata); typedef __sanitizer::VeryDenseSizeClassMap SizeClassMap; using AddressSpaceView = LocalAddressSpaceView; typedef HwasanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; typedef SizeClassAllocator64<AP64> PrimaryAllocator; typedef CombinedAllocator<PrimaryAllocator> Allocator; typedef Allocator::AllocatorCache AllocatorCache; void AllocatorSwallowThreadLocalCache(AllocatorCache *cache); class HwasanChunkView { public: HwasanChunkView() : block_(0), metadata_(nullptr) {} HwasanChunkView(uptr block, Metadata *metadata) : block_(block), metadata_(metadata) {} bool IsAllocated() const; // Checks if the memory is currently allocated uptr Beg() const; // First byte of user memory uptr End() const; // Last byte of user memory uptr UsedSize() const; // Size requested by the user uptr ActualSize() const; // Size allocated by the allocator. u32 GetAllocStackId() const; bool FromSmallHeap() const; private: uptr block_; Metadata *const metadata_; }; HwasanChunkView FindHeapChunkByAddress(uptr address); // Information about one (de)allocation that happened in the past. // These are recorded in a thread-local ring buffer. // TODO: this is currently 24 bytes (20 bytes + alignment). // Compress it to 16 bytes or extend it to be more useful. struct HeapAllocationRecord { uptr tagged_addr; u32 alloc_context_id; u32 free_context_id; u32 requested_size; }; typedef RingBuffer<HeapAllocationRecord> HeapAllocationsRingBuffer; void GetAllocatorStats(AllocatorStatCounters s); } // namespace __hwasan #endif // HWASAN_ALLOCATOR_H
Upload File
Create Folder