Skip to content

Commit cdb537a

Browse files
compudjrostedt
authored andcommitted
tracing/perf: Add might_fault check to syscall probes
Add a might_fault() check to validate that the perf sys_enter/sys_exit probe callbacks are indeed called from a context where page faults can be handled. Cc: Michael Jeanson <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Yonghong Song <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: [email protected] Cc: Joel Fernandes <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent a3204c7 commit cdb537a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

include/trace/perf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ perf_trace_##call(void *__data, proto) \
8484
u64 __count __attribute__((unused)); \
8585
struct task_struct *__task __attribute__((unused)); \
8686
\
87+
might_fault(); \
8788
preempt_disable_notrace(); \
8889
do_perf_trace_##call(__data, args); \
8990
preempt_enable_notrace(); \

kernel/trace/trace_syscalls.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
602602
* Syscall probe called with preemption enabled, but the ring
603603
* buffer and per-cpu data require preemption to be disabled.
604604
*/
605+
might_fault();
605606
guard(preempt_notrace)();
606607

607608
syscall_nr = trace_get_syscall_nr(current, regs);
@@ -710,6 +711,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
710711
* Syscall probe called with preemption enabled, but the ring
711712
* buffer and per-cpu data require preemption to be disabled.
712713
*/
714+
might_fault();
713715
guard(preempt_notrace)();
714716

715717
syscall_nr = trace_get_syscall_nr(current, regs);

0 commit comments

Comments
 (0)