vfs: move getname() from callers to do_mount()
It would make more sense to pass char __user * instead of char * in callers of do_mount() and do getname() inside do_mount(). Suggested-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Seunghun Lee <waydi1@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
4d93bc3e81
commit
5e6123f347
|
@ -446,7 +446,8 @@ struct procfs_args {
|
||||||
* unhappy with OSF UFS. [CHECKME]
|
* unhappy with OSF UFS. [CHECKME]
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
osf_ufs_mount(const char *dirname, struct ufs_args __user *args, int flags)
|
osf_ufs_mount(const char __user *dirname,
|
||||||
|
struct ufs_args __user *args, int flags)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct cdfs_args tmp;
|
struct cdfs_args tmp;
|
||||||
|
@ -466,7 +467,8 @@ osf_ufs_mount(const char *dirname, struct ufs_args __user *args, int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
osf_cdfs_mount(const char *dirname, struct cdfs_args __user *args, int flags)
|
osf_cdfs_mount(const char __user *dirname,
|
||||||
|
struct cdfs_args __user *args, int flags)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct cdfs_args tmp;
|
struct cdfs_args tmp;
|
||||||
|
@ -486,7 +488,8 @@ osf_cdfs_mount(const char *dirname, struct cdfs_args __user *args, int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
osf_procfs_mount(const char *dirname, struct procfs_args __user *args, int flags)
|
osf_procfs_mount(const char __user *dirname,
|
||||||
|
struct procfs_args __user *args, int flags)
|
||||||
{
|
{
|
||||||
struct procfs_args tmp;
|
struct procfs_args tmp;
|
||||||
|
|
||||||
|
@ -500,28 +503,22 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
|
||||||
int, flag, void __user *, data)
|
int, flag, void __user *, data)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct filename *name;
|
|
||||||
|
|
||||||
name = getname(path);
|
|
||||||
retval = PTR_ERR(name);
|
|
||||||
if (IS_ERR(name))
|
|
||||||
goto out;
|
|
||||||
switch (typenr) {
|
switch (typenr) {
|
||||||
case 1:
|
case 1:
|
||||||
retval = osf_ufs_mount(name->name, data, flag);
|
retval = osf_ufs_mount(path, data, flag);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
retval = osf_cdfs_mount(name->name, data, flag);
|
retval = osf_cdfs_mount(path, data, flag);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
retval = osf_procfs_mount(name->name, data, flag);
|
retval = osf_procfs_mount(path, data, flag);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
printk("osf_mount(%ld, %x)\n", typenr, flag);
|
printk("osf_mount(%ld, %x)\n", typenr, flag);
|
||||||
}
|
}
|
||||||
putname(name);
|
|
||||||
out:
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
fs/compat.c
20
fs/compat.c
|
@ -794,7 +794,6 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
|
||||||
char *kernel_type;
|
char *kernel_type;
|
||||||
unsigned long data_page;
|
unsigned long data_page;
|
||||||
char *kernel_dev;
|
char *kernel_dev;
|
||||||
struct filename *dir;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
kernel_type = copy_mount_string(type);
|
kernel_type = copy_mount_string(type);
|
||||||
|
@ -802,19 +801,14 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
|
||||||
if (IS_ERR(kernel_type))
|
if (IS_ERR(kernel_type))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
dir = getname(dir_name);
|
|
||||||
retval = PTR_ERR(dir);
|
|
||||||
if (IS_ERR(dir))
|
|
||||||
goto out1;
|
|
||||||
|
|
||||||
kernel_dev = copy_mount_string(dev_name);
|
kernel_dev = copy_mount_string(dev_name);
|
||||||
retval = PTR_ERR(kernel_dev);
|
retval = PTR_ERR(kernel_dev);
|
||||||
if (IS_ERR(kernel_dev))
|
if (IS_ERR(kernel_dev))
|
||||||
goto out2;
|
goto out1;
|
||||||
|
|
||||||
retval = copy_mount_options(data, &data_page);
|
retval = copy_mount_options(data, &data_page);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto out3;
|
goto out2;
|
||||||
|
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
|
|
||||||
|
@ -823,19 +817,17 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
|
||||||
do_ncp_super_data_conv((void *)data_page);
|
do_ncp_super_data_conv((void *)data_page);
|
||||||
} else if (!strcmp(kernel_type, NFS4_NAME)) {
|
} else if (!strcmp(kernel_type, NFS4_NAME)) {
|
||||||
if (do_nfs4_super_data_conv((void *) data_page))
|
if (do_nfs4_super_data_conv((void *) data_page))
|
||||||
goto out4;
|
goto out3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = do_mount(kernel_dev, dir->name, kernel_type,
|
retval = do_mount(kernel_dev, dir_name, kernel_type,
|
||||||
flags, (void*)data_page);
|
flags, (void*)data_page);
|
||||||
|
|
||||||
out4:
|
|
||||||
free_page(data_page);
|
|
||||||
out3:
|
out3:
|
||||||
kfree(kernel_dev);
|
free_page(data_page);
|
||||||
out2:
|
out2:
|
||||||
putname(dir);
|
kfree(kernel_dev);
|
||||||
out1:
|
out1:
|
||||||
kfree(kernel_type);
|
kfree(kernel_type);
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -2533,7 +2533,7 @@ char *copy_mount_string(const void __user *data)
|
||||||
* Therefore, if this magic number is present, it carries no information
|
* Therefore, if this magic number is present, it carries no information
|
||||||
* and must be discarded.
|
* and must be discarded.
|
||||||
*/
|
*/
|
||||||
long do_mount(const char *dev_name, const char *dir_name,
|
long do_mount(const char *dev_name, const char __user *dir_name,
|
||||||
const char *type_page, unsigned long flags, void *data_page)
|
const char *type_page, unsigned long flags, void *data_page)
|
||||||
{
|
{
|
||||||
struct path path;
|
struct path path;
|
||||||
|
@ -2545,15 +2545,11 @@ long do_mount(const char *dev_name, const char *dir_name,
|
||||||
flags &= ~MS_MGC_MSK;
|
flags &= ~MS_MGC_MSK;
|
||||||
|
|
||||||
/* Basic sanity checks */
|
/* Basic sanity checks */
|
||||||
|
|
||||||
if (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (data_page)
|
if (data_page)
|
||||||
((char *)data_page)[PAGE_SIZE - 1] = 0;
|
((char *)data_page)[PAGE_SIZE - 1] = 0;
|
||||||
|
|
||||||
/* ... and get the mountpoint */
|
/* ... and get the mountpoint */
|
||||||
retval = kern_path(dir_name, LOOKUP_FOLLOW, &path);
|
retval = user_path(dir_name, &path);
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
@ -2778,7 +2774,6 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *kernel_type;
|
char *kernel_type;
|
||||||
struct filename *kernel_dir;
|
|
||||||
char *kernel_dev;
|
char *kernel_dev;
|
||||||
unsigned long data_page;
|
unsigned long data_page;
|
||||||
|
|
||||||
|
@ -2787,12 +2782,6 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
|
||||||
if (IS_ERR(kernel_type))
|
if (IS_ERR(kernel_type))
|
||||||
goto out_type;
|
goto out_type;
|
||||||
|
|
||||||
kernel_dir = getname(dir_name);
|
|
||||||
if (IS_ERR(kernel_dir)) {
|
|
||||||
ret = PTR_ERR(kernel_dir);
|
|
||||||
goto out_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
kernel_dev = copy_mount_string(dev_name);
|
kernel_dev = copy_mount_string(dev_name);
|
||||||
ret = PTR_ERR(kernel_dev);
|
ret = PTR_ERR(kernel_dev);
|
||||||
if (IS_ERR(kernel_dev))
|
if (IS_ERR(kernel_dev))
|
||||||
|
@ -2802,15 +2791,13 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out_data;
|
goto out_data;
|
||||||
|
|
||||||
ret = do_mount(kernel_dev, kernel_dir->name, kernel_type, flags,
|
ret = do_mount(kernel_dev, dir_name, kernel_type, flags,
|
||||||
(void *) data_page);
|
(void *) data_page);
|
||||||
|
|
||||||
free_page(data_page);
|
free_page(data_page);
|
||||||
out_data:
|
out_data:
|
||||||
kfree(kernel_dev);
|
kfree(kernel_dev);
|
||||||
out_dev:
|
out_dev:
|
||||||
putname(kernel_dir);
|
|
||||||
out_dir:
|
|
||||||
kfree(kernel_type);
|
kfree(kernel_type);
|
||||||
out_type:
|
out_type:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -1855,7 +1855,8 @@ extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data);
|
||||||
extern void kern_unmount(struct vfsmount *mnt);
|
extern void kern_unmount(struct vfsmount *mnt);
|
||||||
extern int may_umount_tree(struct vfsmount *);
|
extern int may_umount_tree(struct vfsmount *);
|
||||||
extern int may_umount(struct vfsmount *);
|
extern int may_umount(struct vfsmount *);
|
||||||
extern long do_mount(const char *, const char *, const char *, unsigned long, void *);
|
extern long do_mount(const char *, const char __user *,
|
||||||
|
const char *, unsigned long, void *);
|
||||||
extern struct vfsmount *collect_mounts(struct path *);
|
extern struct vfsmount *collect_mounts(struct path *);
|
||||||
extern void drop_collected_mounts(struct vfsmount *);
|
extern void drop_collected_mounts(struct vfsmount *);
|
||||||
extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
|
extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
|
||||||
|
|
Loading…
Reference in New Issue