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: <20230627092633.2135105-1-tmricht@linux.ibm.com>
Date:   Tue, 27 Jun 2023 11:26:33 +0200
From:   Thomas Richter <tmricht@...ux.ibm.com>
To:     linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        acme@...nel.org, irogers@...gle.com, hca@...ux.ibm.com
Cc:     svens@...ux.ibm.com, gor@...ux.ibm.com, sumanthk@...ux.ibm.com,
        Thomas Richter <tmricht@...ux.ibm.com>
Subject: [PATCH] perf/test: perf test case Daemon operations dumps core

The perf test case Daemon operations dumps core all the time.
I narrowed it down to this invocation:

Segmentation fault (core dumped)
....
(gdb) where
    at builtin-daemon.c:1527
    argv=0x3ffe66f9630) at perf.c:323
    at perf.c:377
    at perf.c:421
(gdb)

Normally this goes unnoticed, the core dumps are only shown in
verbose mode and when core dump generation is enabled on fedora 38:

 # ./perf test daemon
 80: daemon operations                   : Ok
 # ll core*
-rw------- 1 root root 3551232 Jun 27 10:08 core.4586
-rw------- 1 root root 3551232 Jun 27 10:08 core.4688
-rw------- 1 root root 3551232 Jun 27 10:08 core.4812
-rw------- 1 root root 3551232 Jun 27 10:08 core.4857
-rw------- 1 root root 3551232 Jun 27 10:08 core.4893
-rw------- 1 root root 3551232 Jun 27 10:08 core.4933
-rw------- 1 root root 3551232 Jun 27 10:08 core.4947
-rw------- 1 root root 3551232 Jun 27 10:08 core.4949
 # ./perf test -v daemon
 80: daemon operations                  :
--- start ---
test child forked, pid 4974
test daemon list
./tests/shell/daemon.sh: line 133:  4980 Segmentation fault \
		(core dumped) perf daemon start --config ${config}
test daemon reconfig
./tests/shell/daemon.sh: line 133:  5082 Segmentation fault \
		(core dumped) perf daemon start --config ${config}
test daemon stop
./tests/shell/daemon.sh: line 133:  5206 Segmentation fault \
		(core dumped) perf daemon start --config ${config}
test daemon signal
./tests/shell/daemon.sh: line 133:  5250 Segmentation fault \
		(core dumped) perf daemon start --config ${config}
signal 12 sent to session 'test [5252]'
signal 12 sent to session 'test [5252]'
test daemon ping
./tests/shell/daemon.sh: line 133:  5286 Segmentation fault \
		(core dumped) perf daemon start --config ${config}
test daemon lock
./tests/shell/daemon.sh: line 133:  5326 Segmentation fault \
		(core dumped) perf daemon start --config ${config}
test child finished with 0
---- end ----
daemon operations: Ok
 # ll core*|wc -l
16
 #

The root cause is in function cmd_daemon():

    argc = parse_options(argc, argv, daemon_options, daemon_usage,
		         PARSE_OPT_STOP_AT_NON_OPTION);

    if (argc) {
	if (!strcmp(argv[0], "start"))
		ret = __cmd_start(&__daemon, daemon_options, argc,
				  argv);
	if (!strcmp(argv[0], "signal"))
		    ^^^^^^^
Parameter argv[0] is set to NULL in function __cmd_start() and the
next strcmp() accesses a NULL pointer.

Output after:

 # ./perf daemon start --config /tmp/perf-daemon-config
 #
 # ./perf test -v daemon
 80: daemon operations                                               :
--- start ---
test child forked, pid 6517
test daemon list
test daemon reconfig
test daemon stop
test daemon signal
signal 12 sent to session 'test [6780]'
signal 12 sent to session 'test [6780]'
test daemon ping
test daemon lock
test child finished with 0
---- end ----
daemon operations: Ok
 #

Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf")

Signed-off-by: Thomas Richter <tmricht@...ux.ibm.com>
---
 tools/perf/builtin-daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
index f5674d824a40..83954af36753 100644
--- a/tools/perf/builtin-daemon.c
+++ b/tools/perf/builtin-daemon.c
@@ -1524,7 +1524,7 @@ int cmd_daemon(int argc, const char **argv)
 	if (argc) {
 		if (!strcmp(argv[0], "start"))
 			ret = __cmd_start(&__daemon, daemon_options, argc, argv);
-		if (!strcmp(argv[0], "signal"))
+		else if (!strcmp(argv[0], "signal"))
 			ret = __cmd_signal(&__daemon, daemon_options, argc, argv);
 		else if (!strcmp(argv[0], "stop"))
 			ret = __cmd_stop(&__daemon, daemon_options, argc, argv);
-- 
2.41.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ