[Devel] [PATCH 2/4] mm, slub, kasan: enable user tracking by default.

Andrey Ryabinin aryabinin at odin.com
Fri Sep 4 07:06:14 PDT 2015


It's recomended to have slub's user tracking enabled with CONFIG_KASAN:
a) User tracking disables slab merging which improves
    detecting out-of-bounds accesses.
b) User tracking metadata acts as redzone which also improves
    detecting out-of-bounds accesses.
c) User tracking provides additional information about object.
    This information helps to understand bugs.

However, currently this not enabled by default, user have to put
additional parameter in boot cmdline in order to enable this option.
This is bad, because it requires to keep different cmdlines for
release and debug kernels.
So we should enable this by default.

https://jira.sw.ru/browse/PSBM-39339

Signed-off-by: Andrey Ryabinin <aryabinin at odin.com>
---
 Documentation/kasan.txt | 3 +--
 mm/slub.c               | 2 ++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/kasan.txt b/Documentation/kasan.txt
index 092fc10..ee36ef1 100644
--- a/Documentation/kasan.txt
+++ b/Documentation/kasan.txt
@@ -27,8 +27,7 @@ latter is 1.1 - 2 times faster. Inline instrumentation requires GCC 5.0 or
 latter.
 
 Currently KASAN works only with the SLUB memory allocator.
-For better bug detection and nicer report, enable CONFIG_STACKTRACE and put
-at least 'slub_debug=U' in the boot cmdline.
+For better bug detection and nicer report and enable CONFIG_STACKTRACE.
 
 To disable instrumentation for specific files or directories, add a line
 similar to the following to the respective kernel Makefile:
diff --git a/mm/slub.c b/mm/slub.c
index 37c103b..2f07a63 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -457,6 +457,8 @@ static void get_map(struct kmem_cache *s, struct page *page, unsigned long *map)
  */
 #ifdef CONFIG_SLUB_DEBUG_ON
 static int slub_debug = DEBUG_DEFAULT_FLAGS;
+#elif defined (CONFIG_KASAN)
+static int slub_debug = SLAB_STORE_USER;
 #else
 static int slub_debug;
 #endif
-- 
2.4.6




More information about the Devel mailing list