From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Rafael Mendonca <rafaelmendsr@gmail.com>,
Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
Tom Zanussi <zanussi@kernel.org>
Subject: Re: [PATCH] tracing: Fix race where eprobes can be called before the event
Date: Fri, 18 Nov 2022 21:18:09 +0900 [thread overview]
Message-ID: <20221118211809.701d40c0f8a757b0df3c025a@kernel.org> (raw)
In-Reply-To: <20221117214249.2addbe10@gandalf.local.home>
On Thu, 17 Nov 2022 21:42:49 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> The flag that tells the event to call its triggers after reading the event
> is set for eprobes after the eprobe is enabled. This leads to a race where
> the eprobe may be triggered at the beginning of the event where the record
> information is NULL. The eprobe then dereferences the NULL record causing
> a NULL kernel pointer bug.
>
> Test for a NULL record to keep this from happening.
>
> Link: https://lore.kernel.org/linux-trace-kernel/20221116192552.1066630-1-rafaelmendsr@gmail.com/
This looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
BTW, would other trigger callbacks also need to add similar checks?
Thank you,
>
> Cc: stable@vger.kernel.org
> Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events")
> Reported-by: Rafael Mendonca <rafaelmendsr@gmail.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> kernel/trace/trace_eprobe.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> index 5dd0617e5df6..6b31b74954d9 100644
> --- a/kernel/trace/trace_eprobe.c
> +++ b/kernel/trace/trace_eprobe.c
> @@ -563,6 +563,9 @@ static void eprobe_trigger_func(struct event_trigger_data *data,
> {
> struct eprobe_data *edata = data->private_data;
>
> + if (unlikely(!rec))
> + return;
> +
> __eprobe_trace_func(edata, rec);
> }
>
> --
> 2.35.1
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2022-11-18 12:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 2:42 [PATCH] tracing: Fix race where eprobes can be called before the event Steven Rostedt
2022-11-18 12:18 ` Masami Hiramatsu [this message]
2022-11-23 21:02 ` Steven Rostedt
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=20221118211809.701d40c0f8a757b0df3c025a@kernel.org \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rafaelmendsr@gmail.com \
--cc=rostedt@goodmis.org \
--cc=tz.stoyanov@gmail.com \
--cc=zanussi@kernel.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).