Whamcloud - gitweb
LU-8037 fileset: reject dotdot as a path component 46/19646/2
authorWang Shilong <wshilong@ddn.com>
Tue, 19 Apr 2016 04:19:30 +0000 (12:19 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 22 Apr 2016 15:46:31 +0000 (15:46 +0000)
Administrator might access Lustre internal files by
using dotdot path for example:

mount -t lustre ip@tcp:/lustre/.. /mnt/lustre

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I137e12aa3f2feacb8549eb85f966c9dc8426f3af
Reviewed-on: http://review.whamcloud.com/19646
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_handler.c
lustre/tests/sanity.sh

index 95ac27e..47c8a17 100644 (file)
@@ -312,6 +312,14 @@ static int mdt_lookup_fileset(struct mdt_thread_info *info, const char *fileset,
                        rc = -EINVAL;
                        break;
                }
+
+               /* reject .. as a path component */
+               if (lname->ln_namelen == 2 &&
+                   strncmp(s1, "..", 2) == 0) {
+                       rc = -EINVAL;
+                       break;
+               }
+
                strncpy(name, s1, lname->ln_namelen);
                name[lname->ln_namelen] = '\0';
 
index 8a96be6..81a3532 100644 (file)
@@ -13566,6 +13566,22 @@ test_247d() {
 }
 run_test 247d "running fid2path inside root"
 
+# LU-8037
+test_247e() {
+       lctl get_param -n mdc.$FSNAME-MDT0000*.import |
+               grep -q subtree ||
+               { skip "Fileset feature is not supported"; return; }
+
+       local submount=${MOUNT}_$tdir
+
+       mkdir $MOUNT/$tdir
+       mkdir -p $submount || error "mkdir $submount failed"
+       FILESET="$FILESET/.." mount_client $submount &&
+               error "mount $submount should fail"
+       rmdir $submount
+}
+run_test 247e "mount .. as fileset"
+
 test_250() {
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
         && skip "no 16TB file size limit on ZFS" && return