mm/kasan/kasan.h
Source file repositories/reference/linux-study-clean/mm/kasan/kasan.h
File Facts
- System
- Linux kernel
- Corpus path
mm/kasan/kasan.h- Extension
.h- Size
- 20141 bytes
- Lines
- 670
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/kasan.hlinux/kasan-tags.hlinux/kfence.hlinux/stackdepot.hlinux/static_key.h../slab.hasm/mte-kasan.h
Detected Declarations
struct kasan_trackstruct kasan_report_infostruct kasan_source_locationstruct kasan_globalstruct kasan_alloc_metastruct qlist_nodestruct kasan_free_metastruct kasan_stack_ring_entrystruct kasan_stack_ringenum kasan_modeenum kasan_report_typefunction kasan_stack_collection_enabledfunction kasan_stack_collection_enabledfunction kasan_vmalloc_enabledfunction kasan_async_fault_possiblefunction kasan_sync_fault_possiblefunction kasan_sample_page_allocfunction kasan_vmalloc_enabledfunction kasan_async_fault_possiblefunction kasan_sync_fault_possiblefunction kasan_sample_page_allocfunction kasan_requires_metafunction kasan_requires_metafunction addr_in_shadowfunction addr_has_metadatafunction addr_has_metadatafunction kasan_print_tagsfunction kasan_print_address_stack_framefunction kasan_print_aux_stacksfunction kasan_init_object_metafunction kasan_quarantine_putfunction kasan_quarantine_reducefunction kasan_enable_hw_tagsfunction kasan_force_async_faultfunction kasan_random_tagfunction kasan_random_tagfunction kasan_poisonfunction kasan_unpoisonfunction kasan_byte_accessiblefunction kasan_poison_last_granulefunction kasan_test_rust_uaffunction kasan_kunit_test_suite_start
Annotated Snippet
struct kasan_track {
u32 pid;
depot_stack_handle_t stack;
#ifdef CONFIG_KASAN_EXTRA_INFO
u64 cpu:20;
u64 timestamp:44;
#endif /* CONFIG_KASAN_EXTRA_INFO */
};
enum kasan_report_type {
KASAN_REPORT_ACCESS,
KASAN_REPORT_INVALID_FREE,
KASAN_REPORT_DOUBLE_FREE,
};
struct kasan_report_info {
/* Filled in by kasan_report_*(). */
enum kasan_report_type type;
const void *access_addr;
size_t access_size;
bool is_write;
unsigned long ip;
/* Filled in by the common reporting code. */
const void *first_bad_addr;
struct kmem_cache *cache;
void *object;
size_t alloc_size;
/* Filled in by the mode-specific reporting code. */
const char *bug_type;
struct kasan_track alloc_track;
struct kasan_track free_track;
};
/* Do not change the struct layout: compiler ABI. */
struct kasan_source_location {
const char *filename;
int line_no;
int column_no;
};
/* Do not change the struct layout: compiler ABI. */
struct kasan_global {
const void *beg; /* Address of the beginning of the global variable. */
size_t size; /* Size of the global variable. */
size_t size_with_redzone; /* Size of the variable + size of the redzone. 32 bytes aligned. */
const void *name;
const void *module_name; /* Name of the module where the global variable is declared. */
unsigned long has_dynamic_init; /* This is needed for C++. */
#if KASAN_ABI_VERSION >= 4
struct kasan_source_location *location;
#endif
#if KASAN_ABI_VERSION >= 5
char *odr_indicator;
#endif
};
/* Structures for keeping alloc and free meta. */
#ifdef CONFIG_KASAN_GENERIC
/*
* Alloc meta contains the allocation-related information about a slab object.
* Alloc meta is saved when an object is allocated and is kept until either the
* object returns to the slab freelist (leaves quarantine for quarantined
* objects or gets freed for the non-quarantined ones) or reallocated via
* krealloc or through a mempool.
* Alloc meta is stored inside of the object's redzone.
* Alloc meta is considered valid whenever it contains non-zero data.
*/
struct kasan_alloc_meta {
struct kasan_track alloc_track;
/* Free track is stored in kasan_free_meta. */
depot_stack_handle_t aux_stack[2];
};
struct qlist_node {
struct qlist_node *next;
};
/*
* Free meta is stored either in the object itself or in the redzone after the
* object. In the former case, free meta offset is 0. In the latter case, the
* offset is between 0 and INT_MAX. INT_MAX marks that free meta is not present.
*/
#define KASAN_NO_FREE_META INT_MAX
/*
* Free meta contains the freeing-related information about a slab object.
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/kasan.h`, `linux/kasan-tags.h`, `linux/kfence.h`, `linux/stackdepot.h`, `linux/static_key.h`, `../slab.h`, `asm/mte-kasan.h`.
- Detected declarations: `struct kasan_track`, `struct kasan_report_info`, `struct kasan_source_location`, `struct kasan_global`, `struct kasan_alloc_meta`, `struct qlist_node`, `struct kasan_free_meta`, `struct kasan_stack_ring_entry`, `struct kasan_stack_ring`, `enum kasan_mode`.
- Atlas domain: Core OS / Memory Management.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.