Skip to content

Commit

Permalink
tracing: Prevent kernel oops with corrupted buffer
Browse files Browse the repository at this point in the history
If the contents of the ftrace ring buffer gets corrupted and the trace
file is read, it could create a kernel oops (usualy just killing the user
task thread). This is caused by the checking of the pid in the buffer.
If the pid is negative, it still references the cmdline cache array,
which could point to an invalid address.

The simple fix is to test for negative PIDs.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Jan 25, 2010
1 parent f6760aa commit 74bf407
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,11 @@ void trace_find_cmdline(int pid, char comm[])
return;
}

if (WARN_ON_ONCE(pid < 0)) {
strcpy(comm, "<XXX>");
return;
}

if (pid > PID_MAX_DEFAULT) {
strcpy(comm, "<...>");
return;
Expand Down

0 comments on commit 74bf407

Please sign in to comment.