Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: jonathan.rajotte-julien@efficios.com (Jonathan Rajotte-Julien)
Subject: [lttng-dev] [PATCH lttng-tools v2] Fix: use newly created event filter for condition check
Date: Tue, 24 Sep 2019 11:23:05 -0400	[thread overview]
Message-ID: <20190924152305.GJ187569@joraj-alpa> (raw)
In-Reply-To: <20190924152114.45975-1-jonathan.rajotte-julien@efficios.com>

Do not review, this include a change that should not be part of this commit.

On Tue, Sep 24, 2019 at 11:21:14AM -0400, Jonathan Rajotte wrote:
> The following commit introduced a regression while
> fixing the filter and filter_expression ownership.
> 
> commit b0a23296344e57bd2e48e62ec2d7e0d8a38661bb
> Author: J?r?mie Galarneau <jeremie.galarneau at efficios.com>
> Date:   Sat Jan 12 14:53:56 2019 -0500
> 
>     Fix: leak of filter bytecode and expression on agent event re-enable
> 
>     The agent subsystem does not properly assume the clean-up of an
>     event's filter bytecode and expression when a previously disabled
>     event is re-enabled.
> 
>     This change ensures that the ownership of both the filter bytecode
>     and expression is assumed by the agent subsystem and discarded
>     when a matching event is found.
> 
>     Steps to reproduce the leak:
>     $ lttng create
>     $ lttng enable-event --python allo --filter 'a[42] == 241'
>     $ lttng disable-event --python allo
>     $ lttng enable-event --python allo --filter 'a[42] == 241'
> 
>     Signed-off-by: J?r?mie Galarneau <jeremie.galarneau at efficios.com>
> 
> Setting the "filter" object to NULL prevents the call to
> add_filter_app_ctx when needed.
> 
> We use the filter from the newly created event to
> perform the check and the call to add_filter_app_ctx.
> 
> Fixes coverity #1399733
> 
> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
>  src/bin/lttng-sessiond/agent.c | 1 +
>  src/bin/lttng-sessiond/event.c | 5 +++--
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c
> index 9ea899f57..79233ab7c 100644
> --- a/src/bin/lttng-sessiond/agent.c
> +++ b/src/bin/lttng-sessiond/agent.c
> @@ -1145,6 +1145,7 @@ struct agent_event *agent_create_event(const char *name,
>  	event->loglevel_type = loglevel_type;
>  	event->filter = filter;
>  	event->filter_expression = filter_expression;
> +	event->enabled = 0;
>  error:
>  	return event;
>  }
> diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c
> index f32db4429..a8b7646da 100644
> --- a/src/bin/lttng-sessiond/event.c
> +++ b/src/bin/lttng-sessiond/event.c
> @@ -513,8 +513,9 @@ int event_agent_enable(struct ltt_ust_session *usess,
>  		created = 1;
>  	}
>  
> -	if (created && filter) {
> -		ret = add_filter_app_ctx(filter, filter_expression, agt);
> +	if (created && aevent->filter) {
> +		ret = add_filter_app_ctx(
> +				aevent->filter, aevent->filter_expression, agt);
>  		if (ret != LTTNG_OK) {
>  			goto error;
>  		}
> -- 
> 2.17.1
> 

-- 
Jonathan Rajotte-Julien
EfficiOS


      reply	other threads:[~2019-09-24 15:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24 15:21 Jonathan Rajotte
2019-09-24 15:23 ` Jonathan Rajotte-Julien [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=20190924152305.GJ187569@joraj-alpa \
    --to=jonathan.rajotte-julien@efficios.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