mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
This feature let us to detect accesses out of bounds of global variables. This will work as for globals in kernel image, so for globals in modules. Currently this won't work for symbols in user-specified sections (e.g. __init, __read_mostly, ...) The idea of this is simple. Compiler increases each global variable by redzone size and add constructors invoking __asan_register_globals() function. Information about global variable (address, size, size with redzone ...) passed to __asan_register_globals() so we could poison variable's redzone. This patch also forces module_alloc() to return 8*PAGE_SIZE aligned address making shadow memory handling ( kasan_module_alloc()/kasan_module_free() ) more simple. Such alignment guarantees that each shadow page backing modules address space correspond to only one module_alloc() allocation. Signed-off-by: Andrey Ryabinin <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Konstantin Serebryany <[email protected]> Cc: Dmitry Chernenkov <[email protected]> Signed-off-by: Andrey Konovalov <[email protected]> Cc: Yuri Gribov <[email protected]> Cc: Konstantin Khlebnikov <[email protected]> Cc: Sasha Levin <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
26 lines
779 B
Makefile
26 lines
779 B
Makefile
ifdef CONFIG_KASAN
|
|
ifdef CONFIG_KASAN_INLINE
|
|
call_threshold := 10000
|
|
else
|
|
call_threshold := 0
|
|
endif
|
|
|
|
CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
|
|
|
|
CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \
|
|
-fasan-shadow-offset=$(CONFIG_KASAN_SHADOW_OFFSET) \
|
|
--param asan-stack=1 --param asan-globals=1 \
|
|
--param asan-instrumentation-with-call-threshold=$(call_threshold))
|
|
|
|
ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),)
|
|
$(warning Cannot use CONFIG_KASAN: \
|
|
-fsanitize=kernel-address is not supported by compiler)
|
|
else
|
|
ifeq ($(CFLAGS_KASAN),)
|
|
$(warning CONFIG_KASAN: compiler does not support all options.\
|
|
Trying minimal configuration)
|
|
CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
|
|
endif
|
|
endif
|
|
endif
|