Re: [PATCH 3/3] perfcounter: Align ftrace events raw samples to 8bytes

From: Frederic Weisbecker
Date: Mon Aug 10 2009 - 03:32:59 EST


On Mon, Aug 10, 2009 at 09:13:57AM +0200, Peter Zijlstra wrote:
> On Sat, 2009-08-08 at 04:26 +0200, Frederic Weisbecker wrote:
> > Align the ftrace events raw samples to 8 bytes so that they meet the
> > perf output event alignements requirements.
> >
> > Reported-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> > Cc: Mike Galbraith <efault@xxxxxx>
> > Cc: Paul Mackerras <paulus@xxxxxxxxx>
> > ---
> > include/trace/ftrace.h | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
> > index 80e5f6c..7b0834c 100644
> > --- a/include/trace/ftrace.h
> > +++ b/include/trace/ftrace.h
> > @@ -687,7 +687,7 @@ static void ftrace_profile_##call(proto) \
> > pc = preempt_count(); \
> > \
> > __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
> > - __entry_size = __data_size + sizeof(*entry); \
> > + __entry_size = ALIGN(__data_size + sizeof(*entry), sizeof(u64));\
> > \
> > do { \
> > char raw_data[__entry_size]; \
>
> Make sure to clear the trailing few bytes, otherwise we've got a stack
> data leak here.


Oh, right.



> Also, tracepoints using __string() could still easily overflow the stack
> here and cause great havoc, esp since the tracepoint could already be
> deep into a call-chain.


I know yeah, I'll think about a way to store the string parts as pointers
and copy their content on perf_output only.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/