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:   Fri, 22 Nov 2019 11:48:56 +0200
From:   Adrian Hunter <adrian.hunter@...el.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] perf record: Fix perf_can_aux_sample_size()

perf_can_aux_sample_size() always returned true because it did not pass
the attribute size to sys_perf_event_open, nor correctly check the
return value and errno.

Before:

  # perf record --aux-sample -e '{intel_pt//u,branch-misses:u}'
  Error:
  The sys_perf_event_open() syscall returned with 7 (Argument list too long) for event (branch-misses:u).
  /bin/dmesg | grep -i perf may provide additional information.

After:

  # perf record --aux-sample -e '{intel_pt//u,branch-misses:u}'
  AUX area sampling is not supported by kernel

Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
---
 tools/perf/util/record.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
index e2321edcdd8f..7def66168503 100644
--- a/tools/perf/util/record.c
+++ b/tools/perf/util/record.c
@@ -143,6 +143,7 @@ bool perf_can_record_cpu_wide(void)
 bool perf_can_aux_sample(void)
 {
 	struct perf_event_attr attr = {
+		.size = sizeof(struct perf_event_attr),
 		.exclude_kernel = 1,
 		/*
 		 * Non-zero value causes the kernel to calculate the effective
@@ -158,7 +159,7 @@ bool perf_can_aux_sample(void)
 	 * then we assume that it is supported. We are relying on the kernel to
 	 * validate the attribute size before anything else that could be wrong.
 	 */
-	if (fd == -E2BIG)
+	if (fd < 0 && errno == E2BIG)
 		return false;
 	if (fd >= 0)
 		close(fd);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ