Skip to content

Commit ef1a840

Browse files
a13xp0p0vkees
authored andcommitted
stackleak: Disable function tracing and kprobes for stackleak_erase()
The stackleak_erase() function is called on the trampoline stack at the end of syscall. This stack is not big enough for ftrace and kprobes operations, e.g. it can be exhausted if we use kprobe_events for stackleak_erase(). So let's disable function tracing and kprobes of stackleak_erase(). Reported-by: kernel test robot <[email protected]> Fixes: 10e9ae9 ("gcc-plugins: Add STACKLEAK plugin for tracking the kernel stack") Signed-off-by: Alexander Popov <[email protected]> Reviewed-by: Steven Rostedt (VMware) <[email protected]> Reviewed-by: Masami Hiramatsu <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent ccda4af commit ef1a840

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/stackleak.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include <linux/stackleak.h>
14+
#include <linux/kprobes.h>
1415

1516
#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
1617
#include <linux/jump_label.h>
@@ -47,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write,
4748
#define skip_erasing() false
4849
#endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */
4950

50-
asmlinkage void stackleak_erase(void)
51+
asmlinkage void notrace stackleak_erase(void)
5152
{
5253
/* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */
5354
unsigned long kstack_ptr = current->lowest_stack;
@@ -101,6 +102,7 @@ asmlinkage void stackleak_erase(void)
101102
/* Reset the 'lowest_stack' value for the next syscall */
102103
current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64;
103104
}
105+
NOKPROBE_SYMBOL(stackleak_erase);
104106

105107
void __used stackleak_track_stack(void)
106108
{

0 commit comments

Comments
 (0)