From: Lei Feng Date: Wed, 28 Sep 2022 02:16:17 +0000 (+0800) Subject: LU-16194 lod: define negative extent offset as invalid X-Git-Tag: 2.15.59~137 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3d6dbc72e161927ada762d2f0a68cf2d7acef4cb;p=fs%2Flustre-release.git LU-16194 lod: define negative extent offset as invalid If lu_extent.e_start/e_end is negative after converting to s64, regard it as invalid data except -1 (EOF). Signed-off-by: Lei Feng Change-Id: I79276a5185f339e9de48fe87c4da39052c7974e1 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48684 Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 101502f..0a1d571 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -2175,8 +2175,12 @@ recheck: if (le64_to_cpu(ext->e_start) > le64_to_cpu(ext->e_end) || le64_to_cpu(ext->e_start) & (LOV_MIN_STRIPE_SIZE - 1) || + ((__s64)le64_to_cpu(ext->e_start) < 0 && + le64_to_cpu(ext->e_start) != LUSTRE_EOF) || (le64_to_cpu(ext->e_end) != LUSTRE_EOF && - le64_to_cpu(ext->e_end) & (LOV_MIN_STRIPE_SIZE - 1))) { + le64_to_cpu(ext->e_end) & (LOV_MIN_STRIPE_SIZE - 1)) || + ((__s64)le64_to_cpu(ext->e_end) < 0 && + le64_to_cpu(ext->e_end) != LUSTRE_EOF)) { CDEBUG(D_LAYOUT, "invalid extent "DEXT"\n", le64_to_cpu(ext->e_start), le64_to_cpu(ext->e_end)); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7d4d246..2623127 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -10326,6 +10326,23 @@ test_65p () { # LU-16152 } run_test 65p "setstripe with yaml file and huge number" +test_65p () { # LU-16194 + local src_dir=$DIR/$tdir/src_dir + + (( $CLIENT_VERSION >= $(version_code 2.15.51) )) || + skip "Need at least version 2.15.51" + + test_mkdir -p $src_dir + # 8E is 0x8000 0000 0000 0000, which is negative as s64 + $LFS setstripe -E 8E -c 4 -E EOF -c 8 $src_dir && + error "should fail if extent start/end >=8E" + + # EOF should work as before + $LFS setstripe -E 8M -c 4 -E EOF -c 8 $src_dir || + error "failed to setstripe normally" +} +run_test 65p "setstripe with >=8E offset should fail" + # bug 2543 - update blocks count on client test_66() { [ $PARALLEL == "yes" ] && skip "skip parallel run"