Whamcloud - gitweb
LU-17713 mdd: validate the length of mdd append_pool name 91/54691/6
authorEmoly Liu <emoly@whamcloud.com>
Wed, 10 Apr 2024 09:18:03 +0000 (09:18 +0000)
committerOleg Drokin <green@whamcloud.com>
Tue, 23 Apr 2024 19:57:18 +0000 (19:57 +0000)
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 <emoly@whamcloud.com>
Change-Id: Id7083fab60e9a18af4d8eedfa3d55f37544ba15d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54691
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Zhenyu Xu <bobijam@hotmail.com>
lustre/mdd/mdd_lproc.c
lustre/tests/sanity.sh

index aec27cb..a8746a6 100644 (file)
@@ -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);
index 3cc9051..56fdc84 100755 (executable)
@@ -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"