From 5b3d371a58c04c74376e1bc10728ef09354efc33 Mon Sep 17 00:00:00 2001 From: Frank Sehr Date: Thu, 13 Mar 2025 12:36:43 -0700 Subject: [PATCH] LU-18807 utils: SIGSEGV in jt_obd_setattr Wrong argument comparison causes crash. Also unchecked yaml_scalar_event_initialize() causes a double free problem. This should be done for all variable based event initialization. Test-Parameters: trivial Signed-off-by: Frank Sehr Change-Id: Id90aec86d0779316dd7ca3d1d926a3db5503d2c1 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58403 Reviewed-by: Andreas Dilger Reviewed-by: Cyril Bordage Reviewed-by: Manish Regmi Reviewed-by: Oleg Drokin Reviewed-by: Serguei Smirnov Tested-by: jenkins Tested-by: Maloo --- lustre/utils/lustre_cfg.c | 5 ++++- lustre/utils/obd.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 9c72493..972b741 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -713,11 +713,14 @@ static int yaml_get_device_index(char *source) if (rc == 0) goto error; - yaml_scalar_event_initialize(&event, NULL, + rc = yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)source, strlen(source), 1, 0, YAML_PLAIN_SCALAR_STYLE); + if (rc == 0) + goto error; + rc = yaml_emitter_emit(&request, &event); if (rc == 0) goto error; diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index f97ca3b..f131f81 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -1551,7 +1551,7 @@ int jt_obd_setattr(int argc, char **argv) memset(&data, 0, sizeof(data)); data.ioc_dev = cur_device; - if (argc != 2) + if (argc != 3) return CMD_HELP; objid = strtoull(argv[1], &end, 0); -- 1.8.3.1