Received: by 10.213.65.68 with SMTP id h4csp481525imn; Fri, 16 Mar 2018 09:04:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELt/HsSnbuSeZUZqReWt/Qb3eDqvVlTv7qZBx3yx8miZIOEQ30Li6Z2Yo9belj1IiAX26nZZ X-Received: by 10.99.147.11 with SMTP id b11mr1829869pge.379.1521216268529; Fri, 16 Mar 2018 09:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216268; cv=none; d=google.com; s=arc-20160816; b=ymfmZ0BohpDnIg/xfmabSz2Y6tII/tp7XfTLiqA7TtXkxQ0Tn3owBDULpMWMCrhAhM Y5EoLxYc+nb9zTgnJ2BAijBAosMY/e5KefwTj9T1cmm7Sb2I4Oi766SgvtS7onMex9iu nEciTQC/VXfz+/U2BsjywxHE8SaxX50/cNDmPH5blgiOO09b2UlpK13cCUI6fqyOw5/X YsJIdzohw4I50FMXQRpcPEjq70RzxMkVP+0ZqIMkUUqow7ncTYi4KeobDG9k5zqje8y4 S4GEXxlPQWGLew48174z/m7ckQgt4XnhOP8T89111A88KY1IICNggxhaDudIbrkb8UV7 /yqQ== 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 :arc-authentication-results; bh=zOuBx/se6zq3oQxmT98MHwSpcj8YjJ4jEwIGtlsFj3I=; b=rGv8V/yiBvMaASMXPBO3/TcFHIFOQXL/H/Xd7rRtKd33WjBymz3Q3P/TMWWNJib4gd mFC2AM1afLbRmxXwF0cnFkJVmcGhQeImsSC51JckHop11fqmZOMNPmvwtoDXaVcgRTx9 NmLGhpMs2/fd7PONBxWb9ax57oKONG24TGvkY7OcMEijD7wAdS5UpcYqsH3HTQa8Ea9T tXftRm4P7A4bJmzFxWh5TZ+uTBCV12NqyqsVgxrgl2g6hvuCwWmzkoakQMxP+07ZPPHQ wevIPEuiYluog8LKyUOQnm/2U6DkasyinJNtszzWkM2+xvonEDagfyZTDJDZ/ZQhptZL eqSQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v5si5755282pfl.205.2018.03.16.09.04.13; Fri, 16 Mar 2018 09:04:28 -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; 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 S965317AbeCPQAL (ORCPT + 99 others); Fri, 16 Mar 2018 12:00:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44758 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965191AbeCPPnF (ORCPT ); Fri, 16 Mar 2018 11:43:05 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9A0DD102E; Fri, 16 Mar 2018 15:43:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Hendrik Brueckner , Ravi Bangoria , Heiko Carstens , Martin Schwidefsky , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.15 088/128] perf annotate: Fix objdump comment parsing for Intel mov dissassembly Date: Fri, 16 Mar 2018 16:23:49 +0100 Message-Id: <20180316152340.960643455@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@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 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Richter [ Upstream commit 35a8a148d8c1ee9e5ae18f9565a880490f816f89 ] The command 'perf annotate' parses the output of objdump and also investigates the comments produced by objdump. For example the output of objdump produces (on x86): 23eee: 4c 8b 3d 13 01 21 00 mov 0x210113(%rip),%r15 # 234008 and the function mov__parse() is called to investigate the complete line. Mov__parse() breaks this line into several parts and finally calls function comment__symbol() to parse the data after the comment character '#'. Comment__symbol() expects a hexadecimal address followed by a symbol in '<' and '>' brackets. However the 2nd parameter given to function comment__symbol() always points to the comment character '#'. The address parsing always returns 0 because the character '#' is not a digit and strtoull() fails without being noticed. Fix this by advancing the second parameter to function comment__symbol() by one byte before invocation and add an error check after strtoull() has been called. Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Acked-by: Ravi Bangoria Cc: Heiko Carstens Cc: Martin Schwidefsky Fixes: 6de783b6f50f ("perf annotate: Resolve symbols using objdump comment") Link: http://lkml.kernel.org/r/20171128075632.72182-1-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/annotate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -322,6 +322,8 @@ static int comment__symbol(char *raw, ch return 0; *addrp = strtoull(comment, &endptr, 16); + if (endptr == comment) + return 0; name = strchr(endptr, '<'); if (name == NULL) return -1; @@ -435,8 +437,8 @@ static int mov__parse(struct arch *arch, return 0; comment = ltrim(comment); - comment__symbol(ops->source.raw, comment, &ops->source.addr, &ops->source.name); - comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name); + comment__symbol(ops->source.raw, comment + 1, &ops->source.addr, &ops->source.name); + comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name); return 0; @@ -480,7 +482,7 @@ static int dec__parse(struct arch *arch return 0; comment = ltrim(comment); - comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name); + comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name); return 0; }