From e7fe706f887aa4d753b102a610f802f7dd816655 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 22 Jan 2013 11:40:13 -0500 Subject: [PATCH] Fix: add missing rcu read side lock Signed-off-by: David Goulet --- src/bin/lttng-sessiond/cmd.c | 8 ++++++++ src/bin/lttng-sessiond/context.c | 6 ++++++ src/bin/lttng-sessiond/main.c | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index ff418e17e..3a70d4869 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -152,6 +152,7 @@ static void list_lttng_channels(int domain, struct ltt_session *session, struct lttng_ht_iter iter; struct ltt_ust_channel *uchan; + rcu_read_lock(); cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht, &iter.iter, uchan, node.node) { strncpy(channels[i].name, uchan->name, LTTNG_SYMBOL_NAME_LEN); @@ -171,6 +172,7 @@ static void list_lttng_channels(int domain, struct ltt_session *session, } i++; } + rcu_read_unlock(); break; } default: @@ -433,6 +435,8 @@ static int init_kernel_tracing(struct ltt_kernel_session *session) assert(session); + rcu_read_lock(); + if (session->consumer_fds_sent == 0 && session->consumer != NULL) { cds_lfht_for_each_entry(session->consumer->socks->ht, &iter.iter, socket, node.node) { @@ -450,6 +454,7 @@ static int init_kernel_tracing(struct ltt_kernel_session *session) } error: + rcu_read_unlock(); return ret; } @@ -643,6 +648,8 @@ static int setup_relayd(struct ltt_session *session) DBG2("Setting relayd for session %s", session->name); + rcu_read_lock(); + if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET && usess->consumer->enabled) { /* For each consumer socket, send relayd sockets */ @@ -679,6 +686,7 @@ static int setup_relayd(struct ltt_session *session) } error: + rcu_read_unlock(); return ret; } diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 74afd4e0c..cee61f764 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -108,16 +108,20 @@ static int add_uctx_to_channel(struct ltt_ust_session *usess, int domain, goto error; } + rcu_read_lock(); + /* Lookup context before adding it */ lttng_ht_lookup(uchan->ctx, (void *)((unsigned long)uctx->ctx.ctx), &iter); uctx_node = lttng_ht_iter_get_node_ulong(&iter); if (uctx_node != NULL) { ret = -EEXIST; + rcu_read_unlock(); goto error; } /* Add ltt UST context node to ltt UST channel */ lttng_ht_add_unique_ulong(uchan->ctx, &uctx->node); + rcu_read_unlock(); DBG("Context UST %d added to channel %s", uctx->ctx.ctx, uchan->name); @@ -250,6 +254,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, /* Add ctx to channel */ ret = add_uctx_to_channel(usess, domain, uchan, ctx); } else { + rcu_read_lock(); /* Add ctx all events, all channels */ cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) { ret = add_uctx_to_channel(usess, domain, uchan, ctx); @@ -258,6 +263,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, continue; } } + rcu_read_unlock(); } switch (ret) { diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index e5a22460f..339b20d3e 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -638,7 +638,7 @@ static int update_kernel_stream(struct consumer_data *consumer_data, int fd) struct lttng_ht_iter iter; struct consumer_socket *socket; - + rcu_read_lock(); cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter, socket, node.node) { /* Code flow error */ @@ -649,9 +649,11 @@ static int update_kernel_stream(struct consumer_data *consumer_data, int fd) channel, ksess); pthread_mutex_unlock(socket->lock); if (ret < 0) { + rcu_read_unlock(); goto error; } } + rcu_read_unlock(); } goto error; } -- 2.34.1