Received: by 10.213.65.68 with SMTP id h4csp1764673imn; Mon, 19 Mar 2018 12:37:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELuE/VllCVKvoY3oRQzyFWWm6aKWllr+VCh8965m2DXKWsxQmrOJzn1tgfImfxzMKwqu60FU X-Received: by 2002:a17:902:8492:: with SMTP id c18-v6mr13482305plo.40.1521488228275; Mon, 19 Mar 2018 12:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521488228; cv=none; d=google.com; s=arc-20160816; b=Ci04hMN0uSiy6+/gPnH2H/kLQ8NsFr9Z8L8Znc561lazquzflN1jBAiFDyWGicN5S/ y+pYo6Ou4MRY7LPCvNbjoFNvm+HYsgcVAHu+nQb/MwS/W88MQYtKgZg1oEC93UhzCAua O+tF8IU0d5urh2HE6d1dqcsmpWJcfjhwCgz1CbrZGtYnxZFT6jlX/R/0kAsIeb5+dmwR ETatU7QLff45alAA2b8il+Rez0Rb0mWoQh7pDuOhKqRQne1OinFDZLMguBdoRnb2QfI9 ZnioTKFgOKPz+Y5gTwdJlmkQLPaQO9eiapXaHyEWrH520x7AsGpOpeKtK3oHD/0vtKln rgSw== 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=avTj2zxHAuG7zEKgfMr4BUnR/NAZDcz3fv8F6nAiFbc=; b=oOTrq765BCJdFMvpMRt8Tht1QwwWKJWY1Oyd/3eO61T99xEwQo/E/0X4WEcEc1a13T Flt9ttKtAkCDnH03kQ27TIfl7KyxhwcmVdBMoffQ6686vutmh8ADBXJy1xV3M+0lhX5a uQNvGcDYtlYkbxD2Y98xgNGk8bmt6+AAPJOkFa33Nm+J9fVeTOE0W1E/V6qLBowoQROV QHkCYAc9JHrF2BRITnHPanz/0NVyC58Z58z6wu9+ykE/OuPoP6lxAv2hFML5xz9IxbNp cSyz1xqviXluqoqaaFy394GNnoPi4UCTmT5REk8efdvdpl1ofssppoeUo5WrY0xaKY3v CC/g== 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 m13si414165pgs.54.2018.03.19.12.36.53; Mon, 19 Mar 2018 12:37:08 -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 S1031315AbeCSSWj (ORCPT + 99 others); Mon, 19 Mar 2018 14:22:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48548 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031285AbeCSSWa (ORCPT ); Mon, 19 Mar 2018 14:22:30 -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 B2F75128F; Mon, 19 Mar 2018 18:22:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Taeung Song , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , Wang Nan , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.9 068/241] perf annotate: Fix a bug following symbolic link of a build-id file Date: Mon, 19 Mar 2018 19:05:33 +0100 Message-Id: <20180319180754.020953503@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Taeung Song [ Upstream commit 6ebd2547dd24daf95a21b2bc59931de8502afcc3 ] It is wrong way to read link name from a build-id file. Because a build-id file is not anymore a symbolic link but build-id directory of it is symbolic link, so fix it. For example, if build-id file name gotten from dso__build_id_filename() is as below, /root/.debug/.build-id/4f/75c7d197c951659d1c1b8b5fd49bcdf8f3f8b1/elf To correctly read link name of build-id, use the build-id dir path that is a symbolic link, instead of the above build-id file name like below. /root/.debug/.build-id/4f/75c7d197c951659d1c1b8b5fd49bcdf8f3f8b1 Signed-off-by: Taeung Song Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1490598638-13947-2-git-send-email-treeze.taeung@gmail.com Fixes: 01412261d994 ("perf buildid-cache: Use path/to/bin/buildid/elf instead of path/to/bin/buildid") Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/annotate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1250,6 +1250,7 @@ static int dso__disassemble_filename(str { char linkname[PATH_MAX]; char *build_id_filename; + char *build_id_path = NULL; if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && !dso__is_kcore(dso)) @@ -1265,8 +1266,14 @@ static int dso__disassemble_filename(str goto fallback; } + build_id_path = strdup(filename); + if (!build_id_path) + return -1; + + dirname(build_id_path); + if (dso__is_kcore(dso) || - readlink(filename, linkname, sizeof(linkname)) < 0 || + readlink(build_id_path, linkname, sizeof(linkname)) < 0 || strstr(linkname, DSO__NAME_KALLSYMS) || access(filename, R_OK)) { fallback: @@ -1278,6 +1285,7 @@ fallback: __symbol__join_symfs(filename, filename_size, dso->long_name); } + free(build_id_path); return 0; }