Fix: Lock metadata cache on session destroy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 13 Jul 2020 18:59:33 +0000 (14:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 13 Jul 2020 18:59:33 +0000 (14:59 -0400)
commit 92143b2c5656 ("Fix: metadata stream leak, missing list removal and locking")
missed taking a lock protecting the metadata stream list iteration on
session destroy. This opens a race window between iteration and item
removal/free which triggers kernel OOPS.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/lttng-events.c

index 11b0ed5396e68adc1e2aea733318082002333f96..62f8e054043ef7c668ab3ed5e253c739d7871d0f 100644 (file)
@@ -214,8 +214,10 @@ void lttng_session_destroy(struct lttng_session *session)
                BUG_ON(chan->channel_type == METADATA_CHANNEL);
                _lttng_channel_destroy(chan);
        }
+       mutex_lock(&session->metadata_cache->lock);
        list_for_each_entry(metadata_stream, &session->metadata_cache->metadata_stream, list)
                _lttng_metadata_channel_hangup(metadata_stream);
+       mutex_unlock(&session->metadata_cache->lock);
        lttng_id_tracker_destroy(&session->pid_tracker, false);
        lttng_id_tracker_destroy(&session->vpid_tracker, false);
        lttng_id_tracker_destroy(&session->uid_tracker, false);
This page took 0.028076 seconds and 4 git commands to generate.