Fix: missing rcu read locking in trigger "unregister all" command
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-events.c
index ba4e5a057eb79464835a0ae159fbc0d1f2cf3091..052689a0ebd8439dbf11db0172df7eb520c68605 100644 (file)
@@ -1518,6 +1518,7 @@ struct session_info *find_or_create_session_info(
        if (!session) {
                ERR("[notification-thread] Failed to allocation session info for session \"%s\" (uid = %i, gid = %i)",
                                name, uid, gid);
+               lttng_session_trigger_list_destroy(trigger_list);
                goto error;
        }
        trigger_list = NULL;
@@ -1930,6 +1931,7 @@ int bind_trigger_to_matching_channels(const struct lttng_trigger *trigger,
                        channels_ht_node) {
                struct lttng_trigger_list_element *trigger_list_element;
                struct lttng_channel_trigger_list *trigger_list;
+               struct cds_lfht_iter lookup_iter;
 
                if (!trigger_applies_to_channel(trigger, channel)) {
                        continue;
@@ -1939,8 +1941,8 @@ int bind_trigger_to_matching_channels(const struct lttng_trigger *trigger,
                                hash_channel_key(&channel->key),
                                match_channel_trigger_list,
                                &channel->key,
-                               &iter);
-               node = cds_lfht_iter_get_node(&iter);
+                               &lookup_iter);
+               node = cds_lfht_iter_get_node(&lookup_iter);
                assert(node);
                trigger_list = caa_container_of(node,
                                struct lttng_channel_trigger_list,
@@ -2276,9 +2278,9 @@ int handle_notification_thread_command(
        struct notification_thread_command *cmd;
 
        /* Read the event pipe to put it back into a quiescent state. */
-       ret = read(lttng_pipe_get_readfd(handle->cmd_queue.event_pipe), &counter,
+       ret = lttng_read(lttng_pipe_get_readfd(handle->cmd_queue.event_pipe), &counter,
                        sizeof(counter));
-       if (ret == -1) {
+       if (ret != sizeof(counter)) {
                goto error;
        }
 
@@ -2542,6 +2544,7 @@ int handle_notification_thread_trigger_unregister_all(
        struct cds_lfht_iter iter;
        struct lttng_trigger_ht_element *trigger_ht_element;
 
+       rcu_read_lock();
        cds_lfht_for_each_entry(state->triggers_ht, &iter, trigger_ht_element,
                        node) {
                int ret = handle_notification_thread_command_unregister_trigger(
@@ -2550,6 +2553,7 @@ int handle_notification_thread_trigger_unregister_all(
                        error_occurred = true;
                }
        }
+       rcu_read_unlock();
        return error_occurred ? -1 : 0;
 }
 
This page took 0.025351 seconds and 5 git commands to generate.