lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZyACsIFUETsr7-09@x1>
Date: Mon, 28 Oct 2024 18:31:28 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
	"Frank Ch. Eigler" <fche@...hat.com>,
	Francesco Nigro <fnigro@...hat.com>,
	Aaron Merey <amerey@...hat.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Ian Rogers <irogers@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
	Kan Liang <kan.liang@...ux.intel.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	linux-perf-users@...r.kernel.org
Subject: [PATCH 1/1 perf-tools-next] perf probe: Fix retrieval of source
 files from a debuginfod server

When perf is linked with libdebuginfod:

  root@...ber:~# ldd ~/bin/perf | grep debuginfod
	libdebuginfod.so.1 => /lib64/libdebuginfod.so.1 (0x00007ff5c3930000)
  root@...ber:~# perf check feature debuginfod
            debuginfod: [ on  ]  # HAVE_DEBUGINFOD_SUPPORT
  root@...ber:~#

And we don't have a debuginfo package installed for the binary we're
trying to use, vmlinux in this case as we didn't specify any using 'perf
probe -x', it will use the build for the running kernel:

  root@...ber:~# perf buildid-list -k
  38e927fd7799d50dbc4d99ec5e3f781b6105a6a9
  root@...ber:~#

And communicate with a debuginfo server, be it configured in a
~/.perfconfig file, excerpt from the 'perf config' man page:

       buildid-cache.*
           buildid-cache.debuginfod=URLs Specify debuginfod URLs to be
	   used when retrieving perf.data binaries, it follows the same
	   syntax as the DEBUGINFOD_URLS variable, like:

               buildid-cache.debuginfod=http://192.168.122.174:8002

Or via the DEBUGINFOD_URLS env var, as distros like fedora do by
default:

  root@...ber:~# echo $DEBUGINFOD_URLS
  https://debuginfod.fedoraproject.org/
  root@...ber:~#

To pick and cache just what is needed, instead of requiring the manual
installation of the entire kernel-debuginfo package, which is really
large.

It will, in this example, use the following cache files, deleted
before/after this patch just to test the whole process:

  root@...ber:~# rm -f /root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/source-a1414a5d-#usr#src#debug#kernel-6.11.4#linux-6.11.4-201.fc40.x86_64#net#ipv4#icmp.c
  root@...ber:~# rm -f /root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/debuginfo

Before this patch:

  root@...ber:~# perf probe -L icmp_rcv
  Failed to find source file path.
    Error: Failed to show lines.
  root@...ber:~#

This is because 'perf probe' was using just the relative file name, in
this case "net/ipv4/icmp.c", that is where the 'icmp_rcv' function is
located, if we add it and comply with the debuginfo_find_source()
function man page, it contacts the server, finds the necessary files,
cache them locally and all works:

  root@...ber:~# perf probe -L icmp_rcv | head
  <icmp_rcv@...ot/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/source-a1414a5d-#usr#src#debug#kernel-6.11.4#linux-6.11.4-201.fc40.x86_64#net#ipv4#icmp.c:0>
        0  int icmp_rcv(struct sk_buff *skb)
           {
        2  	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
           	struct rtable *rt = skb_rtable(skb);
           	struct net *net = dev_net(rt->dst.dev);
           	struct icmphdr *icmph;

           	if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
        8  		struct sec_path *sp = skb_sec_path(skb);
  root@...ber:~#

Cc: Aaron Merey <amerey@...hat.com>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Francesco Nigro <fnigro@...hat.com>
Cc: Frank Ch. Eigler <fche@...hat.com>
Cc: Ian Rogers <irogers@...gle.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Kan Liang <kan.liang@...ux.intel.com>
Cc: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/probe-finder.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 18181017f5fd344e..c2ca94e29aca3849 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1874,7 +1874,11 @@ int find_source_path(const char *raw_path, const char *sbuild_id,
 	const char *prefix = symbol_conf.source_prefix;
 
 	if (sbuild_id && !prefix) {
-		if (!get_source_from_debuginfod(raw_path, sbuild_id, new_path))
+		char prefixed_raw_path[PATH_MAX];
+
+		path__join(prefixed_raw_path, sizeof(prefixed_raw_path), comp_dir, raw_path);
+
+		if (!get_source_from_debuginfod(prefixed_raw_path, sbuild_id, new_path))
 			return 0;
 	}
 
-- 
2.47.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ