This is a note to let you know that I've just added the patch titled tracing/probes: Handle system names with hyphens to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: tracing-probes-handle-system-names-with-hyphens.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 575b76cb885532aae13a9d979fd476bb2b156cb9 Mon Sep 17 00:00:00 2001 From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> Date: Tue, 22 Nov 2022 12:23:45 -0500 Subject: tracing/probes: Handle system names with hyphens From: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> commit 575b76cb885532aae13a9d979fd476bb2b156cb9 upstream. 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/20221122122345.160f5077@xxxxxxxxxxxxxxxxxx Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Fixes: 5b7a96220900e ("tracing/probe: Check event/group naming rule at parsing") Reported-by: Rafael Mendonca <rafaelmendsr@xxxxxxxxx> Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/trace/trace.h | 19 ++++++++++++++++--- kernel/trace/trace_probe.c | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1939,17 +1939,30 @@ static __always_inline void trace_iterat } /* Check the name is good for event/group/fields */ -static inline bool is_good_name(const char *name) +static inline bool __is_good_name(const char *name, bool hash_ok) { - if (!isalpha(*name) && *name != '_') + if (!isalpha(*name) && *name != '_' && (!hash_ok || *name != '-')) return false; while (*++name != '\0') { - if (!isalpha(*name) && !isdigit(*name) && *name != '_') + if (!isalpha(*name) && !isdigit(*name) && *name != '_' && + (!hash_ok || *name != '-')) return false; } return true; } +/* Check the name is good for event/group/fields */ +static inline bool is_good_name(const char *name) +{ + return __is_good_name(name, false); +} + +/* Check the name is good for system */ +static inline bool is_good_system_name(const char *name) +{ + return __is_good_name(name, true); +} + /* Convert certain expected symbols into '_' when generating event names */ static inline void sanitize_event_name(char *name) { --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -246,7 +246,7 @@ int traceprobe_parse_event_name(const ch return -EINVAL; } strlcpy(buf, event, slash - event + 1); - if (!is_good_name(buf)) { + if (!is_good_system_name(buf)) { trace_probe_log_err(offset, BAD_GROUP_NAME); return -EINVAL; } Patches currently in stable-queue which might be from rostedt@xxxxxxxxxxx are queue-5.15/tracing-fix-race-where-eprobes-can-be-called-before-the-event.patch queue-5.15/tracing-hist-fix-wrong-return-value-in-parse_action_params.patch queue-5.15/tracing-probes-handle-system-names-with-hyphens.patch queue-5.15/tracing-hist-fix-out-of-bound-write-on-action_data.var_ref_idx.patch queue-5.15/kest.pl-fix-grub2-menu-handling-for-rebooting.patch queue-5.15/ktest.pl-minconfig-unset-configs-instead-of-just-removing-them.patch queue-5.15/tracing-fix-complicated-dependency-of-config_tracer_max_trace.patch queue-5.15/tracing-fix-infinite-loop-in-tracing_read_pipe-on-overflowed-print_trace_line.patch queue-5.15/ftrace-x86-add-back-ftrace_expected-for-ftrace-bug-reports.patch