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 <mjeanson@efficios.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Yonghong Song <yhs@fb.com> Cc: Paul E. McKenney <paulmck@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: bpf@vger.kernel.org Cc: Joel Fernandes <joel@joelfernandes.org> Link: https://lore.kernel.org/20241009010718.2050182-8-mathieu.desnoyers@efficios.com Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent a3204c7 commit cdb537a

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

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)