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]
Date:   Tue, 25 Feb 2020 22:41:42 +0800
From:   <zhe.he@...driver.com>
To:     <peterz@...radead.org>, <mingo@...hat.com>, <acme@...nel.org>,
        <mark.rutland@....com>, <alexander.shishkin@...ux.intel.com>,
        <jolsa@...hat.com>, <namhyung@...nel.org>, <mhiramat@...nel.org>,
        <kstewart@...uxfoundation.org>, <tglx@...utronix.de>,
        <linux-kernel@...r.kernel.org>, <zhe.he@...driver.com>
Subject: [PATCH 1/2] perf: Fix checking of duplicate probe to give proper hint

From: He Zhe <zhe.he@...driver.com>

Since commit 72363540c009 ("perf probe: Support multiprobe event") and its
series, if there are multiple probes for one event,
__probe_file__get_namelist would return -EEXIST and cause the following
failure without proper hint, due to adding existing entry to output list.

root@...uarm64:~# perf probe -x /lib64/libc.so.6 free
Added new events:
  probe_libc:free      (on free in /lib64/libc-2.31.so)
  probe_libc:free      (on free in /lib64/libc-2.31.so)

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

        perf record -e probe_libc:free -aR sleep 1

root@...uarm64:~# perf probe -l
  probe_libc:free      (on free@plt in /lib64/libc-2.31.so)
  probe_libc:free      (on cfree in /lib64/libc-2.31.so)
root@...uarm64:~# perf probe -x /lib64/libc.so.6 free
  Error: Failed to add events.

As we just want to check if there is any probe with the same name, -EEXIST
can be ignored, so we can have the right hint as before.

root@...uarm64:~# perf probe -x /lib64/libc.so.6 free
Error: event "free" already exists.
 Hint: Remove existing event by 'perf probe -d'
       or force duplicates by 'perf probe -f'
       or set 'force=yes' in BPF source.
  Error: Failed to add events.

Signed-off-by: He Zhe <zhe.he@...driver.com>
---
 tools/perf/util/probe-file.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 5003ba403345..cf44c05f89c1 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -201,10 +201,16 @@ static struct strlist *__probe_file__get_namelist(int fd, bool include_group)
 		if (include_group) {
 			ret = e_snprintf(buf, 128, "%s:%s", tev.group,
 					tev.event);
-			if (ret >= 0)
+			if (ret >= 0) {
 				ret = strlist__add(sl, buf);
-		} else
+				if (ret == -EEXIST)
+					ret = 0;
+			}
+		} else {
 			ret = strlist__add(sl, tev.event);
+			if (ret == -EEXIST)
+				ret = 0;
+		}
 		clear_probe_trace_event(&tev);
 		if (ret < 0)
 			break;
-- 
2.24.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ