Validate match of all session channel's UUID
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Mar 2021 14:01:55 +0000 (10:01 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Mar 2021 14:26:36 +0000 (10:26 -0400)
Add a validation at channel creation to ensure that the uuid of all
channels created within a session match.

Note that we still need to keep a copy of the uuid field in the channel
private data at this stage, because the consumer daemon creates channels
with a NULL session pointer.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3490bab8879ffa66bc1e19559b0a1a60d33d605b

liblttng-ust/lttng-events.c
liblttng-ust/lttng-ust-abi.c
liblttng-ust/ust-events-internal.h

index 9c65dc4544ffb85fb94bf6552ff7b851c063b2ee..70e2f3a9c6f18d265d3410acd325d7b1cb9fda4a 100644 (file)
@@ -2019,3 +2019,21 @@ void lttng_ust_context_set_event_notifier_group_provider(const char *name,
                        abort();
        }
 }
+
+int lttng_ust_session_uuid_validate(struct lttng_ust_session *session,
+               unsigned char *uuid)
+{
+       if (!session)
+               return 0;
+       /* Compare UUID with session. */
+       if (session->priv->uuid_set) {
+               if (memcmp(session->priv->uuid, uuid, LTTNG_UST_UUID_LEN)) {
+                       return -1;
+               }
+       } else {
+               memcpy(session->priv->uuid, uuid, LTTNG_UST_UUID_LEN);
+               session->priv->uuid_set = true;
+       }
+       return 0;
+
+}
index 53ca5dbe28ef7f2f8dfc82344cc7b5d454bf627d..af2a47dcb5269ac8ec478a75fa18afdfd63fbd2a 100644 (file)
@@ -502,6 +502,11 @@ int lttng_abi_map_channel(int session_objd,
                goto alloc_error;
        }
 
+       if (lttng_ust_session_uuid_validate(session, lttng_chan_config->uuid)) {
+               ret = -EINVAL;
+               goto uuid_error;
+       }
+
        /* Lookup transport name */
        switch (type) {
        case LTTNG_UST_ABI_CHAN_PER_CPU:
@@ -578,6 +583,7 @@ int lttng_abi_map_channel(int session_objd,
        /* error path after channel was created */
 objd_error:
 notransport:
+uuid_error:
 alloc_error:
        channel_destroy(chan, channel_handle, 0);
        lttng_ust_free_channel_common(lttng_chan_buf->parent);
index 6ade956e769be4a5ca37fab357e4a7a84ed06c40..f6ab27a2572bd2e2e923cce77501d34f7869c8f1 100644 (file)
@@ -332,6 +332,9 @@ struct lttng_ust_session_private {
        struct lttng_ust_enum_ht enums_ht;      /* ht of enumerations */
        struct cds_list_head enums_head;
        struct lttng_ust_ctx *ctx;              /* contexts for filters. */
+
+       unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */
+       bool uuid_set;                          /* Is uuid set ? */
 };
 
 struct lttng_enum {
@@ -893,4 +896,8 @@ int lttng_ust_interpret_event_filter(struct lttng_ust_event_common *event,
                const char *interpreter_stack_data,
                void *filter_ctx);
 
+__attribute__((visibility("hidden")))
+int lttng_ust_session_uuid_validate(struct lttng_ust_session *session,
+               unsigned char *uuid);
+
 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */
This page took 0.02682 seconds and 4 git commands to generate.