mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Richter <tmricht@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, rostedt@goodmis.org, mingo@redhat.com
Cc: heiko.carstens@de.ibm.com, schwidefsky@de.ibm.com,
	brueckner@linux.vnet.ibm.com,
	Thomas Richter <tmricht@linux.vnet.ibm.com>
Subject: [PATCH] trace/uprobes: fix output issue with address randomization
Date: Mon, 18 Dec 2017 16:32:25 +0100	[thread overview]
Message-ID: <20171218153225.12192-1-tmricht@linux.vnet.ibm.com> (raw)

Commit ad67b74d2469 ("printk: hash addresses printed with %p")
changed %p to hash pointers in order to avoid leaking
kernel addresses.

This breaks the tool perf probe.

To set a uprobe on a function named inet_pton in libc library,
obtain the address of the symbol inet_pton using command nm and
then use the following command to set the uprobe:

 # echo "p:probe_libc/inet_pton /usr/lib64/libc-2.26.so:0x142060"
	> /sys/kernel/debug/tracing/uprobe_events

However the output shows a randomized address:
 # cat /sys/kernel/debug/tracing/uprobe_events
 p:probe_libc/inet_pton /usr/lib64/libc-2.26.so:0x000000002d0f8952

The displayed address 0x000000002d0f8952 is incorrect and breaks
tools post processing it:

 # linux/tools/perf/perf probe -l
 Failed to find debug information for address 2d0f8952
   probe_libc:inet_pton (on 0x2d0f8952 in /usr/lib64/libc-2.26.so)

Using the %px printk format string fixes this issue for root
and shows the correct address allowing the perf probe tool
to resolve the address to the symbol:

 # echo "p:probe_libc/inet_pton /usr/lib64/libc-2.26.so:0x142060"
	> /sys/kernel/debug/tracing/uprobe_events
 # cat /sys/kernel/debug/tracing/uprobe_events
 p:probe_libc/inet_pton /usr/lib64/libc-2.26.so:0x0000000000142060
 # linux/tools/perf/perf probe -l
  probe_libc:inet_pton (on __inet_pton@resolv/inet_pton.c
					in /usr/lib64/libc-2.26.so)

Signed-off-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
---
 kernel/trace/trace_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 40592e7b3568..268029ae1be6 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -608,7 +608,7 @@ static int probes_seq_show(struct seq_file *m, void *v)
 
 	/* Don't print "0x  (null)" when offset is 0 */
 	if (tu->offset) {
-		seq_printf(m, "0x%p", (void *)tu->offset);
+		seq_printf(m, "0x%px", (void *)tu->offset);
 	} else {
 		switch (sizeof(void *)) {
 		case 4:
-- 
2.13.4

             reply	other threads:[~2017-12-18 15:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-18 15:32 Thomas Richter [this message]
2017-12-18 17:55 ` Peter Zijlstra
2017-12-18 17:59 ` Steven Rostedt
2017-12-18 18:16   ` Linus Torvalds
2017-12-19  8:53     ` Thomas-Mich Richter
  -- strict thread matches above, loose matches on Subject: below --
2017-12-15 15:36 Thomas Richter
2017-12-15 17:31 ` Peter Zijlstra
2017-12-15 17:41   ` Steven Rostedt
2017-12-19  0:25   ` 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=20171218153225.12192-1-tmricht@linux.vnet.ibm.com \
    --to=tmricht@linux.vnet.ibm.com \
    --cc=brueckner@linux.vnet.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=schwidefsky@de.ibm.com \
    /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

all inboxes | Powered by JetHome®