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: [RFC PATCH 1/1] tracepoints: tree-wide: Replace %p with %px
Date: Thu, 15 Oct 2020 00:11:04 +0900 [thread overview]
Message-ID: <20201015001104.593651d4e07bc3d4597e0771@kernel.org> (raw)
In-Reply-To: <20201014093813.74490c26@gandalf.local.home>
On Wed, 14 Oct 2020 09:38:13 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Wed, 14 Oct 2020 17:59:19 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> > To help debugging kernel, use %px to show real addresses on
> > tracefs/trace file.
> >
> > Since ftrace human-readable format uses vsprintf(), all %p are
> > translated to hash values instead of pointer address.
> >
> > However, when debugging the kernel, raw address value gives a
> > hint when comparing with the memory mapping in the kernel.
> > (Those are sometimes used with crash log, which is not hashed too)
> >
> > Moreover, this is not improving the security because the tracefs
> > can be used only by root user and the raw address values are readable
> > from tracefs/percpu/cpu*/trace_pipe_raw file.
> >
> > Note that this has been done by the following script.
> >
> > #!/bin/sh
> > tmp=`mktemp`
> > for h in include/trace/events/*.h ; do
> > sed -e 's/\(%p\)\([^a-zA-Z]\)/\1x\2/g' $h > $tmp
> > cp $tmp $h
> > done
> > rm $tmp
> >
> > Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
>
> Hi Masami,
>
> I think a better approach is to inject on the output side a conversion of
> "%p" to "%px" before printing. That is, in the trace_raw_output_##call()
> function, instead of calling trace_seq_printf(s, print), we call a new
> function trace_event_printf(s, print), that will take the fmt parameter,
> and copies it to something that does your 's/\(%p\)\([^a-zA-Z]\)/\1x\2/g'
> inline before passing it off to trace_seq_printf().
Hmm, would you mean we always run such conversion on printing the trace
buffer for each entry? It could be much overhead because we need allocate
memory (%p->%px increase 1 byte) and format conversion (with copying it).
Maybe we can avoid repeating it using a kind of cache, but it also consumes
memory. And as I pointed, the security reason is meaningless because there
are raw addresses in raw data which user can read...
Could you tell me what is your point? Making the code change as small as
possible?
Thank you,
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2020-10-14 15:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-14 8:59 [RFC PATCH 0/1] tracepoints: Use %px instead of %p in trace event definitions Masami Hiramatsu
2020-10-14 8:59 ` [RFC PATCH 1/1] tracepoints: tree-wide: Replace %p with %px Masami Hiramatsu
2020-10-14 13:38 ` Steven Rostedt
2020-10-14 15:11 ` Masami Hiramatsu [this message]
2020-10-14 15:35 ` Steven Rostedt
2020-10-14 16:41 ` 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=20201015001104.593651d4e07bc3d4597e0771@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