From: John L. Hammond Date: Fri, 14 Sep 2018 20:49:37 +0000 (-0500) Subject: LU-11380 llite: zero lum for stripeless files X-Git-Tag: 2.11.56~33 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F33172%2F3;p=fs%2Flustre-release.git LU-11380 llite: zero lum for stripeless files In the IOC_MDC_GETFILEINFO/LL_IOC_MDC_GETINFO case of ll_dir_ioctl(), if the file has no striping then zero out the lum buffer so that userspace won't be confused by garbage. Signed-off-by: John L. Hammond Change-Id: I4574b8bfdee122ec1ac571ae3714026c6fa0a7f0 Reviewed-on: https://review.whamcloud.com/33172 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu --- diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index cb73a4d..9e07036 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1514,13 +1514,14 @@ out_rmdir: GOTO(out_req, rc); } - if (rc < 0) { - if (rc == -ENODATA && (cmd == IOC_MDC_GETFILEINFO || - cmd == LL_IOC_MDC_GETINFO)) - GOTO(skip_lmm, rc = 0); - else - GOTO(out_req, rc); - } + if (rc == -ENODATA && (cmd == IOC_MDC_GETFILEINFO || + cmd == LL_IOC_MDC_GETINFO)) { + lmmsize = 0; + rc = 0; + } + + if (rc < 0) + GOTO(out_req, rc); if (cmd == IOC_MDC_GETFILESTRIPE || cmd == LL_IOC_LOV_GETSTRIPE || @@ -1531,12 +1532,18 @@ out_rmdir: lmdp = (struct lov_user_mds_data __user *)arg; lump = &lmdp->lmd_lmm; } - if (copy_to_user(lump, lmm, lmmsize)) { + + if (lmmsize == 0) { + /* If the file has no striping then zero out *lump so + * that the caller isn't confused by garbage. */ + if (clear_user(lump, sizeof(*lump))) + GOTO(out_req, rc = -EFAULT); + } else if (copy_to_user(lump, lmm, lmmsize)) { if (copy_to_user(lump, lmm, sizeof(*lump))) - GOTO(out_req, rc = -EFAULT); - rc = -EOVERFLOW; - } - skip_lmm: + GOTO(out_req, rc = -EFAULT); + rc = -EOVERFLOW; + } + if (cmd == IOC_MDC_GETFILEINFO || cmd == LL_IOC_MDC_GETINFO) { struct lov_user_mds_data __user *lmdp; lstat_t st = { 0 }; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 2ff71db..1b0dfab 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -13586,6 +13586,20 @@ test_184e() { } run_test 184e "Recreate layout after stripeless layout swaps" +test_184f() { + # Create a file with name longer than sizeof(struct stat) == + # 144 to see if we can get chars from the file name to appear + # in the returned striping. Note that 'f' == 0x66. + local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done) + + mkdir -p $DIR/$tdir + mcreate $DIR/$tdir/$file + if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then + error "IOC_MDC_GETFILEINFO returned garbage striping" + fi +} +run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping" + test_185() { # LU-2441 # LU-3553 - no volatile file support in old servers [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||