On Mon, Oct 28, 2024 at 12:59 PM Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> wrote: > > On 2024-10-28 15:09, Mathieu Desnoyers wrote: > > Catch incorrect use of syscall tracepoints even if no probes are > > registered by adding a might_fault() check in __DO_TRACE() when > > syscall=1. > > > > Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > > Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> > > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > > Cc: Michael Jeanson <mjeanson@xxxxxxxxxxxx> > > Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> > > Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx> > > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> > > Cc: Alexei Starovoitov <ast@xxxxxxxxxx> > > Cc: Yonghong Song <yhs@xxxxxx> > > Cc: Paul E. McKenney <paulmck@xxxxxxxxxx> > > Cc: Ingo Molnar <mingo@xxxxxxxxxx> > > Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> > > Cc: Mark Rutland <mark.rutland@xxxxxxx> > > Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx> > > Cc: Namhyung Kim <namhyung@xxxxxxxxxx> > > Cc: Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> > > Cc: bpf@xxxxxxxxxxxxxxx > > Cc: Joel Fernandes <joel@xxxxxxxxxxxxxxxxx> > > Cc: Jordan Rife <jrife@xxxxxxxxxx> > > --- > > include/linux/tracepoint.h | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h > > index 259f0ab4ece6..7bed499b7055 100644 > > --- a/include/linux/tracepoint.h > > +++ b/include/linux/tracepoint.h > > @@ -226,10 +226,12 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > > if (!(cond)) \ > > return; \ > > \ > > - if (syscall) \ > > + if (syscall) { \ > > rcu_read_lock_trace(); \ > > - else \ > > + might_fault(); \ > > Actually, __DO_TRACE() is not the best place to put this, because it's > only executed when the tracepoint is enabled. > > I'll move this to __DECLARE_TRACE_SYSCALL() > > #define __DECLARE_TRACE_SYSCALL(name, proto, args, cond, data_proto) \ > __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), cond, PARAMS(data_proto)) \ > static inline void trace_##name(proto) \ > { \ > might_fault(); \ > if (static_branch_unlikely(&__tracepoint_##name.key)) \ > __DO_TRACE(name, \ > TP_ARGS(args), \ > TP_CONDITION(cond), 1); \ > [...] > > instead in v5. please drop the RFC tag while at it > > Thanks, > > Mathieu > > > + } else { \ > > preempt_disable_notrace(); \ > > + } \ > > \ > > __DO_TRACE_CALL(name, TP_ARGS(args)); \ > > \ > > -- > Mathieu Desnoyers > EfficiOS Inc. > https://www.efficios.com >