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] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z8iNr0Lh61o_GZgg@x1>
Date: Wed, 5 Mar 2025 14:45:19 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Ian Rogers <irogers@...gle.com>, Kan Liang <kan.liang@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
	linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 2/4] perf test: Skip perf probe tests when running as
 non-root

On Fri, Feb 28, 2025 at 08:02:50PM -0800, Namhyung Kim wrote:
> perf trace requires root because it needs to use [ku]probes.
> Skip those test when it's not run as root.
> 
> Before:
>   $ perf test probe
>    47: Probe SDT events                                                : Ok
>   104: test perf probe of function from different CU                   : FAILED!
>   115: perftool-testsuite_probe                                        : FAILED!
>   117: Add vfs_getname probe to get syscall args filenames             : FAILED!
>   118: probe libc's inet_pton & backtrace it with ping                 : FAILED!
>   119: Use vfs_getname probe to get syscall args filenames             : FAILED!

Do you have ShellCheck installed?

  TEST    /tmp/build/perf-tools-next/tests/shell/probe_vfs_getname.sh.shellcheck_log
  TEST    /tmp/build/perf-tools-next/tests/shell/record+probe_libc_inet_pton.sh.shellcheck_log
  TEST    /tmp/build/perf-tools-next/tests/shell/record+script_probe_vfs_getname.sh.shellcheck_log

In tests/shell/probe_vfs_getname.sh line 11:
[ "$(id -u)" == 0 ] || exit 2
             ^-- SC3014 (warning): In POSIX sh, == in place of = is undefined.

For more information:
  https://www.shellcheck.net/wiki/SC3014 -- In POSIX sh, == in place of = is ...

In tests/shell/record+script_probe_vfs_getname.sh line 16:
[ "$(id -u)" == 0 ] || exit 2
             ^-- SC3014 (warning): In POSIX sh, == in place of = is undefined.

For more information:
  https://www.shellcheck.net/wiki/SC3014 -- In POSIX sh, == in place of = is ...
make[4]: *** [tests/Build:91: /tmp/build/perf-tools-next/tests/shell/probe_vfs_getname.sh.shellcheck_log] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: *** [tests/Build:91: /tmp/build/perf-tools-next/tests/shell/record+script_probe_vfs_getname.sh.shellcheck_log] Error 1

In tests/shell/record+probe_libc_inet_pton.sh line 108:
[ "$(id -u)" == 0 ] || exit 2
             ^-- SC3014 (warning): In POSIX sh, == in place of = is undefined.

For more information:
  https://www.shellcheck.net/wiki/SC3014 -- In POSIX sh, == in place of = is ...
make[4]: *** [tests/Build:91: /tmp/build/perf-tools-next/tests/shell/record+probe_libc_inet_pton.sh.shellcheck_log] Error 1
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:138: tests] Error 2
make[2]: *** [Makefile.perf:810: /tmp/build/perf-tools-next/perf-test-in.o] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile.perf:321: sub-make] Error 2
make: *** [Makefile:119: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
⬢ [acme@...lbox perf-tools-next]$

The patch below seems to make it happy.

But since it seems to be mixed up, i.e. its not a string comparision, so
why the quotes?

Probably it should be

[ $(id -u) -eq 0 ] || exit 2

?

It all works with bash, but ShellCheck being installed stops the build
with that POSIX error.

⬢ [acme@...lbox perf-tools-next]$ [ "$(id -u)" == 1000 ] && echo bla
bla
⬢ [acme@...lbox perf-tools-next]$ [ "$(id -u)" = 1000 ] && echo bla
bla
⬢ [acme@...lbox perf-tools-next]$ [ $(id -u) -eq 1000 ] && echo bla
bla
⬢ [acme@...lbox perf-tools-next]$ id
uid=1000(acme) gid=1000(acme) groups=1000(acme),10(wheel)
⬢ [acme@...lbox perf-tools-next]

- Arnaldo

diff --git a/tools/perf/tests/shell/probe_vfs_getname.sh b/tools/perf/tests/shell/probe_vfs_getname.sh
index b8e53a9d8473bf6b..c51a32931af6313e 100755
--- a/tools/perf/tests/shell/probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/probe_vfs_getname.sh
@@ -8,7 +8,7 @@
 . "$(dirname $0)"/lib/probe.sh
 
 skip_if_no_perf_probe || exit 2
-[ "$(id -u)" == 0 ] || exit 2
+[ "$(id -u)" = 0 ] || exit 2
 
 # shellcheck source=lib/probe_vfs_getname.sh
 . "$(dirname $0)"/lib/probe_vfs_getname.sh
diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 07a1527c5c03b93d..c4bab5b5cc59f0b3 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -105,7 +105,7 @@ delete_libc_inet_pton_event() {
 
 # Check for IPv6 interface existence
 ip a sh lo | grep -F -q inet6 || exit 2
-[ "$(id -u)" == 0 ] || exit 2
+[ "$(id -u)" = 0 ] || exit 2
 
 skip_if_no_perf_probe && \
 add_libc_inet_pton_event && \
diff --git a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
index 0af3af90a8dcc742..fd5b10d469158b65 100755
--- a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
@@ -13,7 +13,7 @@
 . "$(dirname "$0")/lib/probe.sh"
 
 skip_if_no_perf_probe || exit 2
-[ "$(id -u)" == 0 ] || exit 2
+[ "$(id -u)" = 0 ] || exit 2
 
 # shellcheck source=lib/probe_vfs_getname.sh
 . "$(dirname "$0")/lib/probe_vfs_getname.sh"

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ