From 7660a6fddcbae344de8583aa4092071312f110c3 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 6 Jul 2017 15:36:40 -0700 Subject: mm: allow slab_nomerge to be set at build time Some hardened environments want to build kernels with slab_nomerge already set (so that they do not depend on remembering to set the kernel command line option). This is desired to reduce the risk of kernel heap overflows being able to overwrite objects from merged caches and changes the requirements for cache layout control, increasing the difficulty of these attacks. By keeping caches unmerged, these kinds of exploits can usually only damage objects in the same cache (though the risk to metadata exploitation is unchanged). Link: http://lkml.kernel.org/r/20170620230911.GA25238@beast Signed-off-by: Kees Cook Cc: Daniel Micay Cc: David Windsor Cc: Eric Biggers Cc: Christoph Lameter Cc: Jonathan Corbet Cc: Daniel Micay Cc: David Windsor Cc: Eric Biggers Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: "Rafael J. Wysocki" Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Mauro Carvalho Chehab Cc: "Paul E. McKenney" Cc: Arnd Bergmann Cc: Andy Lutomirski Cc: Nicolas Pitre Cc: Tejun Heo Cc: Daniel Mack Cc: Sebastian Andrzej Siewior Cc: Sergey Senozhatsky Cc: Helge Deller Cc: Rik van Riel Cc: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- init/Kconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'init') diff --git a/init/Kconfig b/init/Kconfig index b0fcbb2c6f56..8514b25db21c 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1548,6 +1548,20 @@ config SLOB endchoice +config SLAB_MERGE_DEFAULT + bool "Allow slab caches to be merged" + default y + help + For reduced kernel memory fragmentation, slab caches can be + merged when they share the same size and other characteristics. + This carries a risk of kernel heap overflows being able to + overwrite objects from merged caches (and more easily control + cache layout), which makes such heap attacks easier to exploit + by attackers. By keeping caches unmerged, these kinds of exploits + can usually only damage objects in the same cache. To disable + merging at runtime, "slab_nomerge" can be passed on the kernel + command line. + config SLAB_FREELIST_RANDOM default n depends on SLAB || SLUB -- cgit v1.2.3