[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <843484l2uj.fsf@jogness.linutronix.de>
Date: Tue, 30 Sep 2025 11:19:56 +0206
From: John Ogness <john.ogness@...utronix.de>
To: chenyuan_fl@....com, rostedt@...dmis.org, peterz@...radead.org
Cc: bigeasy@...utronix.de, chenyuan@...inos.cn,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
mathieu.desnoyers@...icios.com, mhiramat@...nel.org
Subject: Re: [PATH v3] tracing: Fix race condition in kprobe initialization
causing NULL pointer dereference
On 2025-09-30, chenyuan_fl@....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
Powered by blists - more mailing lists