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,
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,
/* Default JUL domain channel name. */
#define DEFAULT_JUL_CHANNEL_NAME "lttng_jul_channel"
/* Default JUL tracepoint name. This is a wildcard for the JUL domain. */
-#define DEFAULT_JUL_EVENT_NAME "lttng_jul:*"
+#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_LOG4J_EVENT_NAME "lttng_log4j:*"
+#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