diff mbox series

[lttng-tools,v3] Fix: use newly created event filter for condition check

Message ID 20190924152417.47028-1-jonathan.rajotte-julien@efficios.com
State Accepted, archived
Headers show
Series [lttng-tools,v3] Fix: use newly created event filter for condition check | expand

Commit Message

Jonathan Rajotte Sept. 24, 2019, 3:24 p.m. UTC
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/event.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jérémie Galarneau Sept. 25, 2019, 4:41 p.m. UTC | #1
Merged in master and stable-2.11.

Backported to stable-2.10, and stable-2.9.

Thanks!
J?r?mie

On Tue, Sep 24, 2019 at 11:24:17AM -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/event.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> 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
>
diff mbox series

Patch

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;
 		}