Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2531088imm; Mon, 28 May 2018 09:51:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoIVQVGF1NSQLToReIJEr4H3WVeSKiFzvckG619RoSVVy52FJvHrzKYF4Pq5kiZ+LCNgGee X-Received: by 2002:a17:902:274a:: with SMTP id j10-v6mr14644799plg.393.1527526316563; Mon, 28 May 2018 09:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527526316; cv=none; d=google.com; s=arc-20160816; b=ddmuW/nRTbONIOJNx4zbOEQKuuCeUswFXlJw0yAawizO+b0dndhHLfMuWVF1X4sZAa dl/seLJvZJBcBr/bjRQMqC07OTOh25iL1m8kn0Yiak3r0yrQ+5kT9JILI5v27UZsxuNJ gedwSEVDml/B+S9adv4hYOraDEwPcjPigGtkyXngCPNKnqO+7YDQ0VSzvurpkdoyYVvs x3a6MuBRCPMZefwAAsNoxbN2vyRmbJGi2jZyKeyNYR1Y7zC792Y0dMMGeJTy1AKMa3ll NKj2+sc3zIF+2vyhgLBgDdUG9FX01RmKrIJnPnwysQqNP5l8/M+d6ZKiQkDQ341+grxo 574w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=9yv3gVIyBkFzM0pymETssEUNL+sFK0E5NQ6B3B/bvjM=; b=X81UqXEy3v0Bl7wAoPnRjJCXrSkRuHmmkVYkdA1HObKN8WKpOqR/ssnAOQl6+6aOWT JmE4I6rR/IqYuvWvo6huFdrEnjMS0mkq4eKD0yL55+gjIgleg+Bthbi/xcpNDZrDCDAg 5jr97+Rgu0k3Nm4LDcNEudgtbm6ACe12n9o9rrQUB9ONTT2U/7l5/73uYLJRZKA1mY+d UGVpsNgYx1+ZWRnILhbHat+Irqs2jcspz8I1le235Ses9AmmEMVGF22miT0HSx0Kfz3z o4WVzMQCKZVD5SFPHUgQbtQ4sFHuGVmhwpx5YIO2QBDC1GMKnrSljO4znbBaMQfUCXMh Ngeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBxgveYZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21-v6si7465116plq.94.2018.05.28.09.51.41; Mon, 28 May 2018 09:51:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBxgveYZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940473AbeE1Qtc (ORCPT + 99 others); Mon, 28 May 2018 12:49:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:54168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754528AbeE1KGO (ORCPT ); Mon, 28 May 2018 06:06:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 954E620843; Mon, 28 May 2018 10:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527501974; bh=nzN4bB2g7/hxUkUQ6MgU3zIbcXpfohqOlGyPpU2plY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JBxgveYZkWZmFR+QcmPPvKjwByTm78Mhz7DktlqzXqmVre9m6EfDaC3Aa+ger7B8c y/Ieb0tamKcfmPIl0QE8chm9kPQQcxK2O5BPLoKtWD9CRCrUNMOqMW5HHhkFKwJYLS cdDQaW0OC4AY/w4RNTHOtK8DrfLwGd46yoz95jW0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gopanapalli Pradeep , Steven Rostedt , Namhyung Kim , Andrew Morton , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 3.18 015/185] tools lib traceevent: Fix get_field_str() for dynamic strings Date: Mon, 28 May 2018 12:00:56 +0200 Message-Id: <20180528100051.539174359@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Steven Rostedt (VMware)" [ Upstream commit d777f8de99b05d399c0e4e51cdce016f26bd971b ] 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 Acked-by: Namhyung Kim Cc: Andrew Morton Link: http://lkml.kernel.org/r/20180112004823.146333275@goodmis.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/lib/traceevent/parse-filter.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -1867,17 +1867,25 @@ static const char *get_field_str(struct 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 */