Skip to content

Commit 491a786

Browse files
hcahcaVasily Gorbik
authored andcommitted
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>
1 parent ccf7c3f commit 491a786

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

kernel/stackleak.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ late_initcall(stackleak_sysctls_init);
7070
#define skip_erasing() false
7171
#endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */
7272

73+
#ifndef __stackleak_poison
74+
static __always_inline void __stackleak_poison(unsigned long erase_low,
75+
unsigned long erase_high,
76+
unsigned long poison)
77+
{
78+
while (erase_low < erase_high) {
79+
*(unsigned long *)erase_low = poison;
80+
erase_low += sizeof(unsigned long);
81+
}
82+
}
83+
#endif
84+
7385
static __always_inline void __stackleak_erase(bool on_task_stack)
7486
{
7587
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)
101113
else
102114
erase_high = task_stack_high;
103115

104-
while (erase_low < erase_high) {
105-
*(unsigned long *)erase_low = STACKLEAK_POISON;
106-
erase_low += sizeof(unsigned long);
107-
}
116+
__stackleak_poison(erase_low, erase_high, STACKLEAK_POISON);
108117

109118
/* Reset the 'lowest_stack' value for the next syscall */
110119
current->lowest_stack = task_stack_high;

0 commit comments

Comments
 (0)