Re: [PATCH v2 17/36] fs: add ksys_chroot() helper; remove-in kernel calls to sys_chroot()

From: Arnd Bergmann
Date: Thu Mar 15 2018 - 16:44:30 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_chroot()
> syscall.
>
> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/base/devtmpfs.c | 2 +-
> fs/open.c | 7 ++++++-
> include/linux/syscalls.h | 1 +
> init/do_mounts.c | 2 +-
> init/do_mounts_initrd.c | 4 ++--
> 5 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
> index 4afb04686c8e..5743f04014ca 100644
> --- a/drivers/base/devtmpfs.c
> +++ b/drivers/base/devtmpfs.c
> @@ -387,7 +387,7 @@ static int devtmpfsd(void *p)
> if (*err)
> goto out;
> sys_chdir("/.."); /* will traverse into overmounted root */
> - sys_chroot(".");
> + ksys_chroot(".");
> complete(&setup_done);
> while (1) {
> spin_lock(&req_lock);

Could this be done using kern_path()/set_fs_root() instead so we
avoid the __user pointer?

Arnd