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:46:12 +0000 (12:46 -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 8c6204c4d99352caa9ba567df11fcc97b3d2cb32..8bffdc406751a37b8a83369e0764bbab193d3cc6 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:
        {
@@ -1219,6 +1233,7 @@ int cmd_enable_event(struct ltt_session *session, int domain,
        ret = LTTNG_OK;
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
@@ -1235,6 +1250,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:
        {
@@ -1365,6 +1382,7 @@ int cmd_enable_event_all(struct ltt_session *session, int domain,
        ret = LTTNG_OK;
 
 error:
+       rcu_read_unlock();
        return ret;
 }
 
index cee61f764ce192350583154df8e40d808ef7edac..ef5e3e1f01b5e62977a48f116f8f2ceb3b72522b 100644 (file)
@@ -223,6 +223,8 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        struct lttng_ht *chan_ht;
        struct ltt_ust_channel *uchan = NULL;
 
+       rcu_read_lock();
+
        /*
         * Define which channel's hashtable to use from the domain or quit if
         * unknown domain.
@@ -285,5 +287,6 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        }
 
 error:
+       rcu_read_unlock();
        return ret;
 }
index 3d9390db22395885cc1f62e62c90bf9167040b93..801e8907758a7b8066e7dd9e85268c21a4adc36e 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.031199 seconds and 4 git commands to generate.