From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932625AbeALAtI (ORCPT + 1 other); Thu, 11 Jan 2018 19:49:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:56260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932538AbeALAsY (ORCPT ); Thu, 11 Jan 2018 19:48:24 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2794621779 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Message-Id: <20180112004823.146333275@goodmis.org> User-Agent: quilt/0.63-1 Date: Thu, 11 Jan 2018 19:47:51 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Andrew Morton , Namhyung Kim , gopanapalli pradeep Subject: [PATCH 10/10] lib traceevent: Fix get_field_str() for dynamic strings References: <20180112004741.378806573@goodmis.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0010-lib-traceevent-Fix-get_field_str-for-dynamic-strings.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: "Steven Rostedt (VMware)" If a field is a dynamic string, get_field_str() returned just the offset/size value and not the string. Have it parse the offset/size correctly to return the actual string. Otherwise filtering fails when trying to filter fields that are dynamic strings. Reported-by: gopanapalli pradeep Signed-off-by: Steven Rostedt (VMware) --- tools/lib/traceevent/parse-filter.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c index 2b9048f90bae..431e8b309f6e 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -1877,17 +1877,25 @@ static const char *get_field_str(struct filter_arg *arg, struct pevent_record *r struct pevent *pevent; unsigned long long addr; const char *val = NULL; + unsigned int size; char hex[64]; /* If the field is not a string convert it */ if (arg->str.field->flags & FIELD_IS_STRING) { val = record->data + arg->str.field->offset; + size = arg->str.field->size; + + if (arg->str.field->flags & FIELD_IS_DYNAMIC) { + addr = *(unsigned int *)val; + val = record->data + (addr & 0xffff); + size = addr >> 16; + } /* * We need to copy the data since we can't be sure the field * is null terminated. */ - if (*(val + arg->str.field->size - 1)) { + if (*(val + size - 1)) { /* copy it */ memcpy(arg->str.buffer, val, arg->str.field->size); /* the buffer is already NULL terminated */ -- 2.13.2