[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140610094247.5fcde204@gandalf.local.home>
Date: Tue, 10 Jun 2014 09:42:47 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Namhyung Kim <namhyung@...il.com>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@...achi.com>
Subject: Re: [for-next][PATCH 4/6] tracing: Return error if
ftrace_trace_arrays list is empty
On Tue, 10 Jun 2014 14:20:39 +0900
Namhyung Kim <namhyung@...il.com> wrote:
> On Fri, 06 Jun 2014 12:30:38 -0400, Steven Rostedt wrote:
> > From: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@...achi.com>
> >
> > ftrace_trace_arrays links global_trace.list. However, global_trace
> > is not added to ftrace_trace_arrays if trace_alloc_buffers() failed.
> > As the result, ftrace_trace_arrays becomes an empty list. If
> > ftrace_trace_arrays is an empty list, current top_trace_array() returns
> > an invalid pointer. As the result, the kernel can induce memory corruption
> > or panic.
> >
> > Current implementation does not check whether ftrace_trace_arrays is empty
> > list or not. So, in this patch, if ftrace_trace_arrays is empty list,
> > top_trace_array() returns NULL. Moreover, this patch makes all functions
> > calling top_trace_array() handle it appropriately.
>
> [SNIP]
> > @@ -252,6 +252,9 @@ static inline struct trace_array *top_trace_array(void)
> > {
> > struct trace_array *tr;
> >
> > + if (list_empty(ftrace_trace_arrays.prev))
> > + return NULL;
>
> It looks weird to me.. why not checking "list_empty(&ftrace_trace_arrays)"?
>
Bah, I don't know how I missed that. Thanks.
-- Steve
> Thanks,
> Namhyung
>
> > +
> > tr = list_entry(ftrace_trace_arrays.prev,
> > typeof(*tr), list);
> > WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL));
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists