Received: by 10.213.65.68 with SMTP id h4csp2177753imn; Sun, 8 Apr 2018 21:47:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+10uW2kjs6pxa+4oXuQqkwXNadU6+CcNJHyIsoralkY2514jAjBLSHRW5QsOXhlaKcDOUY X-Received: by 10.99.108.4 with SMTP id h4mr5022375pgc.368.1523249225327; Sun, 08 Apr 2018 21:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523249225; cv=none; d=google.com; s=arc-20160816; b=mADuRCPWYSwSjA+fOzgi7UjaSwrvm0wIqdkBSUJHlB73iEGHEWceeLxKFcjeGOx0OD ggdd6/078GIuIGnmxpt5ZLYS7cTtPAv09T64TJ/ff9vwzEL0SnTU44wG8tPAA2xGWp4r 2FVlDvDGwkRj35Iva3ywQ+wpodaUtVYU9bWTtFkh3xVns7H/Or7mq3SzXLCZqGP+/6dr BdngVwacv0yFF98GTYi8hUNmVgeKy36WbPgW3PSfYtymoT5oyGOMvlewzz0/WIur5/fq 30mPmg/8+KPgkQAkuO63CXxBRXBmW4bKLFrvi9O2tRHQuQwJAA1WQhRdU3aMI9sSnOgx 8EUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=FL7VU5+1Hg3qfgTcco75C2Aozv/Xkw0r/ynpJnJMTPs=; b=oBfXGu90aCPHdIFSXOrxvxt5BLWtmfmV0e/+zdbPVQ33QXDryEbB8Ez6O9oqz29gty ZlR8SomYejLFJG6hHzF8vJDkBZq4QnWXbWU25RCqZ1qodx8DnT7cJLx56S/dfSipUpXw PNQecyCry8rA67JYDNz4sca1T3tjH+2XeqvBZLSAguv8lgAlkhp/PEmcKMpdRZOYF7Hs y8MwcAh9Y0qPL7EWuR5jrjmd4bPYgNbSb2QNe5cEtCxFJz82zs85obKJ2o05R1LifDDt MtmY+BhCewWgTbIuBFReS3Bd3crCDn9RqG9FjfBNgH7EMPMqV9pWeyZz70LWe70QG4Vk dmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nziSb05t; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si10714515pgr.187.2018.04.08.21.46.28; Sun, 08 Apr 2018 21:47:05 -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=@microsoft.com header.s=selector1 header.b=nziSb05t; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753227AbeDIARt (ORCPT + 99 others); Sun, 8 Apr 2018 20:17:49 -0400 Received: from mail-bl2nam02on0136.outbound.protection.outlook.com ([104.47.38.136]:51875 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753180AbeDIARo (ORCPT ); Sun, 8 Apr 2018 20:17:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FL7VU5+1Hg3qfgTcco75C2Aozv/Xkw0r/ynpJnJMTPs=; b=nziSb05tL7ZnD2eFF4gwB5pkZbZyKkS3PoxVRDTgZxu685CWkjk98luPLMn/XreHH9hheNDQurq0WDNRTWwnp1dBUPiKRXjnuwIZMFA/rgsxN12b6TsWwat48FDRZh+Nk5iKymvBP6ho5sDCCp0gleXDiaEilZbhABIKsz3WIYk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1048.namprd21.prod.outlook.com (52.132.128.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:17:41 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:17:41 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "Steven Rostedt (VMware)" , Andrew Morton , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 031/189] tools lib traceevent: Fix get_field_str() for dynamic strings Thread-Topic: [PATCH AUTOSEL for 4.15 031/189] tools lib traceevent: Fix get_field_str() for dynamic strings Thread-Index: AQHTz5ga7et8I7wda0uPtGU9itjvwg== Date: Mon, 9 Apr 2018 00:17:11 +0000 Message-ID: <20180409001637.162453-31-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1048;7:XNErfR19LlUPTf8AtwCUdt/8jm4g4KU2jCibirC0Uqs1ccGA68FRMsBQF0VPxgaiICgPMJhaFOfjc/puM/jsukAMENZg5096Woe010TUF2/WOGrBoM7zRHQrBQ3qYA9Tm/ByompnIWNpDTMs1IrF79v2szdLfoFedsXEGVLp1jLh7o+Ly1CfXmzb1eikH/0XNHZaw06vvxVI22K6Np9BDmlo5VV++lj6RetMArXPzmRvRBLziXb4hOUU9FF0QeKa;20:+ah1PAMXD+00rF3LYjPp2pM7/+sC/q2qtxeBlaHKII/om4rmlKv6CSMH8fgaiFVedmGWrUZjYUXrLCHgovjRvzmWS63mlucOLCZLZBqhuxDOm3KiZXeO8/LYjFLsb7mmQeLnBmBm2GDQ1bteRfZStoO3+vLtOzwCMCBHV9zlbys= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: dc2b248c-16a6-49b4-6ce4-08d59daf4ef4 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1048; x-ms-traffictypediagnostic: DM5PR2101MB1048: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(42068640409301)(201166117486090); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1048;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1048; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(39380400002)(376002)(39860400002)(346002)(396003)(189003)(199004)(86362001)(1076002)(575784001)(99286004)(6116002)(110136005)(3846002)(54906003)(22452003)(3280700002)(105586002)(2906002)(76176011)(4326008)(6512007)(6436002)(6486002)(3660700001)(6666003)(7736002)(59450400001)(86612001)(25786009)(2900100001)(14454004)(97736004)(6306002)(53936002)(107886003)(68736007)(102836004)(966005)(36756003)(6506007)(26005)(186003)(106356001)(305945005)(5250100002)(72206003)(478600001)(2501003)(10290500003)(81166006)(5660300001)(8676002)(66066001)(316002)(81156014)(2616005)(10090500001)(11346002)(446003)(476003)(8936002)(486006)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1048;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: W8IUfRymIDUkQHyt/+N7fw7cnPC4WSiS7BInrflxZf2Q0IQoMThW4hY8pYL2BlBkDiHK2jIRL2fZ65d/0PNattixwjfppO7w/kQDEV9hC5EZXVCv9o80rtQftS0iEvNNFvME/NTpvptJ8mcG2q+os9dqiL6+kq9mtU2byuUV2ibIg3q2jMGe1dn+ui3RHEcVoSVd5nBSOn4BU4T/GVDvSA4rkqfvmmiiHq0heo3iTHbPU9NxZqeEVizmdHxYRPfvmfnYQ6L64R65V9GX7PvlLjoyHruZD2u25tXUYUQaNBc76wOZDaYJlJQHxrTMlzJoA9F7Z2ux2kERnkHNJgnMi9JU7RYNVnfVp2boGcK9bchdB610p7O3F6zzEiYVjxqYyqUFSuhMra5bdrqhBt0swwl0lz4zDsavbGo9lMm3sFU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc2b248c-16a6-49b4-6ce4-08d59daf4ef4 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:11.0427 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1048 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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/par= se-filter.c index 315df0a70265..7b664fd1ebe8 100644 --- a/tools/lib/traceevent/parse-filter.c +++ b/tools/lib/traceevent/parse-filter.c @@ -1879,17 +1879,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 =3D NULL; + unsigned int size; char hex[64]; =20 /* If the field is not a string convert it */ if (arg->str.field->flags & FIELD_IS_STRING) { val =3D record->data + arg->str.field->offset; + size =3D arg->str.field->size; + + if (arg->str.field->flags & FIELD_IS_DYNAMIC) { + addr =3D *(unsigned int *)val; + val =3D record->data + (addr & 0xffff); + size =3D addr >> 16; + } =20 /* * 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 */ --=20 2.15.1