lkml.org 
[lkml]   [2010]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/5] tracing: Prevent kernel oops with corrupted buffer
From
Date
On Tue, 2010-01-26 at 14:32 -0800, Andrew Morton wrote:
> On Tue, 26 Jan 2010 17:09:24 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > From: Steven Rostedt <srostedt@redhat.com>
> >
> > 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
>
> "usually" ;)

I used "usually" since that is what happened every time I encountered
the issue. But I don't know 100% if it only oops the user task in every
instance.

>
> > 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 | 5 +++++
> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > index 0df1b0f..eac6875 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -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;
>
> But why is it WARN_ON_ONCE()? That will only fix the problem a single
> time. On the second occurrence, it will oops again.

Frederic correctly answered this.

Thanks,

-- Steve





\
 
 \ /
  Last update: 2010-01-27 00:27    [W:0.038 / U:35.504 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site