From 509a7cf9778968f796794c3743e62bc6b2a71592 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Wed, 10 Apr 2024 09:18:03 +0000 Subject: [PATCH] LU-17713 mdd: validate the length of mdd append_pool name Validate the length of mdd append_pool name (<= LOV_MAXPOOLNAME) before saving it in function append_pool_store(). Also, sanity.sh test_27M is improved a little to verify this fix. Signed-off-by: Emoly Liu Change-Id: Id7083fab60e9a18af4d8eedfa3d55f37544ba15d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54691 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Zhenyu Xu --- lustre/mdd/mdd_lproc.c | 2 +- lustre/tests/sanity.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lustre/mdd/mdd_lproc.c b/lustre/mdd/mdd_lproc.c index aec27cb..a8746a6 100644 --- a/lustre/mdd/mdd_lproc.c +++ b/lustre/mdd/mdd_lproc.c @@ -751,7 +751,7 @@ static ssize_t append_pool_store(struct kobject *kobj, struct attribute *attr, struct mdd_device *mdd = container_of(kobj, struct mdd_device, mdd_kobj); - if (!count || count > LOV_MAXPOOLNAME + 1 || buffer[0] == '\n') + if (!count || count > LOV_MAXPOOLNAME || buffer[0] == '\n') return -EINVAL; strscpy(mdd->mdd_append_pool, buffer, LOV_MAXPOOLNAME + 1); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 3cc9051..56fdc84 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -3084,6 +3084,12 @@ test_27M() { [[ "$pool" == "" ]] || error "expected append_pool == '', got '$pool'" stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool=none" + # Validate append_pool name length + (( $MDS1_VERSION >= $(version_code 2.15.61) )) && + do_nodes $mdts $LCTL \ + set_param mdd.*.append_pool="LOV_MAXPOOLNAME*" && + error "Wrong pool name length should report error" + local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count) ((orig_count == 1)) || error "expected append_stripe_count == 1, got $orig_count" stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1" -- 1.8.3.1