Skip to content

Commit a3204c7

Browse files
compudjrostedt
authored andcommitted
tracing/ftrace: Add might_fault check to syscall probes
Add a might_fault() check to validate that the ftrace 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-7-mathieu.desnoyers@efficios.com Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent a363d27 commit a3204c7

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

include/trace/trace_events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ __DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), PARAMS(tstruct), \
446446
static notrace void \
447447
trace_event_raw_event_##call(void *__data, proto) \
448448
{ \
449+
might_fault(); \
449450
preempt_disable_notrace(); \
450451
do_trace_event_raw_event_##call(__data, args); \
451452
preempt_enable_notrace(); \

kernel/trace/trace_syscalls.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
303303
* Syscall probe called with preemption enabled, but the ring
304304
* buffer and per-cpu data require preemption to be disabled.
305305
*/
306+
might_fault();
306307
guard(preempt_notrace)();
307308

308309
syscall_nr = trace_get_syscall_nr(current, regs);
@@ -348,6 +349,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
348349
* Syscall probe called with preemption enabled, but the ring
349350
* buffer and per-cpu data require preemption to be disabled.
350351
*/
352+
might_fault();
351353
guard(preempt_notrace)();
352354

353355
syscall_nr = trace_get_syscall_nr(current, regs);

0 commit comments

Comments
 (0)