From 53b3d1de99277f8d3e4af475986802ee3dcdd304 Mon Sep 17 00:00:00 2001 From: Lei Feng Date: Mon, 26 Sep 2022 14:31:57 +0800 Subject: [PATCH] LU-16152 utils: fix integer overflow in cYAML parser Convert double to int64 correctly in cYAML parser. Signed-off-by: Lei Feng Test-Parameters: trivial testlist=sanity env=ONLY=65p Change-Id: Ia3fd515c76ebfe6e5181301f53c702ef82056eba Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48649 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Emoly Liu Reviewed-by: Oleg Drokin --- lnet/utils/lnetconfig/cyaml.c | 2 +- lustre/tests/sanity.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lnet/utils/lnetconfig/cyaml.c b/lnet/utils/lnetconfig/cyaml.c index 0c859a1..7c82645 100644 --- a/lnet/utils/lnetconfig/cyaml.c +++ b/lnet/utils/lnetconfig/cyaml.c @@ -391,7 +391,7 @@ static bool parse_number(struct cYAML *item, const char *input) n = sign * n * pow(10.0, (scale + subscale * signsubscale)); item->cy_valuedouble = n; - item->cy_valueint = (int)n; + item->cy_valueint = (int64_t)n; item->cy_type = CYAML_TYPE_NUMBER; return true; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index f90d408..11a3442 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9667,6 +9667,34 @@ test_65o() { } run_test 65o "pool inheritance for mdt component" +test_65p () { # LU-16152 + local src_dir=$DIR/$tdir/src_dir + local dst_dir=$DIR/$tdir/dst_dir + local yaml_file=$DIR/$tdir/layout.yaml + local border + + (( $CLIENT_VERSION >= $(version_code 2.15.51) )) || + skip "Need at least version 2.15.51" + + test_mkdir -p $src_dir + $LFS setstripe -E 2048M -c 4 -E EOF -c 8 $src_dir || + error "failed to setstripe" + $LFS getstripe --yaml -d $src_dir > $yaml_file || + error "failed to getstripe" + + test_mkdir -p $dst_dir + $LFS setstripe --yaml $yaml_file $dst_dir || + error "failed to setstripe with yaml file" + border=$($LFS getstripe -d $dst_dir | + awk '/lcme_extent.e_end:/ { print $2; exit; }') || + error "failed to getstripe" + + # 2048M is 0x80000000, or 2147483648 + (( $border == 2147483648 )) || + error "failed to handle huge number in yaml layout" +} +run_test 65p "setstripe with yaml file and huge number" + # bug 2543 - update blocks count on client test_66() { [ $PARALLEL == "yes" ] && skip "skip parallel run" -- 1.8.3.1