Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1433516

Re: [RFC][PATCH] tracing: Add trace_printk_ptr() to force non use of trace_bprintk()

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH] tracing: Add trace_printk_ptr() to force non use of trace_bprintk()
Date 2016-06-29 09:30 +0200
Message-ID <rPi6C-1fN-25@gated-at.bofh.it> (permalink)
References <rPasp-4UA-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Jun 28, 2016 at 07:19:29PM -0400, Steven Rostedt wrote:
> trace_printk() is a very helpful tool for debugging the kernel. It adds
> lots of tricks to optimize itself to prevent any "heisenbugs". That is,
> having the addition of tracing cause the bug to change its timing and
> disappear. One of this tricks is to use trace_bprintk() when possible,
> which just stores the format and the arguments into the ring buffer to
> be processed later at the time of reading the trace output.
> 
> The issue with this is that there's some printf() fields that can do
> redirection. There's a list of "%p*" values that will dereference the
> pointer saved in the buffer. This is an issue with trace_printk()
> because the pointer could have been freed between the time the
> trace_printk() was called and the time the buffer is read. This will
> cause a bad pointer dereference.
> 
> The preferable fix is most likely to change bprintk() to recognize
> these pointers and instead of saving the pointer in the buffer to be
> processed later, it could do the conversion and save the value in the
> buffer. But this added processing kills the whole point of bprintk()
> from being fast and not doing any processing during the recording.
> Perhaps it should simply warn and/or refuse to print.
> 
> The simpler solution is to add an alternate trace_printk() that always
> uses the non optimized version that does the string processing at the
> time of the record, and saves just the string to the ring buffer.
> 
> There's been many times that I myself wanted this version. So here it
> is.
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

if we dont go with this change:
  http://marc.info/?l=linux-kernel&m=146715171527229&w=2

this patch works for me:

Tested-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[RFC][PATCH] tracing: Add trace_printk_ptr() to force non use of  trace_bprintk() Steven Rostedt <rostedt@goodmis.org> - 2016-06-29 01:20 +0200
  Re: [RFC][PATCH] tracing: Add trace_printk_ptr() to force non use of  trace_bprintk() Jiri Olsa <jolsa@redhat.com> - 2016-06-29 09:30 +0200

csiph-web