Whamcloud - gitweb
LU-10824 llite: make foreign symlinks aware of mount namespaces 09/45609/4
authorJames Simmons <jsimmons@infradead.org>
Thu, 18 Nov 2021 16:39:08 +0000 (11:39 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Jan 2022 22:00:21 +0000 (22:00 +0000)
Currently the foreign symlink code test if mount namespace is the
same namespace related to the sysfs tree. This doesn't cover all
cases. Linux supports limiting which mounts are visible to a
process with mount namespaces. Lets add this support as well.

Change-Id: Ie87ed45b3c4439e8800c937eb27ed4931989c0f4
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/45609
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/llite_foreign_symlink.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c

index d401fa0..8c66a5e 100644 (file)
@@ -430,15 +430,15 @@ static struct dentry *ll_foreign_dir_lookup(struct inode *parent,
 
 static bool has_same_mount_namespace(struct ll_sb_info *sbi)
 {
 
 static bool has_same_mount_namespace(struct ll_sb_info *sbi)
 {
-       int rc;
+       bool same;
 
 
-       rc = (sbi->ll_mnt.mnt == current->fs->root.mnt);
-       if (!rc)
+       same = (sbi->ll_mnt_ns == current->nsproxy->mnt_ns);
+       if (!same)
                LCONSOLE_WARN("%s: client mount %s and '%s.%d' not in same mnt-namespace\n",
                              sbi->ll_fsname, sbi->ll_kset.kobj.name,
                              current->comm, current->pid);
 
                LCONSOLE_WARN("%s: client mount %s and '%s.%d' not in same mnt-namespace\n",
                              sbi->ll_fsname, sbi->ll_kset.kobj.name,
                              current->comm, current->pid);
 
-       return rc;
+       return same;
 }
 
 ssize_t foreign_symlink_enable_show(struct kobject *kobj,
 }
 
 ssize_t foreign_symlink_enable_show(struct kobject *kobj,
index 97ec1d2..1fc1222 100644 (file)
@@ -676,6 +676,7 @@ struct ll_sb_info {
        struct obd_device       *ll_dt_obd;
        struct dentry           *ll_debugfs_entry;
        struct lu_fid            ll_root_fid; /* root object fid */
        struct obd_device       *ll_dt_obd;
        struct dentry           *ll_debugfs_entry;
        struct lu_fid            ll_root_fid; /* root object fid */
+       struct mnt_namespace    *ll_mnt_ns;
 
        DECLARE_BITMAP(ll_flags, LL_SBI_NUM_FLAGS); /* enum ll_sbi_flags */
        unsigned int             ll_xattr_cache_enabled:1,
 
        DECLARE_BITMAP(ll_flags, LL_SBI_NUM_FLAGS); /* enum ll_sbi_flags */
        unsigned int             ll_xattr_cache_enabled:1,
index 7a6d4a7..86c6611 100644 (file)
@@ -452,6 +452,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
        sb->s_maxbytes = MAX_LFS_FILESIZE;
        sbi->ll_namelen = osfs->os_namelen;
        sbi->ll_mnt.mnt = current->fs->root.mnt;
        sb->s_maxbytes = MAX_LFS_FILESIZE;
        sbi->ll_namelen = osfs->os_namelen;
        sbi->ll_mnt.mnt = current->fs->root.mnt;
+       sbi->ll_mnt_ns = current->nsproxy->mnt_ns;
 
        if (test_bit(LL_SBI_USER_XATTR, sbi->ll_flags) &&
            !(data->ocd_connect_flags & OBD_CONNECT_XATTR)) {
 
        if (test_bit(LL_SBI_USER_XATTR, sbi->ll_flags) &&
            !(data->ocd_connect_flags & OBD_CONNECT_XATTR)) {