mm/kasan/hw_tags.c
Source file repositories/reference/linux-study-clean/mm/kasan/hw_tags.c
File Facts
- System
- Linux kernel
- Corpus path
mm/kasan/hw_tags.c- Extension
.c- Size
- 11030 bytes
- Lines
- 442
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/visibility.hlinux/init.hlinux/kasan.hlinux/kernel.hlinux/memory.hlinux/mm.hlinux/static_key.hlinux/string.hlinux/string_choices.hlinux/types.hlinux/vmalloc.hkasan.h
Detected Declarations
enum kasan_argenum kasan_arg_modeenum kasan_arg_vmallocfunction early_kasan_flagfunction early_kasan_modefunction early_kasan_flag_vmallocfunction early_kasan_flag_write_onlyfunction early_kasan_flag_page_alloc_samplefunction early_kasan_flag_page_alloc_sample_orderfunction kasan_init_hw_tags_cpufunction kasan_init_hw_tagsfunction unpoison_vmalloc_pagesfunction init_vmalloc_pagesfunction vmallocfunction __kasan_poison_vmallocfunction hw_enable_tag_checks_write_onlyfunction kasan_force_async_faultfunction kasan_write_only_enabledexport kasan_modeexport kasan_flag_vmalloc
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* This file contains core hardware tag-based KASAN code.
*
* Copyright (c) 2020 Google, Inc.
* Author: Andrey Konovalov <andreyknvl@google.com>
*/
#define pr_fmt(fmt) "kasan: " fmt
#include <kunit/visibility.h>
#include <linux/init.h>
#include <linux/kasan.h>
#include <linux/kernel.h>
#include <linux/memory.h>
#include <linux/mm.h>
#include <linux/static_key.h>
#include <linux/string.h>
#include <linux/string_choices.h>
#include <linux/types.h>
#include <linux/vmalloc.h>
#include "kasan.h"
enum kasan_arg {
KASAN_ARG_DEFAULT,
KASAN_ARG_OFF,
KASAN_ARG_ON,
};
enum kasan_arg_mode {
KASAN_ARG_MODE_DEFAULT,
KASAN_ARG_MODE_SYNC,
KASAN_ARG_MODE_ASYNC,
KASAN_ARG_MODE_ASYMM,
};
enum kasan_arg_vmalloc {
KASAN_ARG_VMALLOC_DEFAULT,
KASAN_ARG_VMALLOC_OFF,
KASAN_ARG_VMALLOC_ON,
};
static enum kasan_arg kasan_arg __ro_after_init;
static enum kasan_arg_mode kasan_arg_mode __ro_after_init;
static enum kasan_arg_vmalloc kasan_arg_vmalloc __initdata;
/*
* Whether the selected mode is synchronous, asynchronous, or asymmetric.
* Defaults to KASAN_MODE_SYNC.
*/
enum kasan_mode kasan_mode __ro_after_init;
EXPORT_SYMBOL_GPL(kasan_mode);
/* Whether to enable vmalloc tagging. */
#ifdef CONFIG_KASAN_VMALLOC
DEFINE_STATIC_KEY_TRUE(kasan_flag_vmalloc);
#else
DEFINE_STATIC_KEY_FALSE(kasan_flag_vmalloc);
#endif
EXPORT_SYMBOL_GPL(kasan_flag_vmalloc);
/* Whether to check write accesses only. */
static bool kasan_flag_write_only = false;
#define PAGE_ALLOC_SAMPLE_DEFAULT 1
#define PAGE_ALLOC_SAMPLE_ORDER_DEFAULT 3
/*
* Sampling interval of page_alloc allocation (un)poisoning.
* Defaults to no sampling.
*/
unsigned long kasan_page_alloc_sample = PAGE_ALLOC_SAMPLE_DEFAULT;
/*
* Minimum order of page_alloc allocations to be affected by sampling.
* The default value is chosen to match both
* PAGE_ALLOC_COSTLY_ORDER and SKB_FRAG_PAGE_ORDER.
*/
unsigned int kasan_page_alloc_sample_order = PAGE_ALLOC_SAMPLE_ORDER_DEFAULT;
DEFINE_PER_CPU(long, kasan_page_alloc_skip);
/* kasan=off/on */
static int __init early_kasan_flag(char *arg)
{
if (!arg)
return -EINVAL;
if (!strcmp(arg, "off"))
Annotation
- Immediate include surface: `kunit/visibility.h`, `linux/init.h`, `linux/kasan.h`, `linux/kernel.h`, `linux/memory.h`, `linux/mm.h`, `linux/static_key.h`, `linux/string.h`.
- Detected declarations: `enum kasan_arg`, `enum kasan_arg_mode`, `enum kasan_arg_vmalloc`, `function early_kasan_flag`, `function early_kasan_mode`, `function early_kasan_flag_vmalloc`, `function early_kasan_flag_write_only`, `function early_kasan_flag_page_alloc_sample`, `function early_kasan_flag_page_alloc_sample_order`, `function kasan_init_hw_tags_cpu`.
- 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.