Received: by 10.223.185.116 with SMTP id b49csp1111264wrg; Sat, 3 Mar 2018 15:54:42 -0800 (PST) X-Google-Smtp-Source: AG47ELvF1VJUInU3p6g+kJ4z3dcQ12wXQovAF5cIJ6aVx1ralvbsF94IFz914hON7cc44vbCW9rb X-Received: by 10.98.75.129 with SMTP id d1mr10487464pfj.19.1520121282158; Sat, 03 Mar 2018 15:54:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520121282; cv=none; d=google.com; s=arc-20160816; b=YWOcMI0e64F0pSRkUH9IyYyn9ASS78DCsZdYF0IIMaqGezIg8odGFPag9N0A2V1RIy 5bLL/x6lgbDQrrbCiF97kCUjaI+1g9Ga7cqZVvBnZMard6crU4EmK9kBSs4TNRyQASx8 2TvFZnr0t56hzPy86vrlZqECArKSFs2JrMC24UJC8xkqYocR+Cb3uzbmYQyw6R7r8wa1 CBtYNneVKUkce+Xpn+xWIYhpsaWnzp4tDlTjC/cA6UQi4IHVkgNb0RjYf9HE4PB5Azl5 qYtkEiGu8MDXuWaE/ZTWPcUyV+jGB8XMSITlUYCnWqBF26EE3hqR2+H/vtrkt/1vP8vW LAlg== 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=5ZELDgDnr69tBUjfzU+80KwPUIIAIadFnOpVaQP96Vw=; b=v4sRv8GMtDa954SwKlxQP8h/JGge6ZqbrO54heEIrZutakGudxzGTdEjgh5sNoFNGf NXnlZ5sLSRE7C0M3iLbzKkF6xwJ/DDDom81H9n+PlH9VfGFdh/Fg7lDlyzsqF/Pv1Aca GUVxGDUxtogjqFKw0AhBupI2kYAyLVYs6IqsJ4iBu+wc8eDn8mqzdk6IfRbLjOvlV/lt l6Pfr7WIwKxg/qnpdJbMT7Kr2dxZQaI4XIiyLQBHXzjTXK25raJQBzu2JQOJksvIAooG kfhiNYmHKNV5W01uyZtB6Sb8mhLbl73AshQQRD4DGo6w1pDGUVTB2sMijn1IAB+UDtSf JEWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=NBm8YL/i; 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 d88si7452292pfe.215.2018.03.03.15.54.28; Sat, 03 Mar 2018 15:54:42 -0800 (PST) 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=NBm8YL/i; 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 S934068AbeCCXxe (ORCPT + 99 others); Sat, 3 Mar 2018 18:53:34 -0500 Received: from mail-by2nam01on0092.outbound.protection.outlook.com ([104.47.34.92]:32992 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933891AbeCCWc6 (ORCPT ); Sat, 3 Mar 2018 17:32:58 -0500 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=5ZELDgDnr69tBUjfzU+80KwPUIIAIadFnOpVaQP96Vw=; b=NBm8YL/iT9Bg5UbQv+qIruzv+vsw92G+YxMH+ff121XtBt+r52M5idEfT5fnobDsvcrJO5gl8HKhcOjkM6RmEuSu96g1VxNZlb4rwidZv9FjKNQOSjLFuhXhJqSCvQk7S8vHaBjZVQ0Asf4O8yDGYJbE8/OLtqC2WVPFJ35z9uY= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1097.namprd21.prod.outlook.com (52.132.149.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Sat, 3 Mar 2018 22:32:54 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:32:54 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Taeung Song , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , Wang Nan , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 070/219] perf annotate: Fix a bug following symbolic link of a build-id file Thread-Topic: [PATCH AUTOSEL for 4.9 070/219] perf annotate: Fix a bug following symbolic link of a build-id file Thread-Index: AQHTsz74EiO3k2vYxkmoeWwhIR9j5w== Date: Sat, 3 Mar 2018 22:28:36 +0000 Message-ID: <20180303222716.26640-70-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-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;MW2PR2101MB1097;6:+g6DtS1diWYjsEgnARWukALIe9Zls4kFcw97HUAKgacOqH89TJM0BWjREuSrogb+/9oiCLvyUIifHOHPcls6LVe3Y7F75IdIDWqrqCfiGudV+vGmFQxpaRhcZYJYHsf3lP+/cgua48NmLx+0RB3fv8+cEbaojsbToKPmWo1o7l8qpBuSLiiw+4A7KuEIosI/xaVh/zdM6XOFbmpmz0a2WJlofouAOah8GsolUNuXQthn+oa9Vg5/ryvOQsipxcvMC4ETe/GcTStC6bx1OItqOODYnn3Iypo8M6wFhTb5PVglmHkNY/oaWyLy6RzjEMFRWl//A2xXwjXEXPtnurRGT7mdypVOUSpf+IOh4W1cbcCRCDv/qTJMDh7ckIp5mppo;5:eM6vgF+RfuT+HIIGhnmVkrMfQ2LYsmtf71twcu++1nOvDCkyHu5GhSInpe+0Tb9KMc1k34YPb0NyIxKQuAJe62M4sg/DCxlKqhS+rOaVMwyeqTrGEKVn+bj+yslsGdmy7LTYxb46zfvbV/4wxd8EivTp2HsOI31qXsgsonKuCK8=;24:x3jpKLbRNP4fVE1lAwAbSE2A0rdrz7SbAF3brjHcJU9Eg08zasA1uEE0UyKi46gogqW/7FhYUnVkty8trN+G4AsVHOozdppWZQ8v/YsPwRc=;7:5Iw4sK/yQ6QjMOoj+ez6UAarXxz3cuVkb8mrcYCVDg/cZ559OI7vRd28wPc+q2jItgxYote72YWONYolYYit0oy5+UfKLxPAza/ijdKXPK3glH+qnGYDeNJiec7b1QDfMdAtk2TnjBCSb/OMFcnzdTJq3v7ZNUKECL+7fLzzzKjpM+v2+sSpWPQ0wjsCBecHbOlOkxOb/3A+fadXOQcsmb6sLE209Pgo3rwsidPA+y3eWOOd670ppvHZ+3zUaZPX x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 826872c5-510f-4ee7-0de1-08d58156b4b9 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1097; x-ms-traffictypediagnostic: MW2PR2101MB1097: 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)(50582790962513)(85827821059158)(42068640409301); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231220)(944501244)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:MW2PR2101MB1097;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1097; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(39380400002)(396003)(39860400002)(346002)(189003)(199004)(305945005)(105586002)(36756003)(3660700001)(86362001)(6666003)(66066001)(2900100001)(5660300001)(8676002)(10090500001)(81166006)(81156014)(8936002)(22452003)(10290500003)(2950100002)(39060400002)(4326008)(25786009)(5250100002)(2501003)(68736007)(7736002)(72206003)(325944009)(14454004)(966005)(478600001)(186003)(110136005)(26005)(316002)(2906002)(6306002)(97736004)(6512007)(99286004)(107886003)(54906003)(1076002)(6506007)(106356001)(53936002)(59450400001)(6116002)(3846002)(102836004)(6486002)(86612001)(3280700002)(6436002)(76176011)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1097;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: pEsNrDCsGRy9Xj0qY9ONTNbl6OObBYyDsV9QR+8U0+K5Le34D+LO/qAeOUSLEbQ90Dl2fuHxw7FjZnXllaITlgRpIqeID8fXP30QwV/72w7sHOqy70g8epKZ66YnXPBhVLYpqJRaIW5uSXPjf7QsPM6j8wzpuCBhA7KWPfFZOcQ= 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: 826872c5-510f-4ee7-0de1-08d58156b4b9 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:28:36.6975 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1097 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.tae= ung@gmail.com Fixes: 01412261d994 ("perf buildid-cache: Use path/to/bin/buildid/elf inste= ad of path/to/bin/buildid") Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/annotate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 430d039d0079..a38227eb5450 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1250,6 +1250,7 @@ static int dso__disassemble_filename(struct dso *dso,= char *filename, size_t fil { char linkname[PATH_MAX]; char *build_id_filename; + char *build_id_path =3D NULL; =20 if (dso->symtab_type =3D=3D DSO_BINARY_TYPE__KALLSYMS && !dso__is_kcore(dso)) @@ -1265,8 +1266,14 @@ static int dso__disassemble_filename(struct dso *dso= , char *filename, size_t fil goto fallback; } =20 + build_id_path =3D 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); } =20 + free(build_id_path); return 0; } =20 --=20 2.14.1