]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm, slub, kasan: enable user tracking by default with KASAN=y
authorAndrey Ryabinin <aryabinin@virtuozzo.com>
Wed, 21 Oct 2015 22:03:24 +0000 (09:03 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 21 Oct 2015 22:03:24 +0000 (09:03 +1100)
It's recommended to have slub's user tracking enabled with CONFIG_KASAN,
because:

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.

Currently it is not enabled by default.  Besides recompiling the kernel
with KASAN and reinstalling it, user also have to change the boot cmdline,
which is not very handy.

Enable slub user tracking by default with KASAN=y, since there is no good
reason to not do this.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/kasan.txt
lib/Kconfig.kasan
mm/slub.c

index 94c8815793744dd0f69ef3c7a59b4969e8ab549d..310746718f21e4efb63db3e1432640edb6dd8ce1 100644 (file)
@@ -28,8 +28,7 @@ the latter is 1.1 - 2 times faster. Inline instrumentation requires a GCC
 version 5.0 or later.
 
 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:
index 39f24d6721e5a29d8016811d4f5332fca66c2ec2..0fee5acd5aa09e2bd65ade1200cae5e48bacfa22 100644 (file)
@@ -15,8 +15,7 @@ config KASAN
          global variables requires gcc 5.0 or later.
          This feature consumes about 1/8 of available memory and brings about
          ~x3 performance slowdown.
-         For better error detection enable CONFIG_STACKTRACE,
-         and add slub_debug=U to boot cmdline.
+         For better error detection enable CONFIG_STACKTRACE.
 
 choice
        prompt "Instrumentation type"
index a44c40c03bddb7ae82c37f5ad1ba723d55c25b44..e7b486f182bd1d42cb4ddc5151a7d843a5dd6384 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -461,6 +461,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