Received: by 10.213.65.68 with SMTP id h4csp2119233imn; Sun, 8 Apr 2018 20:10:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/+1LA4+zykAv43Bcqooc0D1HN/oUUfKxAH76cc0IO5lXeOyerXm9LnyBiXg1QXP+rcDrVm X-Received: by 10.99.42.148 with SMTP id q142mr23801622pgq.425.1523243449135; Sun, 08 Apr 2018 20:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243449; cv=none; d=google.com; s=arc-20160816; b=ExyP1P7g6K9cG4/0/kZIVaavzoUqm3MlMQGz9Qd1jo8tXu4TcJVzRuVYkA95LSIqIs h6UKMzBk8YX56d5MMBe1nxQY5dkKxFN10wbWfh/7fq3gyK9F0DilykSL++QYE3Q/yMC8 +9lnameATMU37q5Bdd/UVyztLr7/mqMKZQfegU/8IlB6EZMYY2yBnv4BdtGWYRWDyCxX /mzKboWAiqAiMpVeeXy2ztmuCTx25bXpMp2Lh+7GudookFu4V92XDXAlsWRKbyLu7bZ/ I2MIMZSomtI3hafMVerUKXa9jG8ko3WFDnyDDBQj6bbSPSoy38jo2h909QvgGFgvY27u 67aw== 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=BGZGKVLPX2ozJv971rgLYMF9s565z/nxvw5lRzjb+VE=; b=0XHiX5L387H+pogH7TbhseoVMnBSMN8KvalgKN85Vs7abFXeUqIoQMEsSfAs/avmgi cojSZwwrb+N+vzspI9uughIgA8SlLbTcx1pm3J2C7qsimsKb99G2jvGnJT4rRx6twOBZ 10SLvXJiL7uQO2U/i2j4Vrw+Oa0m7/9X8RfE9Ma32g9BDIB8hGswIdbwToW2UXSDAibR WDes8dQSS45jqYdG038/jOhUfE2mf5815gs0fpyRLx3OiDhAKuT3jjgkDLKoR2u6gpIi cROtfineJPvUiwtePoPqMnq/vneCrSoOsHPZJFPV5EOqfMF4HNpRO+fRJrzsiZOEBTlg hqGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=G1LdfgIV; 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 m8si10535042pgr.85.2018.04.08.20.10.12; Sun, 08 Apr 2018 20:10:49 -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=G1LdfgIV; 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 S932737AbeDIBz5 (ORCPT + 99 others); Sun, 8 Apr 2018 21:55:57 -0400 Received: from mail-by2nam01on0100.outbound.protection.outlook.com ([104.47.34.100]:61248 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932170AbeDIAc5 (ORCPT ); Sun, 8 Apr 2018 20:32:57 -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=BGZGKVLPX2ozJv971rgLYMF9s565z/nxvw5lRzjb+VE=; b=G1LdfgIVgFZadKZ6zhDZMMc8Ore/tYU4odGGn3yeXO+e3cbF/YCfq16xU1x5i+WvFY/NcM0d1aoTtniNxGmpwoMNa/iQGiLONjKKpy3AinEN/c38wCgV+nIcTYMuegfYgAggGynw81UGxCgS8eDDJYnXJbb73oG7ci9fNbSgMZ0= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0998.namprd21.prod.outlook.com (52.132.133.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.0; Mon, 9 Apr 2018 00:32:54 +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:32:54 +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.9 223/293] tools lib traceevent: Fix get_field_str() for dynamic strings Thread-Topic: [PATCH AUTOSEL for 4.9 223/293] tools lib traceevent: Fix get_field_str() for dynamic strings Thread-Index: AQHTz5lOCI3gA6iahkyqtoB6beF+Qg== Date: Mon, 9 Apr 2018 00:25:48 +0000 Message-ID: <20180409002239.163177-223-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0998;7:wfPgjQ24V5U5Of3OkTJvhFs0pbNOc6Oxes2hROYPml1HihyD/uJMXTJrWPN3bLaBSb42zCBSlRvv3S21leCHAgNFYt8odAgBLqxWMrJvK2vNWOmWi2RIbwTKJoGpjKOZDHVz3VC1OBMCZCu4PxNmzDK9VAq+r66mz0rQRSbC2PmYbp4ybdVlmGfQKFkh4w1rLMpJmU4Q3UElltu3dpxZ87G5LVRXj/O292KF9aMJ5wi+4IGxX5eM7W9ZOJR2Xktn;20:8202pT3ZZah19ot7RnD0tFsZjS0ojIe9yC7Sp0DzE9H1uPRF5gSKMg7vHkJ/J7/34nUQSb1ZaCL9xReM0LY9IrP6PhfljNRhf9g285fhK38iHbaHR1mKPFUABrIemHdztkrh2nPkE0+0yCOIGyw5YnKTjxlF7IbFjjFbczag2hc= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: f384954e-adc9-409f-bcce-08d59db16f16 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: 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:DM5PR2101MB0998;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0998; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39380400002)(376002)(396003)(366004)(39860400002)(189003)(199004)(25786009)(59450400001)(105586002)(14454004)(76176011)(68736007)(2906002)(316002)(97736004)(8676002)(966005)(86612001)(3660700001)(3280700002)(102836004)(6116002)(4326008)(8936002)(36756003)(22452003)(81166006)(81156014)(54906003)(6506007)(10090500001)(2501003)(6512007)(186003)(6666003)(3846002)(486006)(5660300001)(6306002)(26005)(7736002)(5250100002)(305945005)(99286004)(2900100001)(110136005)(1076002)(6436002)(53936002)(106356001)(575784001)(107886003)(72206003)(86362001)(476003)(446003)(66066001)(11346002)(478600001)(10290500003)(2616005)(6486002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0998;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: PFdGzKP7IFRgjVXgsVE34QGC1k2i9wSyPSAHwOBtFpsIn5Ymol9pdq31DM+RYtFjX8MHe1WeOJaidQbcfqVX713eZ66aIgNlFTeXI6HHFD6bN53UCPbsjiQ0asLtSe6B1fCIXWcvcT6gasE4E5dxaqdEp/dTa7CCERafjByBZYT4SK6NA9gd0/hlQ3K+CpOBRzQQ18N6gHXCL4bM4XAFZH1SkKlbttNW/07LtQ2WIhf6dzZpBiJCl0QlWJD2cQ1KtC1XSuEGuv5+M7y4u873F72aPAFz+jwfVzkHhg89PIS/GtkkYLPeN5QNtLNHiR1xs9p99D9hAe3OtoezR1PiM6sL/oGTo+jV4EH8lVluUJeBfNAC+3uoM4x79c6GxfT25UJvABQIS0jvSwz+w+iuaCIOWaWjQkKfk3GbMTtC8BI= 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: f384954e-adc9-409f-bcce-08d59db16f16 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:48.3316 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 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 7c214ceb9386..5e10ba796a6f 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