From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752660AbcF2HYc (ORCPT ); Wed, 29 Jun 2016 03:24:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48736 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751352AbcF2HYb (ORCPT ); Wed, 29 Jun 2016 03:24:31 -0400 Date: Wed, 29 Jun 2016 09:24:28 +0200 From: Jiri Olsa To: Steven Rostedt Cc: LKML , Ingo Molnar , Frederic Weisbecker , Rasmus Villemoes , Andrew Morton Subject: Re: [RFC][PATCH] tracing: Add trace_printk_ptr() to force non use of trace_bprintk() Message-ID: <20160629072428.GA14656@krava> References: <20160628191929.4d238183@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160628191929.4d238183@gandalf.local.home> User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 29 Jun 2016 07:24:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 thanks, jirka