mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v3 3/3] tracing: Add ptr-hash option to show the hashed pointer value
Date: Mon, 15 Feb 2021 23:58:15 +0900	[thread overview]
Message-ID: <20210215235815.003b9bcece1d8de59d3e546b@kernel.org> (raw)
In-Reply-To: <20210212103310.791c1f48@gandalf.local.home>

On Fri, 12 Feb 2021 10:33:10 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> 
> Hi Masami,
> 
> I noticed theses sitting in my patchwork and I said I was going to hold off
> to the next merge window, and these got pushed down in my stack :-/

Yeah, managing random topics is a hard task ;)

> 
> 
> On Thu, 15 Oct 2020 23:55:25 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > Add tracefs/options/hash-ptr option to show hashed pointer
> > value by %p in event printk format string.
> > 
> > For the security reason, normal printk will show the hashed
> > pointer value (encrypted by random number) with %p to printk
> > buffer to hide the real address. But the tracefs/trace always
> > shows real address for debug. To bridge those outputs, add an
> > option to switch the output format. Ftrace users can use it
> > to find the hashed value corresponding to the real address
> > in trace log.
> > 
> > Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
> > ---
> >  Documentation/trace/ftrace.rst |    6 ++++++
> >  kernel/trace/trace.c           |    3 +++
> >  kernel/trace/trace.h           |    1 +
> >  3 files changed, 10 insertions(+)
> > 
> > diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst
> > index 87cf5c010d5d..62c98e9bbdd9 100644
> > --- a/Documentation/trace/ftrace.rst
> > +++ b/Documentation/trace/ftrace.rst
> > @@ -1159,6 +1159,12 @@ Here are the available options:
> >  	This simulates the original behavior of the trace file.
> >  	When the file is closed, tracing will be enabled again.
> >  
> > +  hash-ptr
> > +        When set, "%p" in the event printk format displays the
> > +        hashed pointer value instead of real address.
> > +        This will be useful if you want to find out which hashed
> > +        value is corresponding to the real value in trace log.
> > +
> 
> I'm thinking of making this the default. I'll add a patch to make it
> enabled by default "for security reasons", but still allow people to clear
> it this value.
> 
> Are you OK with that?

Yes, I agreed. It will be good for both security and debug reasons. :)

Thank you,

> 
> -- Steve
> 
> 
> 
> >    record-cmd
> >  	When any event or tracer is enabled, a hook is enabled
> >  	in the sched_switch trace point to fill comm cache
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > index 75395293d8df..b88cccf224cd 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -3543,6 +3543,9 @@ const char *trace_event_format(struct trace_iterator *iter, const char *fmt)
> >  	if (WARN_ON_ONCE(!fmt))
> >  		return fmt;
> >  
> > +	if (iter->tr->trace_flags & TRACE_ITER_HASH_PTR)
> > +		return fmt;
> > +
> >  	p = fmt;
> >  	new_fmt = q = iter->fmt;
> >  	while (*p) {
> > diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> > index 524502d1f60a..c34187bd22a9 100644
> > --- a/kernel/trace/trace.h
> > +++ b/kernel/trace/trace.h
> > @@ -1347,6 +1347,7 @@ extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
> >  		C(MARKERS,		"markers"),		\
> >  		C(EVENT_FORK,		"event-fork"),		\
> >  		C(PAUSE_ON_TRACE,	"pause-on-trace"),	\
> > +		C(HASH_PTR,		"hash-ptr"),	/* Print hashed pointer */ \
> >  		FUNCTION_FLAGS					\
> >  		FGRAPH_FLAGS					\
> >  		STACK_FLAGS					\
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2021-02-15 15:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 14:54 [PATCH v3 0/3] tracing: Show real address instead of hashed pointer Masami Hiramatsu
2020-10-15 14:55 ` [PATCH v3 1/3] tracing: Show real address for trace event arguments Masami Hiramatsu
2021-04-19 13:08   ` Jon Hunter
2021-04-19 18:22     ` Steven Rostedt
2021-04-20 11:16       ` Jon Hunter
2020-10-15 14:55 ` [PATCH v3 2/3] tracing: Update the stage 3 of trace event macro comment Masami Hiramatsu
2020-10-15 14:55 ` [PATCH v3 3/3] tracing: Add ptr-hash option to show the hashed pointer value Masami Hiramatsu
2021-02-12 15:33   ` Steven Rostedt
2021-02-15 14:58     ` Masami Hiramatsu [this message]
2020-10-15 15:49 ` [PATCH v3 0/3] tracing: Show real address instead of hashed pointer Steven Rostedt
2020-10-15 16:00   ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210215235815.003b9bcece1d8de59d3e546b@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome