]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
tracing: Prevent kernel oops with corrupted buffer
authorSteven Rostedt <srostedt@redhat.com>
Mon, 25 Jan 2010 20:11:53 +0000 (15:11 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Mon, 25 Jan 2010 20:11:53 +0000 (15:11 -0500)
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>
kernel/trace/trace.c

index 0df1b0f2cb9e0717f2a21f6923389c1978a1fa04..eac6875cb99042fc46aefa4916a4b138e080ca4f 100644 (file)
@@ -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;