Whamcloud - gitweb
LU-18751 lnet: Segfault in lnetctl fault command 16/58216/2
authorFrank Sehr <fsehr@whamcloud.com>
Wed, 26 Feb 2025 00:24:17 +0000 (16:24 -0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Mar 2025 08:10:13 +0000 (08:10 +0000)
"lnetctl fault reset 0" and similar variations cause a segfault. This
is caused by a null pointer that is not checked in the code.

Test-Parameters: trivial
Signed-off-by: Frank Sehr <fsehr@whamcloud.com>
Change-Id: Iec580b19f97c2a189ae8f29444bf3e3cc91d78a0
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58216
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Manish Regmi <mregmi@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c
lustre/tests/sanity-lnet.sh

index 2c4ecd6..4dc284b 100644 (file)
@@ -676,13 +676,9 @@ int yaml_lnet_fault_rule(yaml_document_t *results, __u32 opc, char *src,
        if (rc < 0)
                return rc;
 
-       if (local_nid) {
-               rc = fault_attr_parse_nid(local_nid, &fa_local_nid);
-               if (rc < 0)
-                       return rc;
-       } else {
-               fa_local_nid = LNET_ANY_NID;
-       }
+       rc = fault_attr_parse_nid(local_nid, &fa_local_nid);
+       if (rc < 0)
+               return rc;
 
 skip_options:
        /* Create Netlink emitter to send request to kernel */
@@ -750,6 +746,9 @@ skip_options:
        if (rc == 0)
                goto emitter_error;
 
+       if (attr == NULL)
+               goto yaml_mapping_end_event;
+
        rc = lnet_yaml_uint_mapping(&event, &output, "fa_ptl_mask",
                                    &attr->fa_ptl_mask,
                                    sizeof(attr->fa_ptl_mask));
index 5aad8fc..f227488 100755 (executable)
@@ -4598,6 +4598,16 @@ test_402() {
 }
 run_test 402 "Destination net rule should not panic"
 
+test_410() {
+       reinit_dlc || return $?
+
+       do_lnetctl fault reset \0 ||
+               return 0
+
+       error "Command should fail"
+}
+run_test 410 "No segfault in lnetctl fault command"
+
 test_500() {
        reinit_dlc || return $?