Whamcloud - gitweb
LU-18828 lnet: lnetctl SIGSEGV in infra_ping_nid 60/58460/8
authorFrank Sehr <fsehr@whamcloud.com>
Wed, 19 Mar 2025 00:10:00 +0000 (17:10 -0700)
committerOleg Drokin <green@whamcloud.com>
Wed, 7 May 2025 21:12:41 +0000 (21:12 +0000)
Return value of strtok() not checked.
Save error code and continue pinging after syntax error.

Test-Parameters: trivial
Signed-off-by: Frank Sehr <fsehr@whamcloud.com>
Change-Id: I817d7c46ced9e8ea42a283b6c05dfc17ce8781f3
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58460
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: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetctl.c

index 4a12809..af581f9 100644 (file)
@@ -940,15 +940,25 @@ static int infra_ping_nid(char *ping_nids, char *src_nidstr, char *oper,
                        first_seq = item;
 
                /* check if '-' is a part of NID, token */
-               sep = strchr(token, '-');
+               if (token != NULL)
+                       sep = strchr(token, '-');
+               else
+                       sep = NULL;
+
                if (sep == NULL) {
+                       if (token == NULL)
+                               id.nid = LNET_NID_ANY;
+                       else
+                               /* if no net is specified,
+                                * libcfs_str2nid() will assume tcp
+                                */
+                               id.nid = libcfs_str2nid(token);
+
                        id.pid = LNET_PID_ANY;
-                       /* if no net is specified, libcfs_str2nid() will assume tcp */
-                       id.nid = libcfs_str2nid(token);
                        if (id.nid == LNET_NID_ANY) {
                                snprintf(err_str, sizeof(err_str),
                                         "\"cannot parse NID '%s'\"",
-                                        token);
+                                        token ? token : "NULL");
                                rc = LUSTRE_CFG_RC_BAD_PARAM;
                                cYAML_build_error(rc, seq_no, MANAGE_CMD,
                                                  oper, err_str, err_rc);
index 2700b7e..3834721 100644 (file)
@@ -5424,9 +5424,14 @@ static int jt_ping(int argc, char **argv)
                        return rc;
        }
 
-       for (; optind < argc; optind++)
-               rc = lustre_lnet_ping_nid(argv[optind], src_nidstr, timeout, -1,
-                                         &show_rc, &err_rc);
+       for (; optind < argc; optind++) {
+               int rc2;
+
+               rc2 = lustre_lnet_ping_nid(argv[optind], src_nidstr, timeout,
+                                          -1, &show_rc, &err_rc);
+               if (rc2 != 0 && (rc > 0 || rc == -EOPNOTSUPP))
+                       rc = rc2;
+       }
 
        if (show_rc)
                cYAML_print_tree(show_rc);