Whamcloud - gitweb
LU-18762 lnet: lst SIGSEGV in parser.c 69/58269/2
authorFrank Sehr <fsehr@whamcloud.com>
Fri, 28 Feb 2025 21:49:59 +0000 (13:49 -0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Mar 2025 08:11:33 +0000 (08:11 +0000)
A null pointer problem. Null pointer was passed instead of command
structure array. Built in additional chack.

Test-Parameters: trivial
Signed-off-by: Frank Sehr <fsehr@whamcloud.com>
Change-Id: I7d4e44170aeb8e44c55de681b6b3def781a0b1bd
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58269
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Manish Regmi <mregmi@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/util/parser.c
lnet/utils/lst.c

index 08dfe8f..1d3c205 100644 (file)
@@ -147,6 +147,9 @@ int cfs_parser(int argc, char **argv, command_t cmds[])
 
        done = 0;
 
+       if (cmds == NULL)
+               return -ENOENT;
+
        for (cmd = override_cmdlist; cmd->pc_name && i < MAXCMDS; cmd++)
                top_level[i++] = *cmd;
 
index 71a6d7c..abb167b 100644 (file)
@@ -34,6 +34,8 @@
 #include <linux/lnet/nidstr.h>
 #include "lnetconfig/liblnetconfig.h"
 
+static void lst_print_usage(char *cmd);
+
 static int lst_info_batch_ioctl(char *batch, int test, int server,
                       struct lstcon_test_batch_ent *entp, int *idxp,
                       int *ndentp, struct lstcon_node_ent *dentsp);
@@ -329,14 +331,6 @@ lst_test_name2type(char *name)
 }
 
 static void
-lst_print_usage(char *cmd)
-{
-       char *argv[] = { "help", cmd };
-
-       cfs_parser(2, argv, NULL);
-}
-
-static void
 lst_print_error(char *sub, const char *def_format, ...)
 {
        va_list ap;
@@ -3930,6 +3924,14 @@ lst_initialize(void)
        return 0;
 }
 
+static void
+lst_print_usage(char *cmd)
+{
+       char *argv[] = { "help", cmd };
+
+       cfs_parser(2, argv, lst_cmdlist);
+}
+
 int main(int argc, char **argv)
 {
        int rc = 0;