Skip to content

Commit

Permalink
tracing: do not allow modifying the ftrace events via the event files
Browse files Browse the repository at this point in the history
Impact: fix to prevent crash on calling NULL function pointer

The ftrace internal records have their format exported via the event
system under the ftrace subsystem. These are only for exporting the
format to allow binary readers to be able to parse them in a binary
output.

The ftrace subsystem events can only be enabled via the ftrace tracers
and do not have a registering function. The event files expect the
event record to have registering function and will call it directly.
Passing in a ftrace subsystem event will cause the kernel to crash
because it will execute a NULL pointer.

This patch prevents the ftrace subsystem from being viewable to the
event enabling files.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
  • Loading branch information
Steven Rostedt committed Mar 10, 2009
1 parent ce8eb2b commit 40e2681
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions kernel/trace/trace_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int ftrace_set_clr_event(char *buf, int set)
mutex_lock(&event_mutex);
events_for_each(call) {

if (!call->name)
if (!call->name || !call->regfunc)
continue;

if (match &&
Expand Down Expand Up @@ -207,8 +207,20 @@ t_next(struct seq_file *m, void *v, loff_t *pos)

(*pos)++;

if ((unsigned long)call >= (unsigned long)__stop_ftrace_events)
return NULL;
for (;;) {
if ((unsigned long)call >= (unsigned long)__stop_ftrace_events)
return NULL;

/*
* The ftrace subsystem is for showing formats only.
* They can not be enabled or disabled via the event files.
*/
if (call->regfunc)
break;

call++;
next = call;
}

m->private = ++next;

Expand Down

0 comments on commit 40e2681

Please sign in to comment.