lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 7 Aug 2009 22:36:08 +0200
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	Ingo Molnar <mingo@...e.hu>, LKML <linux-kernel@...r.kernel.org>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Mike Galbraith <efault@....de>,
	Steven Rostedt <rostedt@...dmis.org>,
	Paul Mackerras <paulus@...ba.org>,
	Pekka Enberg <penberg@...helsinki.fi>,
	Gabriel Munteanu <eduard.munteanu@...ux360.ro>,
	Li Zefan <lizf@...fujitsu.com>,
	Lai Jiangshan <laijs@...fujitsu.com>
Subject: Re: [PATCH] perfcounters: Support for ftrace event records sampling

On Fri, Aug 07, 2009 at 10:28:51PM +0200, Peter Zijlstra wrote:
> On Fri, 2009-08-07 at 22:21 +0200, Frederic Weisbecker wrote:
> > On Fri, Aug 07, 2009 at 10:09:07PM +0200, Peter Zijlstra wrote:
> > > On Fri, 2009-08-07 at 12:38 +0200, Peter Zijlstra wrote:
> > > > > +static void ftrace_profile_##call(proto)                             \
> > > > > +{                                                                    \
> > > > > +     struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
> > > > > +     struct ftrace_event_call *event_call = &event_##call;           \
> > > > > +     extern void perf_tpcounter_event(int, u64, u64, void *, int);   \
> > > > > +     struct ftrace_raw_##call *entry;                                \
> > > > > +     u64 __addr = 0, __count = 1;                                    \
> > > > > +     unsigned long irq_flags;                                        \
> > > > > +     int __entry_size;                                               \
> > > > > +     int __data_size;                                                \
> > > > > +     int pc;                                                         \
> > > > > +                                                                     \
> > > > > +     local_save_flags(irq_flags);                                    \
> > > > > +     pc = preempt_count();                                           \
> > > > > +                                                                     \
> > > > > +     __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
> > > > > +     __entry_size = __data_size + sizeof(*entry);                    \
> > > > > +                                                                     \
> > > > > +     do {                                                            \
> > > > > +             char raw_data[__entry_size];                            \
> > > > > +             struct trace_entry *ent;                                \
> > > > > +                                                                     \
> > > > > +             entry = (struct ftrace_raw_##call *)raw_data;           \
> > > > > +             ent = &entry->ent;                                      \
> > > > > +             tracing_generic_entry_update(ent, irq_flags, pc);       \
> > > > > +             ent->type = event_call->id;                             \
> > > > > +                                                                     \
> > > > > +             tstruct                                                 \
> > > > > +                                                                     \
> > > > > +             { assign; }                                             \
> > > > > +                                                                     \
> > > > > +             perf_tpcounter_event(event_call->id, __addr, __count, entry,\
> > > > > +                          __entry_size);                             \
> > > > > +     } while (0);                                                    \
> > > > > +                                                                     \
> > > > > +}
> > > > 
> > > > ok, so the one concern I have here is that the data needs to fit on the
> > > > stack. What if someone puts a large string in the data?
> > > 
> > > Also, how NMI safe is all that?
> > 
> > 
> > Everything is allocated in the stack. It's NMI safe AFAICS, am I missing
> > something?
> 
> I've no idea what all those trace calls do, I was hoping you would and
> say, sure, no problem ;-)


Ah ok :)
To sum up, everything there is allocated in the stack, it's an issue
as you reported but beside that it makes it all NMI safe.

ftrace_get_offset_#call() get the __dynamic_array/__string things
and computes the total _local_ string length.
It also fills __data_offsets with the dynamic arrays offset, __data_offset
is also in the stack.

tracing_entry_generic_update() fills *ent (stack allocated) with the standard
informations (irq_flags, preempt_count, etc...).

And that's it :)

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ