tracing: Check that the synthetic event and field names are legal
authorTom Zanussi <zanussi@kernel.org>
Tue, 13 Oct 2020 14:17:54 +0000 (09:17 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 15 Oct 2020 16:01:13 +0000 (12:01 -0400)
Call the is_good_name() function used by probe events to make sure
synthetic event and field names don't contain illegal characters and
cause unexpected parsing of synthetic event commands.

Link: https://lkml.kernel.org/r/c4d4bb59d3ac39bcbd70fba0cf837d6b1cedb015.1602598160.git.zanussi@kernel.org
Fixes: 4b147936fa50 (tracing: Add support for 'synthetic' events)
Reported-by: Masami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events_synth.c

index b19e2f4..8c9d6e4 100644 (file)
@@ -572,6 +572,10 @@ static struct synth_field *parse_synth_field(int argc, const char **argv,
                ret = -ENOMEM;
                goto free;
        }
+       if (!is_good_name(field->name)) {
+               ret = -EINVAL;
+               goto free;
+       }
 
        if (field_type[0] == ';')
                field_type++;
@@ -1112,6 +1116,11 @@ static int __create_synth_event(int argc, const char *name, const char **argv)
 
        mutex_lock(&event_mutex);
 
+       if (!is_good_name(name)) {
+               ret = -EINVAL;
+               goto out;
+       }
+
        event = find_synth_event(name);
        if (event) {
                ret = -EEXIST;