Re: [PATCH v2 14/36] fs: add ksys_mount() helper; remove in-kernel calls to sys_mount()

From: Arnd Bergmann
Date: Thu Mar 15 2018 - 16:11:35 EST


On Thu, Mar 15, 2018 at 8:05 PM, Dominik Brodowski
<linux@xxxxxxxxxxxxxxxxxxxx> wrote:
> Using this helper allows us to avoid the in-kernel calls to the sys_mount()
> syscall.
>
> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>

> diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
> index 50025d7959cb..4afb04686c8e 100644
> --- a/drivers/base/devtmpfs.c
> +++ b/drivers/base/devtmpfs.c
> @@ -356,7 +356,8 @@ int devtmpfs_mount(const char *mntdir)
> if (!thread)
> return 0;
>
> - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
> + err = ksys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT,
> + NULL);
> if (err)
> printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
> else
> @@ -382,7 +383,7 @@ static int devtmpfsd(void *p)
> *err = sys_unshare(CLONE_NEWNS);
> if (*err)
> goto out;
> - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
> + *err = ksys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
> if (*err)
> goto out;
> sys_chdir("/.."); /* will traverse into overmounted root */

Shouldn't the callers of sys_mount just call do_mount() instead?

As I understand it, sys_mount is already a wrapper around do_mount()
that copies its arguments from user space, but we don't need that
when called from inside the kernel.

Arnd