tracing/kprobes: Have uname use __get_str() in print_fmt

Thomas Richter reported:

> Test case 66 'Use vfs_getname probe to get syscall args filenames'
> is broken on s390, but works on x86. The test case fails with:
>
>  [root@m35lp76 perf]# perf test -F 66
>  66: Use vfs_getname probe to get syscall args filenames
>            :Recording open file:
>  [ perf record: Woken up 1 times to write data ]
>  [ perf record: Captured and wrote 0.004 MB /tmp/__perf_test.perf.data.TCdYj\
> 	 (20 samples) ]
>  Looking at perf.data file for vfs_getname records for the file we touched:
>   FAILED!
>   [root@m35lp76 perf]#

The root cause was the print_fmt of the kprobe event that referenced the
"ustring"

> Setting up the kprobe event using perf command:
>
>  # ./perf probe "vfs_getname=getname_flags:72 pathname=filename:ustring"
>
> generates this format file:
>   [root@m35lp76 perf]# cat /sys/kernel/debug/tracing/events/probe/\
> 	  vfs_getname/format
>   name: vfs_getname
>   ID: 1172
>   format:
>     field:unsigned short common_type; offset:0; size:2; signed:0;
>     field:unsigned char common_flags; offset:2; size:1; signed:0;
>     field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
>     field:int common_pid; offset:4; size:4; signed:1;
>
>     field:unsigned long __probe_ip; offset:8; size:8; signed:0;
>     field:__data_loc char[] pathname; offset:16; size:4; signed:1;
>
>     print fmt: "(%lx) pathname=\"%s\"", REC->__probe_ip, REC->pathname

Instead of using "__get_str(pathname)" it referenced it directly.

Link: http://lkml.kernel.org/r/20200124100742.4050c15e@gandalf.local.home

Cc: stable@vger.kernel.org
Fixes: 88903c46 ("tracing/probe: Add ustring type for user-space string")
Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Reported-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Tested-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent b61387cb
...@@ -876,7 +876,8 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, ...@@ -876,7 +876,8 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len,
for (i = 0; i < tp->nr_args; i++) { for (i = 0; i < tp->nr_args; i++) {
parg = tp->args + i; parg = tp->args + i;
if (parg->count) { if (parg->count) {
if (strcmp(parg->type->name, "string") == 0) if ((strcmp(parg->type->name, "string") == 0) ||
(strcmp(parg->type->name, "ustring") == 0))
fmt = ", __get_str(%s[%d])"; fmt = ", __get_str(%s[%d])";
else else
fmt = ", REC->%s[%d]"; fmt = ", REC->%s[%d]";
...@@ -884,7 +885,8 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, ...@@ -884,7 +885,8 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len,
pos += snprintf(buf + pos, LEN_OR_ZERO, pos += snprintf(buf + pos, LEN_OR_ZERO,
fmt, parg->name, j); fmt, parg->name, j);
} else { } else {
if (strcmp(parg->type->name, "string") == 0) if ((strcmp(parg->type->name, "string") == 0) ||
(strcmp(parg->type->name, "ustring") == 0))
fmt = ", __get_str(%s)"; fmt = ", __get_str(%s)";
else else
fmt = ", REC->%s"; fmt = ", REC->%s";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment