Message ID | 20230626201606.2514679-1-jolsa@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7733993vqr; Mon, 26 Jun 2023 13:23:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CnZ9EuWbbkYsgD5Zyjpy2geGVUzjIkU+WlkHmmpjaqgfV+rpZzFY2WPpc7Wf2znjSnqLo X-Received: by 2002:a17:907:6e17:b0:958:cc8:bd55 with SMTP id sd23-20020a1709076e1700b009580cc8bd55mr32083412ejc.0.1687811027715; Mon, 26 Jun 2023 13:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687811027; cv=none; d=google.com; s=arc-20160816; b=B0EH3lgMQVQFMrq0w1Qu43CqkpLGa1A11DMkIwFORGbZZPdMz1tmLoShp2bJmK0jp7 43xzY8ntZBT90+dXK4Ii6hSjisLgSIvaHksHLFIQi+YACvFowH+CyM0nW3OV4vOxVg+Y Mr7gjfJ8KWnWgXLyQsi6/kaO74GNOTl8kv3xZIUUNmdn+Y3jxd+YoFph2+ZFmt5Z/Nxo BoDtahiHB2NglrDZcOsPesSuymQUWRH3l2902Jvu5D3yXjZ33Q6U3QPmxoVw7irKXObv 46vswqr8bIlyZPLMKBSzd9wj5mKuo6R8ix9DHI+q/YjMnav7+o6vTBqpgcEnuUrnECrn mxNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=z5pr0PihcVU61SZr15BA1PAdflr6Yw5TSGmSiX1W8GY=; fh=ie7M2DgD87IQ1d59dQ0YcxSX7+a1yHkv++WgNgnkSgg=; b=jFZc/48c8Ze8yy6j1DOSUFFiSrrgj1/fbkxV8xA/8v1NKfKQHbUr+QcjqbqZDbsxbi b67QnbclACqtg/A8SdylG1Z6ZWshZjJgOeSm1e4AgkkwyTsWVSBK5IZBqD/9HN7Ak3Fx 7y8FLi2asr5c912TJD8i3IZh8CrNxwXWPbOS6GDmKzQL5FRxflU59MeVQqiu068yXE3Q FnRj9U2mTHTvHfvbfSWn1CE/TVTRiOW2dmWeaQa0oNroiSWaXGFb0RoSNwE4ZQORVjxI 15R7A+u3p5IRzSA7sR9Uukr4Y1zRRC65QEEAEWvj8ujknH4lrR5X2kIbiPPT38yHXxPD mXCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="P9u+7v/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a170906348800b0098d2f715b83si3144507ejb.626.2023.06.26.13.23.18; Mon, 26 Jun 2023 13:23:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="P9u+7v/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231144AbjFZUQQ (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Mon, 26 Jun 2023 16:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbjFZUQO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 26 Jun 2023 16:16:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6FA9E4; Mon, 26 Jun 2023 13:16:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3FF3860DFA; Mon, 26 Jun 2023 20:16:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B296C433C0; Mon, 26 Jun 2023 20:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687810572; bh=5BDJLetXXf3y8IYgHBV9UPex77ekTt4y/ajL2pcgjdQ=; h=From:To:Cc:Subject:Date:From; b=P9u+7v/Ye/PUDn5GmLPJ0/nM8sGaVBDBsCgui9Nl9qEC0FZWtAW6lvfyyrYNgJPto 0JHkmIqcvnwZUMKJwi/PT4iAyjuiCPYGusStHTQZkFpTitl5rWW0MUJiqm/vALG5+M MmhSHI030QvblwCFOarjCuSnip8HN8bAnD50m2s52242LUhVQEx16WHlWH/6E2p+1w ym0ZofAT2qaM/lyVW3UfNOPKdJbw0+a7OIzR8zSLu/3/voyHIA+m3ZlTZ/9OpybfQ+ W6scvHIcTcXCN5xEaKSgxvzptwckxqpeASYKefAg3Gcqn7vG/C4hLvr+nPLhQHyNSC wjLhGedJ4R9fQ== From: Jiri Olsa <jolsa@kernel.org> To: Arnaldo Carvalho de Melo <acme@kernel.org>, Namhyung Kim <namhyung@kernel.org> Cc: lkml <linux-kernel@vger.kernel.org>, Peter Zijlstra <a.p.zijlstra@chello.nl>, Ingo Molnar <mingo@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, linux-perf-users@vger.kernel.org Subject: [PATCH] perf tools: Add missing else to cmd_daemon subcommand condition Date: Mon, 26 Jun 2023 22:16:05 +0200 Message-ID: <20230626201606.2514679-1-jolsa@kernel.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769798136388123816?= X-GMAIL-MSGID: =?utf-8?q?1769798136388123816?= |
Series |
perf tools: Add missing else to cmd_daemon subcommand condition
|
|
Commit Message
Jiri Olsa
June 26, 2023, 8:16 p.m. UTC
Namhyung reported segfault in perf daemon start command.
It's caused by extra check on argv[0] which is set to NULL by previous
__cmd_start call. Adding missing else to skip the extra check.
Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf")
Reported-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Jiri, On Mon, Jun 26, 2023 at 1:16 PM Jiri Olsa <jolsa@kernel.org> wrote: > > Namhyung reported segfault in perf daemon start command. > > It's caused by extra check on argv[0] which is set to NULL by previous > __cmd_start call. Adding missing else to skip the extra check. > > Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf") > Reported-by: Namhyung Kim <namhyung@kernel.org> > Signed-off-by: Jiri Olsa <jolsa@kernel.org> Thanks for the fix. Now it runs ok. Before: $ sudo ./perf test -v daemon 85: daemon operations : --- start --- test child forked, pid 82420 test daemon list ./tests/shell/daemon.sh: line 133: 82426 Segmentation fault perf daemon start --config ${config} test daemon reconfig ./tests/shell/daemon.sh: line 133: 82520 Segmentation fault perf daemon start --config ${config} test daemon stop ./tests/shell/daemon.sh: line 133: 82636 Segmentation fault perf daemon start --config ${config} test daemon signal ./tests/shell/daemon.sh: line 133: 82674 Segmentation fault perf daemon start --config ${config} signal 12 sent to session 'test [82676]' signal 12 sent to session 'test [82676]' test daemon ping ./tests/shell/daemon.sh: line 133: 82702 Segmentation fault perf daemon start --config ${config} test daemon lock ./tests/shell/daemon.sh: line 133: 82734 Segmentation fault perf daemon start --config ${config} test child finished with 0 ---- end ---- daemon operations: Ok Maybe we need to investigate more why it was ok.. But at least I don't see segfaults anymore After: 85: daemon operations : --- start --- test child forked, pid 80752 test daemon list test daemon reconfig test daemon stop test daemon signal signal 12 sent to session 'test [81022]' signal 12 sent to session 'test [81022]' test daemon ping test daemon lock test child finished with 0 ---- end ---- daemon operations: Ok Tested-by: Namhyung Kim <namhyung@kernel.org> Thanks, Namhyung > --- > 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 >
On Mon, Jun 26, 2023 at 01:58:48PM -0700, Namhyung Kim wrote: > Hi Jiri, > > On Mon, Jun 26, 2023 at 1:16 PM Jiri Olsa <jolsa@kernel.org> wrote: > > > > Namhyung reported segfault in perf daemon start command. > > > > It's caused by extra check on argv[0] which is set to NULL by previous > > __cmd_start call. Adding missing else to skip the extra check. > > > > Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf") > > Reported-by: Namhyung Kim <namhyung@kernel.org> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org> > > Thanks for the fix. Now it runs ok. > > Before: > $ sudo ./perf test -v daemon > 85: daemon operations : > --- start --- > test child forked, pid 82420 > test daemon list > ./tests/shell/daemon.sh: line 133: 82426 Segmentation fault > perf daemon start --config ${config} > test daemon reconfig > ./tests/shell/daemon.sh: line 133: 82520 Segmentation fault > perf daemon start --config ${config} > test daemon stop > ./tests/shell/daemon.sh: line 133: 82636 Segmentation fault > perf daemon start --config ${config} > test daemon signal > ./tests/shell/daemon.sh: line 133: 82674 Segmentation fault > perf daemon start --config ${config} > signal 12 sent to session 'test [82676]' > signal 12 sent to session 'test [82676]' > test daemon ping > ./tests/shell/daemon.sh: line 133: 82702 Segmentation fault > perf daemon start --config ${config} > test daemon lock > ./tests/shell/daemon.sh: line 133: 82734 Segmentation fault > perf daemon start --config ${config} > test child finished with 0 > ---- end ---- > daemon operations: Ok > > Maybe we need to investigate more why it was ok.. > But at least I don't see segfaults anymore yea, for some reason parse_options would put NULL into argv[0] I'll try to check what changed, in any case the fix makes the condition alligned with the other legs and fixes the segfault jirka > > > After: > 85: daemon operations : > --- start --- > test child forked, pid 80752 > test daemon list > test daemon reconfig > test daemon stop > test daemon signal > signal 12 sent to session 'test [81022]' > signal 12 sent to session 'test [81022]' > test daemon ping > test daemon lock > test child finished with 0 > ---- end ---- > daemon operations: Ok > > > Tested-by: Namhyung Kim <namhyung@kernel.org> > > Thanks, > Namhyung > > > > > --- > > 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 > >
On Tue, Jun 27, 2023 at 1:35 AM Jiri Olsa <olsajiri@gmail.com> wrote: > > On Mon, Jun 26, 2023 at 01:58:48PM -0700, Namhyung Kim wrote: > > Hi Jiri, > > > > On Mon, Jun 26, 2023 at 1:16 PM Jiri Olsa <jolsa@kernel.org> wrote: > > > > > > Namhyung reported segfault in perf daemon start command. > > > > > > It's caused by extra check on argv[0] which is set to NULL by previous > > > __cmd_start call. Adding missing else to skip the extra check. > > > > > > Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf") > > > Reported-by: Namhyung Kim <namhyung@kernel.org> > > > Signed-off-by: Jiri Olsa <jolsa@kernel.org> > > > > Thanks for the fix. Now it runs ok. > > > > Before: > > $ sudo ./perf test -v daemon > > 85: daemon operations : > > --- start --- > > test child forked, pid 82420 > > test daemon list > > ./tests/shell/daemon.sh: line 133: 82426 Segmentation fault > > perf daemon start --config ${config} > > test daemon reconfig > > ./tests/shell/daemon.sh: line 133: 82520 Segmentation fault > > perf daemon start --config ${config} > > test daemon stop > > ./tests/shell/daemon.sh: line 133: 82636 Segmentation fault > > perf daemon start --config ${config} > > test daemon signal > > ./tests/shell/daemon.sh: line 133: 82674 Segmentation fault > > perf daemon start --config ${config} > > signal 12 sent to session 'test [82676]' > > signal 12 sent to session 'test [82676]' > > test daemon ping > > ./tests/shell/daemon.sh: line 133: 82702 Segmentation fault > > perf daemon start --config ${config} > > test daemon lock > > ./tests/shell/daemon.sh: line 133: 82734 Segmentation fault > > perf daemon start --config ${config} > > test child finished with 0 > > ---- end ---- > > daemon operations: Ok > > > > Maybe we need to investigate more why it was ok.. > > But at least I don't see segfaults anymore > > yea, for some reason parse_options would put NULL into argv[0] > > I'll try to check what changed, in any case the fix makes the > condition alligned with the other legs and fixes the segfault Yep, thanks for checking. In the meantime, Thomas Richter reported the same problem and fix. I'll take yours but leave it for the record. http://lore.kernel.org/r/20230627092633.2135105-1-tmricht@linux.ibm.com Applied to perf-tools-next, thanks!
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);