Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1263325ybf; Thu, 27 Feb 2020 07:44:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzBURb2FSXcgTjeomQxCde//tFNYDgjDKfNGau68LCoW/AgTUH2N1hCgfxBzSdM3vBKFAaS X-Received: by 2002:a9d:bef:: with SMTP id 102mr208272oth.225.1582818239967; Thu, 27 Feb 2020 07:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582818239; cv=none; d=google.com; s=arc-20160816; b=fAQ8kPAqwgk1cBdke/vGHQeT1d6OeH3839R3PXMSF0qjIY0GIxpS+C0Upvs81+80z+ LW/S2XI3KFoulSdgWaiheeDCKc8ILBlewPCmS1+17iG6GqxkcwL7EKQU/Ng+buw5pD1i v9zpJocEqeN7XYurVHCfOE0PVL4CvZ8x+RofU5+LmFTZ3y6wXrkrJFYI+ZSKtNLZIrBj 1j+fcolL9UtjNUPiBAE4bzC7NVml/9JqXNQImjlfkPR7a02GdHy+ydAoDJLHJ4SYIZIB HIsgn7SfsZh44JJASZ1iDbgP12oBKBDQiCiUrADEm0DEscPmzFOmW8KzcLxeBSI7jMRH Pi/w== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5PPyz/H+GJe/4oVDqplaoitA7GJqGYachV3BAQPshqk=; b=wNJwxmVPrP/ha+gGIoKkYnvNvFCNtpTvx0atHjiLaPhgo5v9ofdQVJtV5t+76FPdqK OV/Jg1aYSmXfA92Aoo4nfCTD2dXKp4l7TxlFVzEbvsVMUzFePJTyehoNngyVhXDE5wzT jjC+J9cLYV+aJ12dMHP/IAUMy7NTIod/xObKDKdVfrSoAEACuvO8SIxypmYGSCa4+vIs a/4f23m9+w3RlKGj1NKHbIBGAyORtMkT3uI2NUnX5aVSirb0/iPY5tFbXYbXdU8JzWuE FvIq7OtjxbNZA1y6/+ilH8AmjkyJoIMXl2HbEOd9cZxyJu6RrkJOUO3S5GjEJGKIqOUs GNLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y4X1bh43; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p19si1938317otq.296.2020.02.27.07.43.47; Thu, 27 Feb 2020 07:43:59 -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=@kernel.org header.s=default header.b=Y4X1bh43; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729842AbgB0PmH (ORCPT + 99 others); Thu, 27 Feb 2020 10:42:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:39258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727592AbgB0PmH (ORCPT ); Thu, 27 Feb 2020 10:42:07 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F4B124697; Thu, 27 Feb 2020 15:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582818126; bh=DaLJtm6KohuN+cM/TAHbV88fZ/uWlTT8YpaA8v4SJKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4X1bh43IsWZ3v+GRJ3RGojBfeMMOA8lMQKn/ZEituuza0yS/63sJXTHs83vXyKY1 09yPCoCNZm0OTqjtexhKZWw8XulpO7ShcJBQZlI9mitjy1aWqGOnacHICExVyPJ3ox g65dj6jJmpewX3cPHBLGdQLV1+T0pfPPOZprsbEA= From: Masami Hiramatsu To: Arnaldo Carvalho de Melo , Alexandre Ghiti Cc: Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Sasha Levin , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [BUGFIX PATCH] perf probe: Do not depend on dwfl_module_addrsym() Date: Fri, 28 Feb 2020 00:42:01 +0900 Message-Id: <158281812176.476.14164573830975116234.stgit@devnote2> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200228002553.31b82876b705aaabbd717131@kernel.org> References: <20200228002553.31b82876b705aaabbd717131@kernel.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 1c817add6ca4..e4cff49384f4 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;