aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuan-Ying Lee <[email protected]>2021-06-28 19:40:58 -0700
committerLinus Torvalds <[email protected]>2021-06-29 10:53:53 -0700
commit7a22bdc3c443d5abc420df1381e425b49e8901a3 (patch)
treee1b4ae8542080a1124c61f69f697cfabf39ab7e7
parenta0503b8a0b3c8ef1be55744a248bffb8f533d227 (diff)
kasan: add memory corruption identification support for hardware tag-based mode
Add memory corruption identification support for hardware tag-based mode. We store one old free pointer tag and free backtrace instead of five because hardware tag-based kasan only has 16 different tags. If we store as many stacks as SW tag-based kasan does(5 stacks), there is high probability to find the same tag in the stacks when out-of-bound issues happened and we will mistake out-of-bound issue for use-after-free. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kuan-Ying Lee <[email protected]> Suggested-by: Marco Elver <[email protected]> Reviewed-by: Alexander Potapenko <[email protected]> Reviewed-by: Andrey Konovalov <[email protected]> Reviewed-by: Marco Elver <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Chinwen Chang <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Matthias Brugger <[email protected]> Cc: Nicholas Tang <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--lib/Kconfig.kasan2
-rw-r--r--mm/kasan/kasan.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index fdb4a08dba83..1e2d10f86011 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -169,7 +169,7 @@ config KASAN_STACK
config KASAN_TAGS_IDENTIFY
bool "Enable memory corruption identification"
- depends on KASAN_SW_TAGS
+ depends on KASAN_SW_TAGS || KASAN_HW_TAGS
help
This option enables best-effort identification of bug type
(use-after-free or out-of-bounds) at the cost of increased
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index 2317d0943a07..98e3059bfea4 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -153,7 +153,7 @@ struct kasan_track {
depot_stack_handle_t stack;
};
-#ifdef CONFIG_KASAN_TAGS_IDENTIFY
+#if defined(CONFIG_KASAN_TAGS_IDENTIFY) && defined(CONFIG_KASAN_SW_TAGS)
#define KASAN_NR_FREE_STACKS 5
#else
#define KASAN_NR_FREE_STACKS 1