Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp690375ybg; Thu, 19 Mar 2020 07:06:21 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvT9KtFvyMBtlDuB62HD6pXl+V4mFAnTnogrxhsLvv/prPgcOtD8mv39wouzEX+g8o0zhFK X-Received: by 2002:a9d:6358:: with SMTP id y24mr2570330otk.49.1584626781012; Thu, 19 Mar 2020 07:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584626781; cv=none; d=google.com; s=arc-20160816; b=1Fq58HseD4FxcCbHmSr9gMzea9xtaJYEPqCiKzaiPB7GbViwVQOOmtRmgTI/7GQDun o/ZAiTHKrzRSyajqznQvFiK9gj3I2Jy7YiHAHS+K5XbX5Pz3akLcmFvJPhWAMf6RhTRr 2iWzNHbqK2vaORJ5GIjvgJ/q+h9TsJ8QFUTDqpXLdJc31cKlZ5OOq2obCUKLLtQvcwWL tqxyojMn/rU0quP1W6aGp5cSP3mv+kvraM5QMUonM2vqp8yJQ2MAGv7Yg+jUD6zO2Ufy 8Al+0zLDeafuDCSs4bxhOaj9jmMgtETFF8yqw2tyK1TLbVAx8SkuuW+uiKtysBIXEXoc pFwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=fXS+BWfQgDZUBC7EllamHlqWx8b2H33BPtFB0XywDX4=; b=I6wfoxORkj9jI7OC+43b1onqRVfNgX7VlX398rPJ3hSn9N9n5Aup362SZWalrj2ysW 0V3awcPGho5RgWIJQpyWEPOQe8Or8UES6HZ0vKZ0a1Q0ceWPgksu1BPvEaCpLR/F1DH6 Eo3wZ3ttE5jix1tWyJcBB4ERNmcvPsEUIIJIQMEPf4zd2NazRrMyAT9RvURlm3/9VxJG VG1eH95GUUao+JJINwlwIi9+Hxie/FBSn1ewyeybqfduLHjzuQQfDw6g59Xg2knwoN22 D0PHN2vxXhRJVkhCxx169u6IXr2Bcv4UCCJ2/+yxXDFDaex9DPrlVOXhjTKYt28ibjer LG8w== 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 18si1124242oin.182.2020.03.19.07.05.56; Thu, 19 Mar 2020 07:06:21 -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 S1727731AbgCSOEz (ORCPT + 99 others); Thu, 19 Mar 2020 10:04:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60728 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727252AbgCSOEz (ORCPT ); Thu, 19 Mar 2020 10:04:55 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jEvmt-0001oU-TI; Thu, 19 Mar 2020 15:04:44 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 6481B1C22A1; Thu, 19 Mar 2020 15:04:43 +0100 (CET) Date: Thu, 19 Mar 2020 14:04:43 -0000 From: "tip-bot2 for Masami Hiramatsu" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf probe: Do not depend on dwfl_module_addrsym() Cc: Alexandre Ghiti , Masami Hiramatsu , Alexander Shishkin , "Greg Kroah-Hartman" , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Sasha Levin , Arnaldo Carvalho de Melo , x86 , LKML In-Reply-To: <158281812176.476.14164573830975116234.stgit@devnote2> References: <158281812176.476.14164573830975116234.stgit@devnote2> MIME-Version: 1.0 Message-ID: <158462668303.28353.5082928065747740360.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 1efde2754275dbd9d11c6e0132a4f09facf297ab Gitweb: https://git.kernel.org/tip/1efde2754275dbd9d11c6e0132a4f09facf297ab Author: Masami Hiramatsu AuthorDate: Fri, 28 Feb 2020 00:42:01 +09:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Mon, 09 Mar 2020 10:43:53 -03:00 perf probe: Do not depend on dwfl_module_addrsym() Do not depend on dwfl_module_addrsym() because it can fail on user-space shared libraries. Actually, same bug was fixed by commit 664fee3dc379 ("perf probe: Do not use dwfl_module_addrsym if dwarf_diename finds symbol name"), but commit 07d369857808 ("perf probe: Fix wrong address verification) reverted to get actual symbol address from symtab. This fixes it again by getting symbol address from DIE, and only if the DIE has only address range, it uses dwfl_module_addrsym(). Fixes: 07d369857808 ("perf probe: Fix wrong address verification) Reported-by: Alexandre Ghiti Signed-off-by: Masami Hiramatsu Tested-by: Alexandre Ghiti Cc: Alexander Shishkin Cc: Greg Kroah-Hartman Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Sasha Levin Link: http://lore.kernel.org/lkml/158281812176.476.14164573830975116234.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-finder.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 1c817ad..e4cff49 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -637,14 +637,19 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod, return -EINVAL; } - /* Try to get actual symbol name from symtab */ - symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL); + if (dwarf_entrypc(sp_die, &eaddr) == 0) { + /* If the DIE has entrypc, use it. */ + symbol = dwarf_diename(sp_die); + } else { + /* Try to get actual symbol name and address from symtab */ + symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL); + eaddr = sym.st_value; + } if (!symbol) { pr_warning("Failed to find symbol at 0x%lx\n", (unsigned long)paddr); return -ENOENT; } - eaddr = sym.st_value; tp->offset = (unsigned long)(paddr - eaddr); tp->address = (unsigned long)paddr;