From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Richard Weinberger <richard@nod.at>, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: vsprintf: Add support for userspace strings
Date: Mon, 11 May 2015 09:24:19 +0900 [thread overview]
Message-ID: <554FF6B3.4030205@hitachi.com> (raw)
In-Reply-To: <1431286936-4333-1-git-send-email-richard@nod.at>
On 2015/05/11 4:42, Richard Weinberger wrote:
> While debugging issues I often add (trace_)printks to strategic positions.
> Dealing with user provided string is complicated as an extra buffer a
> copy_from_user() is needed.
> This adds a new format string to allow direct printing of such strings.
>
> My initial plan was to use %pU but 'U' is already taken, therefore
> I used the next letter which comes in mind when one thinks of userpace,
> 'L'.
> The %pL format string works exactly like %s.
BTW, if you need to do this for debug, you can also use ftrace's kprobe-tracer
(and perf probe) which allows you to dump userspace strings :)
Here is an example.
-----
[mhiramat@localhost perf]$ ./perf probe -L do_sys_open:0-3
<do_sys_open@/usr/src/debug/kernel-3.10.0-229.1.2.el7/linux-3.10.0-229.1.2.el7.x
0 long do_sys_open(int dfd, const char __user *filename, int flags, umode
1 {
struct open_flags op;
3 int lookup = build_open_flags(flags, mode, &op);
[mhiramat@localhost perf]$ ./perf probe -V do_sys_open
Available variables at do_sys_open
@<do_sys_open+0>
char* filename
int dfd
int flags
int lookup
struct open_flags op
umode_t mode
[mhiramat@localhost perf]$ sudo ./perf probe do_sys_open filename:string
Added new event:
probe:do_sys_open (on do_sys_open with filename:string)
You can now use it in all perf tools, such as:
perf record -e probe:do_sys_open -aR sleep 1
[mhiramat@localhost perf]$ sudo ./perf record -e probe:do_sys_open -a ls &> /dev/null
[mhiramat@localhost perf]$ sudo ./perf script | more
ls 7238 [003] 1629305.250347: probe:do_sys_open: (ffffffff811c5e40) filename_string="/etc/ld.so.cache"
ls 7238 [003] 1629305.250384: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libselinux.so.1"
ls 7238 [003] 1629305.250501: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libcap.so.2"
ls 7238 [003] 1629305.250562: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libacl.so.1"
ls 7238 [003] 1629305.250631: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libc.so.6"
ls 7238 [003] 1629305.250706: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libpcre.so.1"
ls 7238 [003] 1629305.250769: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/liblzma.so.5"
ls 7238 [003] 1629305.250838: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libdl.so.2"
ls 7238 [003] 1629305.250898: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libattr.so.1"
ls 7238 [003] 1629305.250959: probe:do_sys_open: (ffffffff811c5e40) filename_string="/lib64/libpthread.so.0"
ls 7238 [003] 1629305.251591: probe:do_sys_open: (ffffffff811c5e40) filename_string=""
ls 7238 [003] 1629305.251695: probe:do_sys_open: (ffffffff811c5e40) filename_string="."
[mhiramat@localhost perf]$ sudo ./perf probe -d \*
Removed event: probe:do_sys_open
-----
Thank you,
--
Masami HIRAMATSU
Linux Technology Research Center, System Productivity Research Dept.
Center for Technology Innovation - Systems Engineering
Hitachi, Ltd., Research & Development Group
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2015-05-11 0:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-10 19:42 vsprintf: Add support for userspace strings Richard Weinberger
2015-05-10 19:42 ` [PATCH 1/2] Fix printk() on ERR_PTR() Richard Weinberger
2015-05-11 23:20 ` Andrew Morton
2015-05-12 7:23 ` Richard Weinberger
2015-05-10 19:42 ` [PATCH 2/2] vsprintf: Add support for userspace strings Richard Weinberger
2015-05-10 20:09 ` Joe Perches
2015-05-10 20:11 ` Richard Weinberger
2015-05-10 20:16 ` Joe Perches
2015-05-10 20:22 ` Richard Weinberger
2015-05-11 23:23 ` Andrew Morton
2015-05-12 7:31 ` Richard Weinberger
2015-05-11 0:24 ` Masami Hiramatsu [this message]
2015-05-11 8:59 ` Richard Weinberger
2015-05-11 10:57 ` Richard Weinberger
2015-05-11 20:42 ` 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=554FF6B3.4030205@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard@nod.at \
/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