From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754462AbeAQQcL (ORCPT ); Wed, 17 Jan 2018 11:32:11 -0500 Received: from terminus.zytor.com ([65.50.211.136]:48247 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754259AbeAQQcJ (ORCPT ); Wed, 17 Jan 2018 11:32:09 -0500 Date: Wed, 17 Jan 2018 08:29:48 -0800 From: "tip-bot for Steven Rostedt (VMware)" Message-ID: Cc: namhyung@kernel.org, acme@redhat.com, akpm@linux-foundation.org, hpa@zytor.com, rostedt@goodmis.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org Reply-To: acme@redhat.com, akpm@linux-foundation.org, namhyung@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, rostedt@goodmis.org, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <20180112004822.403349289@goodmis.org> References: <20180112004822.403349289@goodmis.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools lib traceevent: Handle new pointer processing of bprint strings Git-Commit-ID: 37db96bb49629681cb839d7304a70524fe10f969 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 37db96bb49629681cb839d7304a70524fe10f969 Gitweb: https://git.kernel.org/tip/37db96bb49629681cb839d7304a70524fe10f969 Author: Steven Rostedt (VMware) AuthorDate: Thu, 11 Jan 2018 19:47:46 -0500 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 17 Jan 2018 10:22:08 -0300 tools lib traceevent: Handle new pointer processing of bprint strings The Linux kernel printf() has some extended use cases that dereference the pointer. This is dangerouse for tracing because the pointer that is dereferenced can change or even be unmapped. It also causes issues when the trace data is extracted, because user space does not have access to the contents of the pointer even if it still exists. To handle this, the kernel was updated to process these dereferenced pointers at the time they are recorded, and not post processed. Now they exist in the tracing buffer, and no dereference is needed at the time of reading the trace. The event parsing library needs to handle this new case. Signed-off-by: Steven Rostedt Acked-by: Namhyung Kim Cc: Andrew Morton Link: http://lkml.kernel.org/r/20180112004822.403349289@goodmis.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-parse.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 8757dd6..344a034 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -4300,6 +4300,26 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc goto process_again; case 'p': ls = 1; + if (isalnum(ptr[1])) { + ptr++; + /* Check for special pointers */ + switch (*ptr) { + case 's': + case 'S': + case 'f': + case 'F': + break; + default: + /* + * Older kernels do not process + * dereferenced pointers. + * Only process if the pointer + * value is a printable. + */ + if (isprint(*(char *)bptr)) + goto process_string; + } + } /* fall through */ case 'd': case 'u': @@ -4352,6 +4372,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc break; case 's': + process_string: arg = alloc_arg(); if (!arg) { do_warning_event(event, "%s(%d): not enough memory!", @@ -4959,6 +4980,11 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event if (isalnum(ptr[1])) ptr++; + if (arg->type == PRINT_BSTRING) { + trace_seq_puts(s, arg->string.string); + break; + } + if (*ptr == 'F' || *ptr == 'f' || *ptr == 'S' || *ptr == 's') { show_func = *ptr;