Skip to content

Commit 575b76c

Browse files
committed
tracing/probes: Handle system names with hyphens
When creating probe names, a check is done to make sure it matches basic C standard variable naming standards. Basically, starts with alphabetic or underline, and then the rest of the characters have alpha-numeric or underline in them. But system names do not have any true naming conventions, as they are created by the TRACE_SYSTEM macro and nothing tests to see what they are. The "xhci-hcd" trace events has a '-' in the system name. When trying to attach a eprobe to one of these trace points, it fails because the system name does not follow the variable naming convention because of the hyphen, and the eprobe checks fail on this. Allow hyphens in the system name so that eprobes can attach to the "xhci-hcd" trace events. Link: https://lore.kernel.org/all/Y3eJ8GiGnEvVd8%2FN@macondo/ Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: [email protected] Fixes: 5b7a962 ("tracing/probe: Check event/group naming rule at parsing") Reported-by: Rafael Mendonca <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent fff1787 commit 575b76c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

kernel/trace/trace.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,17 +1954,30 @@ static __always_inline void trace_iterator_reset(struct trace_iterator *iter)
19541954
}
19551955

19561956
/* Check the name is good for event/group/fields */
1957-
static inline bool is_good_name(const char *name)
1957+
static inline bool __is_good_name(const char *name, bool hash_ok)
19581958
{
1959-
if (!isalpha(*name) && *name != '_')
1959+
if (!isalpha(*name) && *name != '_' && (!hash_ok || *name != '-'))
19601960
return false;
19611961
while (*++name != '\0') {
1962-
if (!isalpha(*name) && !isdigit(*name) && *name != '_')
1962+
if (!isalpha(*name) && !isdigit(*name) && *name != '_' &&
1963+
(!hash_ok || *name != '-'))
19631964
return false;
19641965
}
19651966
return true;
19661967
}
19671968

1969+
/* Check the name is good for event/group/fields */
1970+
static inline bool is_good_name(const char *name)
1971+
{
1972+
return __is_good_name(name, false);
1973+
}
1974+
1975+
/* Check the name is good for system */
1976+
static inline bool is_good_system_name(const char *name)
1977+
{
1978+
return __is_good_name(name, true);
1979+
}
1980+
19681981
/* Convert certain expected symbols into '_' when generating event names */
19691982
static inline void sanitize_event_name(char *name)
19701983
{

kernel/trace/trace_probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
246246
return -EINVAL;
247247
}
248248
strlcpy(buf, event, slash - event + 1);
249-
if (!is_good_name(buf)) {
249+
if (!is_good_system_name(buf)) {
250250
trace_probe_log_err(offset, BAD_GROUP_NAME);
251251
return -EINVAL;
252252
}

0 commit comments

Comments
 (0)