mm/kasan/sw_tags.c
Source file repositories/reference/linux-study-clean/mm/kasan/sw_tags.c
File Facts
- System
- Linux kernel
- Corpus path
mm/kasan/sw_tags.c- Extension
.c- Size
- 5229 bytes
- Lines
- 179
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
Dependency Surface
linux/export.hlinux/interrupt.hlinux/init.hlinux/kasan.hlinux/kernel.hlinux/kmemleak.hlinux/linkage.hlinux/memblock.hlinux/memory.hlinux/mm.hlinux/module.hlinux/printk.hlinux/random.hlinux/sched.hlinux/sched/task_stack.hlinux/slab.hlinux/stacktrace.hlinux/string.hlinux/string_choices.hlinux/types.hlinux/vmalloc.hlinux/bug.hkasan.h../slab.h
Detected Declarations
function kasan_init_sw_tagsfunction kasan_random_tagfunction kasan_check_rangefunction kasan_byte_accessiblefunction __hwasan_loadN_noabortfunction __hwasan_storeN_noabortfunction __hwasan_tag_memoryfunction kasan_tag_mismatchexport __hwasan_loadN_noabortexport __hwasan_storeN_noabortexport __hwasan_tag_memory
Annotated Snippet
if (*shadow != tag) {
return !kasan_report(addr, size, write, ret_ip);
}
}
return true;
}
bool kasan_byte_accessible(const void *addr)
{
u8 tag = get_tag(addr);
void *untagged_addr = kasan_reset_tag(addr);
u8 shadow_byte;
if (!addr_has_metadata(untagged_addr))
return false;
shadow_byte = READ_ONCE(*(u8 *)kasan_mem_to_shadow(untagged_addr));
return tag == KASAN_TAG_KERNEL || tag == shadow_byte;
}
#define DEFINE_HWASAN_LOAD_STORE(size) \
void __hwasan_load##size##_noabort(void *addr) \
{ \
kasan_check_range(addr, size, false, _RET_IP_); \
} \
EXPORT_SYMBOL(__hwasan_load##size##_noabort); \
void __hwasan_store##size##_noabort(void *addr) \
{ \
kasan_check_range(addr, size, true, _RET_IP_); \
} \
EXPORT_SYMBOL(__hwasan_store##size##_noabort)
DEFINE_HWASAN_LOAD_STORE(1);
DEFINE_HWASAN_LOAD_STORE(2);
DEFINE_HWASAN_LOAD_STORE(4);
DEFINE_HWASAN_LOAD_STORE(8);
DEFINE_HWASAN_LOAD_STORE(16);
void __hwasan_loadN_noabort(void *addr, ssize_t size)
{
kasan_check_range(addr, size, false, _RET_IP_);
}
EXPORT_SYMBOL(__hwasan_loadN_noabort);
void __hwasan_storeN_noabort(void *addr, ssize_t size)
{
kasan_check_range(addr, size, true, _RET_IP_);
}
EXPORT_SYMBOL(__hwasan_storeN_noabort);
void __hwasan_tag_memory(void *addr, u8 tag, ssize_t size)
{
kasan_poison(addr, size, tag, false);
}
EXPORT_SYMBOL(__hwasan_tag_memory);
void kasan_tag_mismatch(void *addr, unsigned long access_info,
unsigned long ret_ip)
{
kasan_report(addr, 1 << (access_info & 0xf), access_info & 0x10,
ret_ip);
}
Annotation
- Immediate include surface: `linux/export.h`, `linux/interrupt.h`, `linux/init.h`, `linux/kasan.h`, `linux/kernel.h`, `linux/kmemleak.h`, `linux/linkage.h`, `linux/memblock.h`.
- Detected declarations: `function kasan_init_sw_tags`, `function kasan_random_tag`, `function kasan_check_range`, `function kasan_byte_accessible`, `function __hwasan_loadN_noabort`, `function __hwasan_storeN_noabort`, `function __hwasan_tag_memory`, `function kasan_tag_mismatch`, `export __hwasan_loadN_noabort`, `export __hwasan_storeN_noabort`.
- Atlas domain: Core OS / Memory Management.
- Implementation status: integration 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.