From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Jordan Rife <jrife@google.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Michael Jeanson <mjeanson@efficios.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Alexei Starovoitov <ast@kernel.org>, Yonghong Song <yhs@fb.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
bpf@vger.kernel.org, Joel Fernandes <joel@joelfernandes.org>
Subject: Re: [RFC PATCH v4 4/4] tracing: Add might_fault() check in __DO_TRACE() for syscall
Date: Mon, 28 Oct 2024 16:25:53 -0400 [thread overview]
Message-ID: <588eb8e1-5035-499f-b19b-8b40a9877433@efficios.com> (raw)
In-Reply-To: <CAEf4BzZgSPXyvtBZuB+W3fp=C8QYSHsd0TduxWE3Le+9e80-UA@mail.gmail.com>
On 2024-10-28 16:20, Andrii Nakryiko wrote:
> On Mon, Oct 28, 2024 at 12:59 PM Mathieu Desnoyers
> <mathieu.desnoyers@efficios.com> 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@linutronix.de>
>>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>> Cc: Michael Jeanson <mjeanson@efficios.com>
>>> Cc: Steven Rostedt <rostedt@goodmis.org>
>>> 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>
>>> Cc: Jordan Rife <jrife@google.com>
>>> ---
>>> 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
I'm still awaiting for Jordan (or someone else) to come back with
testing results before I feel confident dropping the RFC tag.
Thanks,
Mathieu
>
>>
>> Thanks,
>>
>> Mathieu
>>
>>> + } else { \
>>> preempt_disable_notrace(); \
>>> + } \
>>> \
>>> __DO_TRACE_CALL(name, TP_ARGS(args)); \
>>> \
>>
>> --
>> Mathieu Desnoyers
>> EfficiOS Inc.
>> https://www.efficios.com
>>
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2024-10-28 20:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 19:09 [RFC PATCH v4 0/4] Faultable syscall tracepoints updates Mathieu Desnoyers
2024-10-28 19:09 ` [RFC PATCH v4 1/4] tracing: Introduce tracepoint extended structure Mathieu Desnoyers
2024-10-28 19:09 ` [RFC PATCH v4 2/4] tracing: Introduce tracepoint_is_faultable() Mathieu Desnoyers
2024-10-28 20:19 ` Andrii Nakryiko
2024-10-28 20:24 ` Mathieu Desnoyers
2024-10-28 19:09 ` [RFC PATCH v4 3/4] tracing: Fix syscall tracepoint use-after-free Mathieu Desnoyers
2024-10-28 19:09 ` [RFC PATCH v4 4/4] tracing: Add might_fault() check in __DO_TRACE() for syscall Mathieu Desnoyers
2024-10-28 19:58 ` Mathieu Desnoyers
2024-10-28 20:20 ` Andrii Nakryiko
2024-10-28 20:25 ` Mathieu Desnoyers [this message]
2024-10-28 20:40 ` Jordan Rife
2024-10-29 0:28 ` Jordan Rife
2024-10-30 14:42 ` Mathieu Desnoyers
2024-10-30 14:59 ` Alexei Starovoitov
2024-10-30 17:34 ` Jordan Rife
2024-10-30 17:39 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=588eb8e1-5035-499f-b19b-8b40a9877433@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=joel@joelfernandes.org \
--cc=jrife@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=mjeanson@efficios.com \
--cc=namhyung@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®