Prevent the use of reserved UST event names
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 23 Aug 2015 04:27:34 +0000 (00:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 8 Sep 2015 12:52:02 +0000 (08:52 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/common/defaults.h

index c26e5163c993f760885a5e1c7916d32b1397f284..5aff25d2ab937371e547b2bc50ecfa95738d6d0f 100644 (file)
@@ -1409,6 +1409,36 @@ end:
        return ret;
 }
 
+static inline bool name_starts_with(const char *name, const char *prefix)
+{
+       const size_t max_cmp_len = min(strlen(prefix), LTTNG_SYMBOL_NAME_LEN);
+
+       return !strncmp(name, prefix, max_cmp_len);
+}
+
+/* Perform userspace-specific event name validation */
+static int validate_ust_event_name(const char *name)
+{
+       int ret = 0;
+
+       if (!name) {
+               ret = -1;
+               goto end;
+       }
+
+       /*
+        * Check name against all internal UST event component namespaces used
+        * by the agents.
+        */
+       if (name_starts_with(name, DEFAULT_JUL_EVENT_COMPONENT) ||
+               name_starts_with(name, DEFAULT_LOG4J_EVENT_COMPONENT) ||
+               name_starts_with(name, DEFAULT_PYTHON_EVENT_COMPONENT)) {
+               ret = -1;
+       }
+
+end:
+       return ret;
+}
 
 static int cmd_enable_event_internal(struct ltt_session *session,
                struct lttng_domain *domain,
@@ -1624,6 +1654,21 @@ static int _cmd_enable_event(struct ltt_session *session,
                        assert(uchan);
                }
 
+               if (!internal_event) {
+                       /*
+                        * Ensure the event name is not reserved for internal
+                        * use.
+                        */
+                       ret = validate_ust_event_name(event->name);
+                       if (ret) {
+                               WARN("Userspace event name %s failed validation.",
+                                               event->name ?
+                                               event->name : "NULL");
+                               ret = LTTNG_ERR_INVALID_EVENT_NAME;
+                               goto error;
+                       }
+               }
+
                /* At this point, the session and channel exist on the tracer */
                ret = event_ust_enable_tracepoint(usess, uchan, event,
                                filter_expression, filter, exclusion,
index a0a582a01b4c4657b7fcfd8357eb20091833e411..d1cec34586e10e498261cc7d89a45c5f499d6e62 100644 (file)
 /* Default JUL tracepoint name. This is a wildcard for the JUL domain. */
 #define DEFAULT_SYS_JUL_EVENT_NAME      "lttng_jul:sys*"
 #define DEFAULT_USER_JUL_EVENT_NAME     "lttng_jul:user*"
+#define DEFAULT_JUL_EVENT_COMPONENT     "lttng_jul"
+#define DEFAULT_JUL_EVENT_NAME          DEFAULT_JUL_EVENT_COMPONENT ":*"
 
 /* Default log4j domain channel name. */
 #define DEFAULT_LOG4J_CHANNEL_NAME        "lttng_log4j_channel"
 /* Default log4j tracepoint name. This is a wildcard for the log4j domain. */
 #define DEFAULT_SYS_LOG4J_EVENT_NAME      "lttng_log4j:sys*"
 #define DEFAULT_USER_LOG4J_EVENT_NAME     "lttng_log4j:user*"
+#define DEFAULT_LOG4J_EVENT_COMPONENT     "lttng_log4j"
+#define DEFAULT_LOG4J_EVENT_NAME          DEFAULT_LOG4J_EVENT_COMPONENT ":*"
 
 /* Default Python domain channel name. */
 #define DEFAULT_PYTHON_CHANNEL_NAME       "lttng_python_channel"
 /* Default Python tracepoint name. This is a wildcard for the python domain. */
-#define DEFAULT_PYTHON_EVENT_NAME         "lttng_python:*"
+#define DEFAULT_PYTHON_EVENT_COMPONENT    "lttng_python"
+#define DEFAULT_PYTHON_EVENT_NAME         DEFAULT_PYTHON_EVENT_COMPONENT ":*"
 
 #define DEFAULT_CHANNEL_OVERWRITE       0
 #define DEFAULT_CHANNEL_TRACEFILE_SIZE  0
This page took 0.029489 seconds and 4 git commands to generate.