stack: Introduce CONFIG_RANDOMIZE_KSTACK_OFFSET
authorMarco Elver <elver@google.com>
Mon, 31 Jan 2022 09:05:20 +0000 (10:05 +0100)
committerKees Cook <keescook@chromium.org>
Mon, 14 Feb 2022 19:07:12 +0000 (11:07 -0800)
commit8cb37a5974a48569aab8a1736d21399fddbdbdb2
treeb7c766fc7e31649c8fabc0c53cefc6c278740ea1
parentae978009fc013e3166c9f523f8b17e41a3c0286e
stack: Introduce CONFIG_RANDOMIZE_KSTACK_OFFSET

The randomize_kstack_offset feature is unconditionally compiled in when
the architecture supports it.

To add constraints on compiler versions, we require a dedicated Kconfig
variable. Therefore, introduce RANDOMIZE_KSTACK_OFFSET.

Furthermore, this option is now also configurable by EXPERT kernels:
while the feature is supposed to have zero performance overhead when
disabled, due to its use of static branches, there are few cases where
giving a distribution the option to disable the feature entirely makes
sense. For example, in very resource constrained environments, which
would never enable the feature to begin with, in which case the
additional kernel code size increase would be redundant.

Signed-off-by: Marco Elver <elver@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220131090521.1947110-1-elver@google.com
arch/Kconfig
include/linux/randomize_kstack.h
init/main.c