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 <[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] Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent a363d27 commit a3204c7

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

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)