Skip to content

Commit bb4a58b

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
VFS: Add GPL_EXPORTED function vfs_kern_mount()
do_kern_mount() does not allow the kernel to use private mount interfaces without exposing the same interfaces to userland. The problem is that the filesystem is referenced by name, thus meaning that it and its mount interface must be registered in the global filesystem list. vfs_kern_mount() passes the struct file_system_type as an explicit parameter in order to overcome this limitation. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent da6d503 commit bb4a58b

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

‎fs/super.c‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -800,17 +800,13 @@ struct super_block *get_sb_single(struct file_system_type *fs_type,
800800
EXPORT_SYMBOL(get_sb_single);
801801

802802
struct vfsmount *
803-
do_kern_mount(const char *fstype, int flags, const char *name, void *data)
803+
vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
804804
{
805-
struct file_system_type *type = get_fs_type(fstype);
806805
struct super_block *sb = ERR_PTR(-ENOMEM);
807806
struct vfsmount *mnt;
808807
int error;
809808
char *secdata = NULL;
810809

811-
if (!type)
812-
return ERR_PTR(-ENODEV);
813-
814810
mnt = alloc_vfsmnt(name);
815811
if (!mnt)
816812
goto out;
@@ -841,7 +837,6 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data)
841837
mnt->mnt_parent = mnt;
842838
up_write(&sb->s_umount);
843839
free_secdata(secdata);
844-
put_filesystem(type);
845840
return mnt;
846841
out_sb:
847842
up_write(&sb->s_umount);
@@ -852,10 +847,23 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data)
852847
out_mnt:
853848
free_vfsmnt(mnt);
854849
out:
855-
put_filesystem(type);
856850
return (struct vfsmount *)sb;
857851
}
858852

853+
EXPORT_SYMBOL_GPL(vfs_kern_mount);
854+
855+
struct vfsmount *
856+
do_kern_mount(const char *fstype, int flags, const char *name, void *data)
857+
{
858+
struct file_system_type *type = get_fs_type(fstype);
859+
struct vfsmount *mnt;
860+
if (!type)
861+
return ERR_PTR(-ENODEV);
862+
mnt = vfs_kern_mount(type, flags, name, data);
863+
put_filesystem(type);
864+
return mnt;
865+
}
866+
859867
EXPORT_SYMBOL_GPL(do_kern_mount);
860868

861869
struct vfsmount *kern_mount(struct file_system_type *type)

‎include/linux/mount.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ extern struct vfsmount *alloc_vfsmnt(const char *name);
7373
extern struct vfsmount *do_kern_mount(const char *fstype, int flags,
7474
const char *name, void *data);
7575

76+
struct file_system_type;
77+
extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
78+
int flags, const char *name,
79+
void *data);
80+
7681
struct nameidata;
7782

7883
extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,

0 commit comments

Comments
 (0)