Fix: syscall_list_show NULL pointer deref
[lttng-modules.git] / lttng-events.c
index eefee69b31a5cc59583fb57d7f074c5715aec654..135c8c527123acd43266c7191148d9bc314121a8 100644 (file)
@@ -98,6 +98,8 @@ struct lttng_session *lttng_session_create(void)
        kref_init(&metadata_cache->refcount);
        session->metadata_cache = metadata_cache;
        INIT_LIST_HEAD(&metadata_cache->metadata_stream);
+       memcpy(&metadata_cache->uuid, &session->uuid,
+               sizeof(metadata_cache->uuid));
        list_add(&session->list, &sessions);
        mutex_unlock(&sessions_mutex);
        return session;
@@ -377,8 +379,14 @@ struct lttng_event *lttng_event_create(struct lttng_channel *chan,
         */
        list_for_each_entry(event, &chan->session->events, list) {
                if (!strcmp(event->desc->name, event_param->name)) {
-                       ret = -EEXIST;
-                       goto exist;
+                       /*
+                        * Allow events with the same name to appear in
+                        * different channels.
+                        */
+                       if (event->chan == chan) {
+                               ret = -EEXIST;
+                               goto exist;
+                       }
                }
        }
        event = kmem_cache_zalloc(event_cache, GFP_KERNEL);
@@ -597,16 +605,20 @@ int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
 
        /*
         * Ensure we support mutiple get_next / put sequences followed
-        * by put_next.
+        * by put_next. The metadata stream lock internally protects
+        * reading the metadata cache. It can indeed be read
+        * concurrently by "get_next_subbuf" and "flush" operations on
+        * the buffer invoked by different processes.
         */
+       mutex_lock(&stream->lock);
        WARN_ON(stream->metadata_in < stream->metadata_out);
        if (stream->metadata_in != stream->metadata_out)
-               return 0;
+               goto end;
 
        len = stream->metadata_cache->metadata_written -
                stream->metadata_in;
        if (!len)
-               return 0;
+               goto end;
        reserve_len = min_t(size_t,
                        stream->transport->ops.packet_avail_size(chan),
                        len);
@@ -628,6 +640,7 @@ int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
        ret = reserve_len;
 
 end:
+       mutex_unlock(&stream->lock);
        return ret;
 }
 
@@ -1255,6 +1268,10 @@ static int __init lttng_events_init(void)
 {
        int ret;
 
+       ret = wrapper_lttng_fixup_sig(THIS_MODULE);
+       if (ret)
+               return ret;
+
        ret = lttng_tracepoint_init();
        if (ret)
                return ret;
This page took 0.02336 seconds and 4 git commands to generate.