lib/Kconfig.kasan

Source file repositories/reference/linux-study-clean/lib/Kconfig.kasan

File Facts

System
Linux kernel
Corpus path
lib/Kconfig.kasan
Extension
.kasan
Size
7791 bytes
Lines
232
Domain
Kernel Services
Bucket
lib
Inferred role
Kernel Services: lib
Status
atlas-only

Why This File Exists

Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.

Dependency Surface

Detected Declarations

Annotated Snippet

# SPDX-License-Identifier: GPL-2.0-only

# This config refers to the generic KASAN mode.
config HAVE_ARCH_KASAN
	bool

config HAVE_ARCH_KASAN_SW_TAGS
	bool

config HAVE_ARCH_KASAN_HW_TAGS
	bool

config HAVE_ARCH_KASAN_VMALLOC
	bool

config ARCH_DISABLE_KASAN_INLINE
	bool
	help
	  Disables both inline and stack instrumentation. Selected by
	  architectures that do not support these instrumentation types.

config ARCH_NEEDS_DEFER_KASAN
	bool

config ARCH_DEFER_KASAN
	def_bool y
	depends on KASAN && ARCH_NEEDS_DEFER_KASAN
	help
	  Architectures should select this if they need to defer KASAN
	  initialization until shadow memory is properly set up. This
	  enables runtime control via static keys. Otherwise, KASAN uses
	  compile-time constants for better performance.

config CC_HAS_KASAN_GENERIC
	def_bool $(cc-option, -fsanitize=kernel-address)

config CC_HAS_KASAN_SW_TAGS
	def_bool $(cc-option, -fsanitize=kernel-hwaddress)

# This option is only required for software KASAN modes.
# Old GCC versions do not have proper support for no_sanitize_address.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89124 for details.
config CC_HAS_WORKING_NOSANITIZE_ADDRESS
	def_bool !CC_IS_GCC || GCC_VERSION >= 80300

menuconfig KASAN
	bool "KASAN: dynamic memory safety error detector"
	depends on (((HAVE_ARCH_KASAN && CC_HAS_KASAN_GENERIC) || \
		     (HAVE_ARCH_KASAN_SW_TAGS && CC_HAS_KASAN_SW_TAGS)) && \
		    CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \
		   HAVE_ARCH_KASAN_HW_TAGS
	depends on SYSFS && !SLUB_TINY
	select STACKDEPOT_ALWAYS_INIT
	help
	  Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety
	  error detector designed to find out-of-bounds and use-after-free bugs.

	  See Documentation/dev-tools/kasan.rst for details.

	  For better error reports, also enable CONFIG_STACKTRACE.

if KASAN

config CC_HAS_KASAN_MEMINTRINSIC_PREFIX
	def_bool (CC_IS_CLANG && $(cc-option,-fsanitize=kernel-address -mllvm -asan-kernel-mem-intrinsic-prefix=1)) || \
		 (CC_IS_GCC && $(cc-option,-fsanitize=kernel-address --param asan-kernel-mem-intrinsic-prefix=1))
	# Don't define it if we don't need it: compilation of the test uses
	# this variable to decide how the compiler should treat builtins.
	depends on !KASAN_HW_TAGS
	help

Annotation

Implementation Notes