From 30868de94003ae436d7177b92e22553c22f54b9f Mon Sep 17 00:00:00 2001 From: Frank Sehr Date: Tue, 25 Feb 2025 16:24:17 -0800 Subject: [PATCH] LU-18751 lnet: Segfault in lnetctl fault command "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 Change-Id: Iec580b19f97c2a189ae8f29444bf3e3cc91d78a0 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58216 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Manish Regmi Reviewed-by: Oleg Drokin --- lnet/utils/lnetconfig/liblnetconfig.c | 13 ++++++------- lustre/tests/sanity-lnet.sh | 10 ++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index 2c4ecd6..4dc284b 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -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)); diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index 5aad8fc..f227488 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -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 $? -- 1.8.3.1