Skip to contentSkip to conversation

Fix: sessiond: ht_match_event(): check if filter is NULL

PATCH Mathieu Desnoyers 2 participants 2 messages Jun 18, 2016 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Received: from jsutto (cable-192.222.213.99.electronicbox.net.

host mtl.efficios.com
mtl.efficios.com has address 192.222.213.99

Nice try Phil. ;-)

We'll need the actual contributor name to merge this contribution however. I'm pretty sure there is no Mrs. Sutto at EfficiOS.

Thanks,

Mathieu

Quoted 49 lines · ----- On Jun 15, 2016, at 5:34 PM, Janine Sutto [email protected] wrote:

It looks like an agent event's filter expression is NULL when it's created with -a, for example:

lttng enable-event -j -a

Since there's no check for this in ht_match_event(), strlen() makes the session daemon segfault with this scenario:

lttng create
lttng enable-event -j -a
lttng disable-event -j -a

---
src/bin/lttng-sessiond/agent.c | 11 +++++++++--

1 file changed, 9 insertions(+), 2 deletions(-)
src/bin/lttng-sessiond/agent.c +9 -2
index 8e1ef08..7cbbbde 100644
@@ -143,11 +143,18 @@ static int ht_match_event(struct cds_lfht_node *node,
 	}
 
 	/* Filter expression */
-	if (strncmp(event->filter_expression, key->filter_expression,
-			strlen(event->filter_expression)) != 0) {
+	if (!!event->filter_expression ^ !!key->filter_expression) {
+		/* One has a filter expression, the other does not */
 		goto no_match;
 	}
 
+	if (event->filter_expression) {
+		if (strncmp(event->filter_expression, key->filter_expression,
+				strlen(event->filter_expression)) != 0) {
+			goto no_match;
+		}
+	}
+
 	return 1;
 

no_match:
--
2.8.3

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 7 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Oh, Janine hijacked my workstation again!

Philippe Proulx

Quoted 70 lines · Mathieu Desnoyers

Received: from jsutto (cable-192.222.213.99.electronicbox.net.

host mtl.efficios.com
mtl.efficios.com has address 192.222.213.99

Nice try Phil. ;-)

We'll need the actual contributor name to merge this contribution however. I'm pretty sure there is no Mrs. Sutto at EfficiOS.

Thanks,

Mathieu

----- On Jun 15, 2016, at 5:34 PM, Janine Sutto [email protected]

Quoted 12 lines · wrote:

It looks like an agent event's filter expression is NULL when it's created with -a, for example:

lttng enable-event -j -a

Since there's no check for this in ht_match_event(), strlen() makes the session daemon segfault with this scenario:

lttng create
lttng enable-event -j -a
lttng disable-event -j -a

Review

Quoted 6 lines

---
src/bin/lttng-sessiond/agent.c | 11 +++++++++--

1 file changed, 9 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/src/bin/lttng-sessiond/agent.c

src/bin/lttng-sessiond/agent.c static int ht_match_event(struct cds_lfht_node

Quoted 4 lines

index 8e1ef08..7cbbbde 100644

src/bin/lttng-sessiond/agent.c +0 -0
@@ -143,11 +143,18 @@ static int ht_match_event(struct cds_lfht_node

*node,

src/bin/lttng-sessiond/agent.c static int ht_match_event(struct cds_lfht_node · line 152

Quoted 12 lines
src/bin/lttng-sessiond/agent.c +4 -2
      }
 
      /* Filter expression */
-     if (strncmp(event->filter_expression, key->filter_expression,
-                     strlen(event->filter_expression)) != 0) {
+     if (!!event->filter_expression ^ !!key->filter_expression) {
+             /* One has a filter expression, the other does not */
              goto no_match;
      }
 
+     if (event->filter_expression) {
+             if (strncmp(event->filter_expression,

key->filter_expression,

Quoted 11 lines
src/bin/lttng-sessiond/agent.c +5 -0
+                             strlen(event->filter_expression)) != 0) {
+                     goto no_match;
+             }
+     }
+
      return 1;
 

no_match:
--
2.8.3

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Quoted 9 lines

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev