From 49276f7c85ba1c140b2605b816a2596d02b36ba4 Mon Sep 17 00:00:00 2001 From: Yifan Feng Date: Tue, 17 Nov 2026 16:32:05 -0800 Subject: tracing/fprobe: Do not let KASAN check the $stackN read ftrace_regs_get_kernel_stack_nth() reads the Nth entry of the kernel stack for the $stackN argument of fprobe and tracepoint probe events. That entry can be in the redzone of another stack frame, so with CONFIG_KASAN_STACK every hit of such an event is reported: # echo 'f:fp_read vfs_read $stack10' >> dynamic_events # echo 1 > events/fprobes/fp_read/enable BUG: KASAN: stack-out-of-bounds in process_fetch_insn+0xac9/0xcb0 Use READ_ONCE_NOCHECK(), as arm64 does in regs_get_kernel_stack_nth() for kprobe events. Link: https://lore.kernel.org/all/20261118003205.59804-1-evanfengff@gmail.com/ Fixes: 0566cefe73b9 ("tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS") Signed-off-by: Yifan Feng Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 1c2056a1a68b..bdb6ee6bc3b9 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -270,7 +270,7 @@ ftrace_regs_get_kernel_stack_nth(struct ftrace_regs *fregs, unsigned int nth) stackp = (unsigned long *)ftrace_regs_get_stack_pointer(fregs); if (((unsigned long)(stackp + nth) & ~(THREAD_SIZE - 1)) == ((unsigned long)stackp & ~(THREAD_SIZE - 1))) - return *(stackp + nth); + return READ_ONCE_NOCHECK(*(stackp + nth)); return 0; } -- cgit v1.2.3