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-prev] [day] [month] [year] [list]
Message-Id: <1461659905-11147-2-git-send-email-ravi.bangoria@linux.vnet.ibm.com>
Date:	Tue, 26 Apr 2016 14:08:25 +0530
From:	Ravi Bangoria <ravi.bangoria@...ux.vnet.ibm.com>
To:	linux-kernel@...r.kernel.org
Cc:	acme@...nel.org, peterz@...radead.org, mingo@...hat.com,
	alexander.shishkin@...ux.intel.com, mhiramat@...nel.org,
	wangnan0@...wei.com, namhyung@...nel.org,
	srikar@...ux.vnet.ibm.com, naveen.n.rao@...ux.vnet.ibm.com,
	Ravi Bangoria <ravi.bangoria@...ux.vnet.ibm.com>
Subject: [RFC v2 2/2] perf probe: Fix module probe issue if no dwarf support

Perf is not able to register probe in kernel module when dwarf supprt
is not there(and so it goes for symtab). Perf passes full path of
module where only module name is required which is causing the problem.
This patch fixes this issue.

Before applying patch:

  $ dpkg -s libdw-dev
    dpkg-query: package 'libdw-dev' is not installed ...

  $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
    Added new event:
      probe:foo_show (on foo_show in /linux/samples/kobject/kobject-example.ko)

    You can now use it in all perf tools, such as:

  perf record -e probe:foo_show -aR sleep 1

  $ cat /sys/kernel/debug/tracing/kprobe_events
    p:probe/foo_show /linux/samples/kobject/kobject-example.ko:foo_show

After applying patch:

  $ ./perf probe -m /linux/samples/kobject/kobject-example.ko foo_show
    Added new event:
      probe:foo_show (on foo_show in kobject_example)

    You can now use it in all perf tools, such as:

  perf record -e probe:foo_show -aR sleep 1

  $ cat /sys/kernel/debug/tracing/kprobe_events
    p:probe/foo_show kobject_example:foo_show

Signed-off-by: Ravi Bangoria <ravi.bangoria@...ux.vnet.ibm.com>
---
Changes in v2:
  - made find_module_name static

 tools/perf/util/probe-event.c | 19 +++++++++++++++----
 tools/perf/util/probe-event.h |  2 --
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 5f1a9bf..c570a6c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -285,7 +285,7 @@ static bool kprobe_warn_out_range(const char *symbol, unsigned long address)
  * inspect elf and find out what is actual module name.
  * Caller has to free mod_name after using it.
  */
-char *find_module_name(const char *module)
+static char *find_module_name(const char *module)
 {
 	int fd;
 	Elf *elf;
@@ -2566,6 +2566,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 	struct probe_trace_point *tp;
 	int num_matched_functions;
 	int ret, i, j, skipped = 0;
+	char *mod_name;
 
 	map = get_target_map(pev->target, pev->uprobes);
 	if (!map) {
@@ -2650,9 +2651,19 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 		tp->realname = strdup_or_goto(sym->name, nomem_out);
 
 		tp->retprobe = pp->retprobe;
-		if (pev->target)
-			tev->point.module = strdup_or_goto(pev->target,
-							   nomem_out);
+		if (pev->target) {
+			if (pev->uprobes) {
+				tev->point.module = strdup_or_goto(pev->target,
+								   nomem_out);
+			} else {
+				mod_name = find_module_name(pev->target);
+				tev->point.module =
+					strdup(mod_name ? mod_name : pev->target);
+				free(mod_name);
+				if (!tev->point.module)
+					goto nomem_out;
+			}
+		}
 		tev->uprobes = pev->uprobes;
 		tev->nargs = pev->nargs;
 		if (tev->nargs) {
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 0468fa3..e54e7b0 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -166,6 +166,4 @@ int e_snprintf(char *str, size_t size, const char *format, ...)
 int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
 			    struct perf_probe_arg *pvar);
 
-char *find_module_name(const char *module);
-
 #endif /*_PROBE_EVENT_H */
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ