Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1298887ybf; Thu, 27 Feb 2020 08:21:18 -0800 (PST) X-Google-Smtp-Source: APXvYqw3k9v8AXiVH/dLiegjpX3VAu0y9bbqTpL0jldRmPSVFIp9bC4yzi4nQrZdTA0rD7pcbwkQ X-Received: by 2002:aca:5094:: with SMTP id e142mr3874355oib.101.1582820478295; Thu, 27 Feb 2020 08:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582820478; cv=none; d=google.com; s=arc-20160816; b=sLFmwRKn6fmsEBhIdVnNOewlscdAhb2/iFNK/n6en3BvG1/AmPReAZLh1mGJLhdVoE U8Msvd7z1Fwcs/+S7XrBdtf/gF+Ke1oJb8n+eJyzIkVrAh75ac0nUoNUsdzKPTpKcws/ 0l6cGJDj+V54o60ayF1OT2mgTqOKmYlD9lWrphypjrGma0FjKP9Jg4VdvO+Yy6iQenzK 2xj1m1uTps6PJZ2eikeBHX4VQbYPEI+cB+TllBotMxdRtP4Njw21r/rzXQcAYuSt6jya gZ3PX+vRYkfWxZdWpFwXUImHgZ7qFcf199YmEGYkRrPocY5pec7kVm1W4jARLfCuUOxs pooQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Kz1lRelgvxwS4GmPQVLEtFEGIAGj6cCivo3qi5FNQ7w=; b=MKukh+iuiuu1TMarLCsNi+969HMo90x1GYhsaUS1DAYieIl4SmNfoErCCO+Gf8FArx sBeIEmEA9QxqPI/lBjTbkXUW4ymSf+c6d2YwGTkjObqPxIm3bKzguHqvuSFfezTek7Yw Dm0uFOUCs17hDWiaKA+8cBRJdduFxEvG3LolH8RMiVkcKD30zP1UvZqilLbjlxiaURly VyYfAamQR1JTOAYIBdkGnkyHLY/IjgA5bEmRQKo8XqldM2OfqE6lhb2vJs+SM3twyHpG Av6//tb1rvRR4uwREQ+eX2cP+ualW3ONSIQx1QgOW7M+UaYOr+VL/KfXpGQB0HgFH32j EIPQ== 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 c67si87215oib.276.2020.02.27.08.21.01; Thu, 27 Feb 2020 08:21:18 -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; 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 S1730015AbgB0QUr (ORCPT + 99 others); Thu, 27 Feb 2020 11:20:47 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:43437 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728963AbgB0QUr (ORCPT ); Thu, 27 Feb 2020 11:20:47 -0500 Received: from [10.30.1.20] (lneuilly-657-1-5-103.w81-250.abo.wanadoo.fr [81.250.144.103]) (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id E9614240011; Thu, 27 Feb 2020 16:20:39 +0000 (UTC) Subject: Re: [BUGFIX PATCH] perf probe: Do not depend on dwfl_module_addrsym() To: Masami Hiramatsu , Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Sasha Levin , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20200228002553.31b82876b705aaabbd717131@kernel.org> <158281812176.476.14164573830975116234.stgit@devnote2> From: Alexandre Ghiti Message-ID: <787c2915-c868-358a-481d-1ffd355d92db@ghiti.fr> Date: Thu, 27 Feb 2020 17:20:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <158281812176.476.14164573830975116234.stgit@devnote2> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/27/20 4:42 PM, Masami Hiramatsu wrote: > 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; > I have just tested your patch, that fixes the issue, so you can add: Tested-by: Alexandre Ghiti I added stable in cc. Thanks, Alex