diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2023-04-05 15:08:40 +0200 |
---|---|---|
committer | Vasily Gorbik <gor@linux.ibm.com> | 2023-04-20 11:36:35 +0200 |
commit | 491a78663e039fabc58c892ca8f2c2e08caaf4f8 (patch) | |
tree | 2c4ae50cfbe10e680a68e7fc1b19985af60dffa0 /kernel | |
parent | s390: select ARCH_USE_SYM_ANNOTATIONS (diff) | |
download | linux-491a78663e039fabc58c892ca8f2c2e08caaf4f8.tar.xz linux-491a78663e039fabc58c892ca8f2c2e08caaf4f8.zip |
stackleak: allow to specify arch specific stackleak poison function
Factor out the code that fills the stack with the stackleak poison value
in order to allow architectures to provide a faster implementation.
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20230405130841.1350565-2-hca@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/stackleak.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/kernel/stackleak.c b/kernel/stackleak.c index c2c33d2202e9..34c9d81eea94 100644 --- a/kernel/stackleak.c +++ b/kernel/stackleak.c @@ -70,6 +70,18 @@ late_initcall(stackleak_sysctls_init); #define skip_erasing() false #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ +#ifndef __stackleak_poison +static __always_inline void __stackleak_poison(unsigned long erase_low, + unsigned long erase_high, + unsigned long poison) +{ + while (erase_low < erase_high) { + *(unsigned long *)erase_low = poison; + erase_low += sizeof(unsigned long); + } +} +#endif + static __always_inline void __stackleak_erase(bool on_task_stack) { const unsigned long task_stack_low = stackleak_task_low_bound(current); @@ -101,10 +113,7 @@ static __always_inline void __stackleak_erase(bool on_task_stack) else erase_high = task_stack_high; - while (erase_low < erase_high) { - *(unsigned long *)erase_low = STACKLEAK_POISON; - erase_low += sizeof(unsigned long); - } + __stackleak_poison(erase_low, erase_high, STACKLEAK_POISON); /* Reset the 'lowest_stack' value for the next syscall */ current->lowest_stack = task_stack_high; |