include/linux/kasan.h
Source file repositories/reference/linux-study-clean/include/linux/kasan.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/kasan.h- Extension
.h- Size
- 22744 bytes
- Lines
- 714
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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/bug.hlinux/kasan-enabled.hlinux/kasan-tags.hlinux/kernel.hlinux/static_key.hlinux/types.hlinux/linkage.hasm/kasan.hlinux/pgtable.h
Detected Declarations
struct kmem_cachestruct pagestruct slabstruct vm_structstruct task_structstruct kasan_cachefunction kasan_add_zero_shadowfunction kasan_remove_zero_shadowfunction kasan_unpoison_rangefunction kasan_poison_pagesfunction kasan_unpoison_pagesfunction kasan_poison_slabfunction kasan_poison_new_objectfunction kasan_unpoison_new_objectfunction kasan_init_slab_objfunction kasan_slab_pre_freefunction kasan_slab_freefunction kasan_kfree_largefunction kasan_slab_allocfunction kasan_kmallocfunction kasan_kmalloc_largefunction kasan_kreallocfunction kasan_mempool_poison_pagesfunction page_allocfunction kasan_mempool_poison_objectfunction allocatorfunction kasan_check_bytefunction kasan_unpoison_rangefunction kasan_poison_slabfunction kasan_slab_pre_freefunction kasan_slab_freefunction kasan_kfree_largefunction kasan_mempool_poison_pagesfunction kasan_mempool_unpoison_pagesfunction kasan_mempool_unpoison_objectfunction kasan_unpoison_task_stackfunction kasan_metadata_sizefunction kasan_cache_createfunction kasan_init_genericfunction kasan_init_sw_tagsfunction kasan_init_hw_tags_cpufunction kasan_populate_vmallocfunction kasan_release_vmallocfunction kasan_populate_early_vm_area_shadowfunction kasan_release_vmallocfunction kasan_poison_vmallocfunction kasan_unpoison_vmap_areasfunction kasan_vrealloc
Annotated Snippet
struct kasan_cache {
int alloc_meta_offset;
int free_meta_offset;
};
size_t kasan_metadata_size(struct kmem_cache *cache, bool in_object);
void kasan_cache_create(struct kmem_cache *cache, unsigned int *size,
slab_flags_t *flags);
void kasan_cache_shrink(struct kmem_cache *cache);
void kasan_cache_shutdown(struct kmem_cache *cache);
void kasan_record_aux_stack(void *ptr);
#else /* CONFIG_KASAN_GENERIC */
/* Tag-based KASAN modes do not use per-object metadata. */
static inline size_t kasan_metadata_size(struct kmem_cache *cache,
bool in_object)
{
return 0;
}
/* And no cache-related metadata initialization is required. */
static inline void kasan_cache_create(struct kmem_cache *cache,
unsigned int *size,
slab_flags_t *flags) {}
static inline void kasan_cache_shrink(struct kmem_cache *cache) {}
static inline void kasan_cache_shutdown(struct kmem_cache *cache) {}
static inline void kasan_record_aux_stack(void *ptr) {}
#endif /* CONFIG_KASAN_GENERIC */
#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS)
static inline void *kasan_reset_tag(const void *addr)
{
return (void *)arch_kasan_reset_tag(addr);
}
/**
* kasan_report - print a report about a bad memory access detected by KASAN
* @addr: address of the bad access
* @size: size of the bad access
* @is_write: whether the bad access is a write or a read
* @ip: instruction pointer for the accessibility check or the bad access itself
*/
bool kasan_report(const void *addr, size_t size,
bool is_write, unsigned long ip);
#else /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */
static inline void *kasan_reset_tag(const void *addr)
{
return (void *)addr;
}
#endif /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS*/
#ifdef CONFIG_KASAN_HW_TAGS
void kasan_report_async(void);
#endif /* CONFIG_KASAN_HW_TAGS */
#ifdef CONFIG_KASAN_GENERIC
void __init kasan_init_generic(void);
#else
static inline void kasan_init_generic(void) { }
#endif
#ifdef CONFIG_KASAN_SW_TAGS
void __init kasan_init_sw_tags(void);
#else
static inline void kasan_init_sw_tags(void) { }
#endif
#ifdef CONFIG_KASAN_HW_TAGS
void kasan_init_hw_tags_cpu(void);
void __init kasan_init_hw_tags(void);
#else
static inline void kasan_init_hw_tags_cpu(void) { }
static inline void kasan_init_hw_tags(void) { }
#endif
#ifdef CONFIG_KASAN_VMALLOC
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
void kasan_populate_early_vm_area_shadow(void *start, unsigned long size);
int __kasan_populate_vmalloc(unsigned long addr, unsigned long size, gfp_t gfp_mask);
Annotation
- Immediate include surface: `linux/bug.h`, `linux/kasan-enabled.h`, `linux/kasan-tags.h`, `linux/kernel.h`, `linux/static_key.h`, `linux/types.h`, `linux/linkage.h`, `asm/kasan.h`.
- Detected declarations: `struct kmem_cache`, `struct page`, `struct slab`, `struct vm_struct`, `struct task_struct`, `struct kasan_cache`, `function kasan_add_zero_shadow`, `function kasan_remove_zero_shadow`, `function kasan_unpoison_range`, `function kasan_poison_pages`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.