Commit 2e6d3045 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'remove-ksys-mount-dup' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux

Pull ksys_mount() and ksys_dup() removal from Dominik Brodowski:
 "This small series replaces all in-kernel calls to the
  userspace-focused ksys_mount() and ksys_dup() with calls to
  kernel-centric functions:

  For each replacement of ksys_mount() with do_mount(), one needs to
  verify that the first and third parameter (char *dev_name, char *type)
  are strings allocated in kernelspace and that the fifth parameter
  (void *data) is either NULL or refers to a full page (only occurence
  in init/do_mounts.c::do_mount_root()). The second and fourth
  parameters (char *dir_name, unsigned long flags) are passed by
  ksys_mount() to do_mount() unchanged, and therefore do not require
  particular care.

  Moreover, instead of pretending to be userspace, the opening of
  /dev/console as stdin/stdout/stderr can be implemented using in-kernel
  functions as well. Thereby, ksys_dup() can be removed for good"

[ This doesn't get rid of the special "kernel init runs with KERNEL_DS"
  case, but it at least removes _some_ of the users of "treat kernel
  pointers as user pointers for our magical init sequence".

  One day we'll hopefully be rid of it all, and can initialize our
  init_thread addr_limit to USER_DS.    - Linus ]

* 'remove-ksys-mount-dup' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux:
  fs: remove ksys_dup()
  init: unify opening /dev/console as stdin/stdout/stderr
  init: use do_mount() instead of ksys_mount()
  initrd: use do_mount() instead of ksys_mount()
  devtmpfs: use do_mount() instead of ksys_mount()
parents 510c9788 8243186f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -359,7 +359,7 @@ static int handle_remove(const char *nodename, struct device *dev)
 * If configured, or requested by the commandline, devtmpfs will be
 * auto-mounted after the kernel mounted the root filesystem.
 */
int devtmpfs_mount(const char *mntdir)
int devtmpfs_mount(void)
{
	int err;

@@ -369,7 +369,7 @@ int devtmpfs_mount(const char *mntdir)
	if (!thread)
		return 0;

	err = ksys_mount("devtmpfs", mntdir, "devtmpfs", MS_SILENT, NULL);
	err = do_mount("devtmpfs", "dev", "devtmpfs", MS_SILENT, NULL);
	if (err)
		printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
	else
@@ -394,7 +394,7 @@ static int devtmpfsd(void *p)
	*err = ksys_unshare(CLONE_NEWNS);
	if (*err)
		goto out;
	*err = ksys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
	*err = do_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
	if (*err)
		goto out;
	ksys_chdir("/.."); /* will traverse into overmounted root */
+1 −6
Original line number Diff line number Diff line
@@ -960,7 +960,7 @@ SYSCALL_DEFINE2(dup2, unsigned int, oldfd, unsigned int, newfd)
	return ksys_dup3(oldfd, newfd, 0);
}

int ksys_dup(unsigned int fildes)
SYSCALL_DEFINE1(dup, unsigned int, fildes)
{
	int ret = -EBADF;
	struct file *file = fget_raw(fildes);
@@ -975,11 +975,6 @@ int ksys_dup(unsigned int fildes)
	return ret;
}

SYSCALL_DEFINE1(dup, unsigned int, fildes)
{
	return ksys_dup(fildes);
}

int f_dupfd(unsigned int from, struct file *file, unsigned flags)
{
	int err;
+2 −8
Original line number Diff line number Diff line
@@ -3325,8 +3325,8 @@ struct dentry *mount_subtree(struct vfsmount *m, const char *name)
}
EXPORT_SYMBOL(mount_subtree);

int ksys_mount(const char __user *dev_name, const char __user *dir_name,
	       const char __user *type, unsigned long flags, void __user *data)
SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
		char __user *, type, unsigned long, flags, void __user *, data)
{
	int ret;
	char *kernel_type;
@@ -3359,12 +3359,6 @@ out_type:
	return ret;
}

SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
		char __user *, type, unsigned long, flags, void __user *, data)
{
	return ksys_mount(dev_name, dir_name, type, flags, data);
}

/*
 * Create a kernel mount representation for a new, prepared superblock
 * (specified by fs_fd) and attach to an open_tree-like file descriptor.
+2 −2
Original line number Diff line number Diff line
@@ -1666,11 +1666,11 @@ extern bool kill_device(struct device *dev);
#ifdef CONFIG_DEVTMPFS
extern int devtmpfs_create_node(struct device *dev);
extern int devtmpfs_delete_node(struct device *dev);
extern int devtmpfs_mount(const char *mntdir);
extern int devtmpfs_mount(void);
#else
static inline int devtmpfs_create_node(struct device *dev) { return 0; }
static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
static inline int devtmpfs_mount(void) { return 0; }
#endif

/* drivers/base/power/shutdown.c */
+2 −0
Original line number Diff line number Diff line
@@ -28,3 +28,5 @@ extern unsigned int real_root_dev;

extern char __initramfs_start[];
extern unsigned long __initramfs_size;

void console_on_rootfs(void);
Loading