Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752089AbbEKAY2 (ORCPT ); Sun, 10 May 2015 20:24:28 -0400 Received: from mail9.hitachi.co.jp ([133.145.228.44]:52420 "EHLO mail9.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751773AbbEKAY0 (ORCPT ); Sun, 10 May 2015 20:24:26 -0400 Message-ID: <554FF6B3.4030205@hitachi.com> Date: Mon, 11 May 2015 09:24:19 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Richard Weinberger , akpm@linux-foundation.org CC: linux-kernel@vger.kernel.org Subject: Re: vsprintf: Add support for userspace strings References: <1431286936-4333-1-git-send-email-richard@nod.at> In-Reply-To: <1431286936-4333-1-git-send-email-richard@nod.at> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3695 Lines: 71 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 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/