Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3286093ybb; Tue, 31 Mar 2020 02:07:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvwURbG9bmUnPBarbXZ6IUIcRUccokmhUSvnq1KYjz4LnRqhjWD+qQgTsCwo6n30FuiTVQQ X-Received: by 2002:aca:3302:: with SMTP id z2mr1411597oiz.3.1585645624350; Tue, 31 Mar 2020 02:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645624; cv=none; d=google.com; s=arc-20160816; b=g/vtlkGfLEJG4ASz7bZOIn7NsTCX/7BvQxVNC3C/EyvUVn/QlkwHy11qv4KIfeDHC5 UJT194cr4HmoUDzPOQpdZWElEUs9qlU3JsnxSirXqamDOa9HY64g3D4xNtIi4Pnj8i1s moDt4SxKOtYfHoBdVC9+duZOtHKyOMvyFHNzcDf8pj4cQndwZy09cVxJ5eJozbsTCHC3 dqum+iCMXKDsHHSHcju9HkLU3Fh3VYXY5IXXRGhqs2REhmXTF8ql4M/FIwTCpugIrTVg fNg5lm0ZWPZ4eBCiWQVUgYs4gaL4z3NHiNcPeMvkEEEzGhFb8/qxZtD0/YOSQDhOjzj0 u6rQ== 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=MBiZpN46qQiFue7IyVmDnxzNLyWNMoqPpnAxaASA59I=; b=hnwwaAPa8z2Ndl0NwHj8lcX4I1xLqtXwC0V2DekqiWgdyx7ZpbQyoZg8erfdx+LbZ/ EWWBH17WAyFMEACNUEf3rTsnRCAkLRs9xX6PPh9/Hs0RhnWIhHjcriqJdoEjULNl2sMJ DFjDiX4qNV99f/t8s5gaAmLyGKfAMxxtB/dWoovANm3s+IFIP4TDmp/4MCptCfHB2jIm NrDqEHNhjI4yOQ6jSJ90dQYbpxO6WM09dD5IjBqas7tZOVdZthp6kS4YYVWQvXz4Qbeu +O+giAKqurEXy6vPzL4wFcnES/W5H7eooxCw+oFeDfpcLRqaBTub5oNKg1QWcITezXD+ dJjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DFwitTFH; 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 e8si7170927oif.218.2020.03.31.02.06.52; Tue, 31 Mar 2020 02:07:04 -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; dkim=pass header.i=@kernel.org header.s=default header.b=DFwitTFH; 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 S1730793AbgCaJGe (ORCPT + 99 others); Tue, 31 Mar 2020 05:06:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:47936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730888AbgCaJGa (ORCPT ); Tue, 31 Mar 2020 05:06:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B93E212CC; Tue, 31 Mar 2020 09:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645590; bh=HZ7GlHyZB6RnMvGr6cMq3mUlllhIUvbAbbr628e4hBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DFwitTFHPJ+KlgMRhqfMTsN3bX6pet9TS34uw1S8f/mC5tKg73owSWtO7LIz7v/V2 zWZiV7poqsXs2eITRtJZU3hU0Q2nhfw+rigMq9NeZdeBV3DzJooDff1Cp5wV3DPfLm VhWTR2id6So6R82pDyfKgPQfzXtPToKA+wDdzG+M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Ghiti , Masami Hiramatsu , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Sasha Levin , Arnaldo Carvalho de Melo Subject: [PATCH 5.5 099/170] perf probe: Do not depend on dwfl_module_addrsym() Date: Tue, 31 Mar 2020 10:58:33 +0200 Message-Id: <20200331085434.761153477@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Masami Hiramatsu commit 1efde2754275dbd9d11c6e0132a4f09facf297ab upstream. 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 Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/probe-finder.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -636,14 +636,19 @@ static int convert_to_trace_point(Dwarf_ 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;