aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Ryabinin <aryabinin@virtuozzo.com>2015-11-05 21:51:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-05 22:34:48 -0500
commit89d3c87e20d95e3238eac85e43de7b3cb1f39d8b (patch)
tree9c680ae573229c1908986e853c3eca1c3132fe28
parent10f702627e139e21465f4c9d44f63527bbca163c (diff)
mm, slub, kasan: enable user tracking by default with KASAN=y
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. [akpm@linux-foundation.org: little fixes, per David] 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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/kasan.txt3
-rw-r--r--lib/Kconfig.kasan3
-rw-r--r--mm/slub.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/Documentation/kasan.txt b/Documentation/kasan.txt
index 94c881579374..aa1e0c91e368 100644
--- a/Documentation/kasan.txt
+++ b/Documentation/kasan.txt
@@ -28,8 +28,7 @@ the latter is 1.1 - 2 times faster. Inline instrumentation requires a GCC
28version 5.0 or later. 28version 5.0 or later.
29 29
30Currently KASAN works only with the SLUB memory allocator. 30Currently KASAN works only with the SLUB memory allocator.
31For better bug detection and nicer report, enable CONFIG_STACKTRACE and put 31For better bug detection and nicer reporting, enable CONFIG_STACKTRACE.
32at least 'slub_debug=U' in the boot cmdline.
33 32
34To disable instrumentation for specific files or directories, add a line 33To disable instrumentation for specific files or directories, add a line
35similar to the following to the respective kernel Makefile: 34similar to the following to the respective kernel Makefile:
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index 39f24d6721e5..0fee5acd5aa0 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -15,8 +15,7 @@ config KASAN
15 global variables requires gcc 5.0 or later. 15 global variables requires gcc 5.0 or later.
16 This feature consumes about 1/8 of available memory and brings about 16 This feature consumes about 1/8 of available memory and brings about
17 ~x3 performance slowdown. 17 ~x3 performance slowdown.
18 For better error detection enable CONFIG_STACKTRACE, 18 For better error detection enable CONFIG_STACKTRACE.
19 and add slub_debug=U to boot cmdline.
20 19
21choice 20choice
22 prompt "Instrumentation type" 21 prompt "Instrumentation type"
diff --git a/mm/slub.c b/mm/slub.c
index 423dbe77d145..75a5fa92ac2a 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -459,8 +459,10 @@ static void get_map(struct kmem_cache *s, struct page *page, unsigned long *map)
459/* 459/*
460 * Debug settings: 460 * Debug settings:
461 */ 461 */
462#ifdef CONFIG_SLUB_DEBUG_ON 462#if defined(CONFIG_SLUB_DEBUG_ON)
463static int slub_debug = DEBUG_DEFAULT_FLAGS; 463static int slub_debug = DEBUG_DEFAULT_FLAGS;
464#elif defined(CONFIG_KASAN)
465static int slub_debug = SLAB_STORE_USER;
464#else 466#else
465static int slub_debug; 467static int slub_debug;
466#endif 468#endif