From: Steven Rostedt <rostedt@goodmis.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Tom Zanussi <tom.zanussi@linux.intel.com>,
Hiraku Toyooka <hiraku.toyooka@cybertrust.co.jp>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] tracing: Fix double free of event_trigger_data
Date: Wed, 25 Jul 2018 15:29:04 -0400 [thread overview]
Message-ID: <20180725152904.11edde2b@gandalf.local.home> (raw)
In-Reply-To: <20180725124008.7008e586@gandalf.local.home>
On Wed, 25 Jul 2018 12:40:08 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> Hmm, looks to me that event_enable_trigger_func() suffers the same
> issue. Perhaps we should add this patch too:
>
> -- Steve
>
> diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
> index d18ec0e58be2..2681d917f896 100644
> --- a/kernel/trace/trace_events_trigger.c
> +++ b/kernel/trace/trace_events_trigger.c
> @@ -1457,6 +1457,10 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
> ret = trace_event_enable_disable(event_enable_file, 1, 1);
> if (ret < 0)
> goto out_put;
> +
> + /* Up the trigger_data count to make sure reg doesn't free it on failure */
> + event_trigger_init(trigger_ops, trigger_data);
> +
> ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file);
> /*
> * The above returns on success the # of functions enabled,
> @@ -1464,12 +1468,13 @@ int event_enable_trigger_func(struct event_command *cmd_ops,
> * Consider no functions a failure too.
> */
> if (!ret) {
> + cmd_ops->unreg(glob, trigger_ops, trigger_data, file);
> ret = -ENOENT;
> - goto out_disable;
> - } else if (ret < 0)
> - goto out_disable;
> - /* Just return zero, not the number of enabled functions */
> - ret = 0;
> + } else if (ret > 0)
> + ret = 0;
> +
> + /* Down the counter of trigger_data or free it if not used anymore */
> + event_trigger_free(trigger_ops, trigger_data);
Nope, this doesn't work. It's a little more complex than the other one.
I'll just leave it, and fix the reg code for 4.19.
-- Steve
> out:
> return ret;
>
next prev parent reply other threads:[~2018-07-25 19:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 12:57 [PATCH] tracing: Fix double free of event_trigger_data Steven Rostedt
2018-07-25 15:43 ` Masami Hiramatsu
2018-07-25 16:40 ` Steven Rostedt
2018-07-25 19:29 ` Steven Rostedt [this message]
2018-07-25 19:53 ` Steven Rostedt
2018-07-25 22:51 ` Masami Hiramatsu
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=20180725152904.11edde2b@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=hiraku.toyooka@cybertrust.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=tom.zanussi@linux.intel.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;
as well as URLs for NNTP newsgroup(s).