From: John Ogness <john.ogness@linutronix.de>
To: chenyuan_fl@163.com, rostedt@goodmis.org, peterz@infradead.org
Cc: bigeasy@linutronix.de, chenyuan@kylinos.cn,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
mathieu.desnoyers@efficios.com, mhiramat@kernel.org
Subject: Re: [PATH v3] tracing: Fix race condition in kprobe initialization causing NULL pointer dereference
Date: Tue, 30 Sep 2025 11:19:56 +0206 [thread overview]
Message-ID: <843484l2uj.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20250930081848.433648-1-chenyuan_fl@163.com>
On 2025-09-30, chenyuan_fl@163.com wrote:
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index 842383fbc03b..98b838591edc 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -274,19 +274,19 @@ struct event_file_link {
> static inline bool trace_probe_test_flag(struct trace_probe *tp,
> unsigned int flag)
> {
> - return !!(tp->event->flags & flag);
> + return !!(smp_load_acquire(&tp->event->flags) & flag);
> }
>
> static inline void trace_probe_set_flag(struct trace_probe *tp,
> unsigned int flag)
> {
> - tp->event->flags |= flag;
> + smp_store_release(&tp->event->flags, tp->event->flags | flag);
> }
>
> static inline void trace_probe_clear_flag(struct trace_probe *tp,
> unsigned int flag)
> {
> - tp->event->flags &= ~flag;
> + smp_store_release(&tp->event->flags, tp->event->flags & ~flag);
> }
>
> static inline bool trace_probe_is_enabled(struct trace_probe *tp)
I don't have any feedback about the correctness with regards to tracing
and kprobes. However, I recommend writing a comment at each necessary
memory barrier site. The comment should mention the pairing memory
barrier and the ordering it is guaranteeing.
John
prev parent reply other threads:[~2025-09-30 9:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 3:11 [PATCH] tracing: Fix race condition in kprobe initialization causing NULL pointer dereference chenyuan_fl
2025-09-29 5:39 ` Masami Hiramatsu
2025-09-29 6:57 ` [PATCH v2] " chenyuan_fl
2025-09-29 8:48 ` Steven Rostedt
2025-09-29 9:12 ` Peter Zijlstra
2025-09-29 9:32 ` John Ogness
2025-09-29 10:12 ` Peter Zijlstra
2025-09-30 8:58 ` Masami Hiramatsu
2025-09-30 10:10 ` Peter Zijlstra
2025-09-30 15:37 ` Masami Hiramatsu
2025-09-30 8:18 ` [PATH v3] " chenyuan_fl
2025-09-30 8:46 ` Peter Zijlstra
2025-09-30 15:37 ` Masami Hiramatsu
2025-10-01 2:20 ` [PATCH v4] " chenyuan_fl
2025-10-01 12:32 ` Peter Zijlstra
2025-10-01 14:31 ` Steven Rostedt
2025-10-01 22:59 ` Masami Hiramatsu
2025-10-02 14:04 ` Masami Hiramatsu
2025-10-01 23:23 ` Masami Hiramatsu
2025-09-30 9:13 ` John Ogness [this message]
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=843484l2uj.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=chenyuan@kylinos.cn \
--cc=chenyuan_fl@163.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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;
as well as URLs for NNTP newsgroup(s).