Fix: add missing rcu lock for UST lookup
authorDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 17:13:13 +0000 (12:13 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 17:42:33 +0000 (12:42 -0500)
Trace UST channel and event were not protected by RCU lock when calling
their find function. Furthermore, the event lookup was not protected at
all during and after the lookup.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/context.c
src/bin/lttng-sessiond/trace-ust.c

index 5ec65b78637beaf0904a1c32ef1d25377dbcdc11..456ddeb77d85fd4d1a6f70ca7116494435a12b5e 100644 (file)
@@ -766,6 +766,8 @@ int cmd_disable_channel(struct ltt_session *session, int domain,
 
        usess = session->ust_session;
 
+       rcu_read_lock();
+
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -810,6 +812,7 @@ int cmd_disable_channel(struct ltt_session *session, int domain,
        ret = LTTNG_OK;
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
@@ -830,6 +833,8 @@ int cmd_enable_channel(struct ltt_session *session,
 
        DBG("Enabling channel %s for session %s", attr->name, session->name);
 
+       rcu_read_lock();
+
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -898,6 +903,7 @@ int cmd_enable_channel(struct ltt_session *session,
        }
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
@@ -910,6 +916,8 @@ int cmd_disable_event(struct ltt_session *session, int domain,
 {
        int ret;
 
+       rcu_read_lock();
+
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -968,6 +976,7 @@ int cmd_disable_event(struct ltt_session *session, int domain,
        ret = LTTNG_OK;
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
@@ -979,6 +988,8 @@ int cmd_disable_event_all(struct ltt_session *session, int domain,
 {
        int ret;
 
+       rcu_read_lock();
+
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -1037,6 +1048,7 @@ int cmd_disable_event_all(struct ltt_session *session, int domain,
        ret = LTTNG_OK;
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
@@ -1126,6 +1138,8 @@ int cmd_enable_event(struct ltt_session *session, int domain,
        assert(event);
        assert(channel_name);
 
+       rcu_read_lock();
+
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -1224,6 +1238,7 @@ int cmd_enable_event(struct ltt_session *session, int domain,
        ret = LTTNG_OK;
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
@@ -1240,6 +1255,8 @@ int cmd_enable_event_all(struct ltt_session *session, int domain,
        assert(session);
        assert(channel_name);
 
+       rcu_read_lock();
+
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
        {
@@ -1371,6 +1388,7 @@ int cmd_enable_event_all(struct ltt_session *session, int domain,
        ret = LTTNG_OK;
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
index c1b7410da00020dc541313326892d850e6810b28..46e1b344612e1f8af58a1117ec214c112b0a05b3 100644 (file)
@@ -241,6 +241,8 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        assert(ctx);
        assert(channel_name);
 
+       rcu_read_lock();
+
        /*
         * Define which channel's hashtable to use from the domain or quit if
         * unknown domain.
@@ -303,5 +305,6 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        }
 
 error:
+       rcu_read_unlock();
        return ret;
 }
index 81cb4db63180216b76d42ab3f628788525c06d89..e07d27e678b93c718ff3dee1378706b3382a3692 100644 (file)
@@ -116,7 +116,8 @@ no_match:
 }
 
 /*
- * Find the channel in the hashtable.
+ * Find the channel in the hashtable and return channel pointer. RCU read side
+ * lock MUST be acquired before calling this.
  */
 struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
                char *name)
@@ -124,14 +125,11 @@ struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
        struct lttng_ht_node_str *node;
        struct lttng_ht_iter iter;
 
-       rcu_read_lock();
        lttng_ht_lookup(ht, (void *)name, &iter);
        node = lttng_ht_iter_get_node_str(&iter);
        if (node == NULL) {
-               rcu_read_unlock();
                goto error;
        }
-       rcu_read_unlock();
 
        DBG2("Trace UST channel %s found by name", name);
 
@@ -143,7 +141,8 @@ error:
 }
 
 /*
- * Find the event in the hashtable.
+ * Find the event in the hashtable and return event pointer. RCU read side lock
+ * MUST be acquired before calling this.
  */
 struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht,
                char *name, struct lttng_filter_bytecode *filter, int loglevel)
This page took 0.030297 seconds and 5 git commands to generate.