Received: by 10.213.65.68 with SMTP id h4csp500819imn; Fri, 16 Mar 2018 09:39:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELtEeQQvNEbFlCEGmnDvDhRbUDQsQnoOX5UKjakoo8FLYLci7haE5M5s3BSvPkx+NfAKeMOY X-Received: by 2002:a17:902:309:: with SMTP id 9-v6mr2876008pld.63.1521218350934; Fri, 16 Mar 2018 09:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521218350; cv=none; d=google.com; s=arc-20160816; b=C29MaNQMyrNxTI9Om27fB2fR++Kf2EiXrEWBX9koMDBobfQS69fhSg2CvNGjvljzNs ZTJHlG7FOCjgO5yztxyYvUF7eThKJIqtlI07p1KQhW2WdxCW8XNbD1l74JX8pij60EDS /Yo0I2aNC4v4I0THnTFJcQJyfDYkirWlGcewucUw7WMPueXIWwg9oo+X6zWI4aRfJGEr z7dBBdnYQs4H3vFWuS4j7Bf4bpFOk6bnP8OXK4YpclB9ct6ZXiBNO79ZaYxWg+b1rFbh r+9HMMagQgeW/+aini5+VqmGowc4tAzNMhxLfCyyEZkWX9cbAFaoTD4ZRWVwTEG7wknF 1gIw== 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=qYedttp88YpCjoY/sy9IjTpoOO+CRh07cHD4W2s/C64=; b=kDjoFX6HXdYqDn1NNN37lxGbTqDlL3YR7te4fcRdSligJ9IKnBAY5GcNaHb/8ZaOQE AL6IuQhCA5+rDFLqoTzCJrB5MN6xlZ45TEIhfnwOR++S2TdXOrkgSQuxww6LDaylWYUf Gm3tpiK72DmzPLhjcJnjFV1wpf3DzgcNbaim8p0ImHh4FbXMAM/Hx0fNoAdS0lphgwUz 31estTNjHIvP6MAxLHMz6u3S/IDN6b4kMlqY5L8XMpafh10mS1I8GX2I+38AytFLUxwJ gRPxtY3h8XnF/74lnM3sefJYRtny41glOw+IxIbdcyTy+hH2bKf31/CNP3f3ObDI1Qms agrQ== 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 d8-v6si3387326pli.332.2018.03.16.09.38.57; Fri, 16 Mar 2018 09:39:10 -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 S934390AbeCPPhL (ORCPT + 99 others); Fri, 16 Mar 2018 11:37:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40548 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934376AbeCPPhG (ORCPT ); Fri, 16 Mar 2018 11:37:06 -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 4E6D21221; Fri, 16 Mar 2018 15:37:05 +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.14 073/109] perf annotate: Fix objdump comment parsing for Intel mov dissassembly Date: Fri, 16 Mar 2018 16:23:42 +0100 Message-Id: <20180316152333.957937973@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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 @@ -323,6 +323,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; @@ -436,8 +438,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; @@ -481,7 +483,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; }