add file system helpers that take kernel pointers for the init code v3
Subsystems (4)
Hi Al and Linus,
currently a lot of the file system calls in the early in code (and the devtmpfs kthread) rely on the implicit set_fs(KERNEL_DS) during boot. This is one of the few last remaining places we need to deal with to kill off set_fs entirely, so this series adds new helpers that take kernel pointers. These helpers are in init/ and marked __init and thus will be discarded after bootup. A few also need to be duplicated in devtmpfs, though unfortunately.
The series sits on top of my previous
"decruft the early init / initrd / initramfs code v2"
series.
Git tree:
git://git.infradead.org/users/hch/misc.git init_path
Gitweb:
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/init_path
Changes since v2:
- move to fs/for-init.c
- reuse the init routines in devtmpfs after refactoring devtmpfsd (and thus the broken error handling in the previous version)
- actually use kern_path in a place where user_path_at sneaked back in
Changes since v1:
- avoid most core VFS changes
- renamed the functions and move them to init/ and devtmpfs
- drop a bunch of cleanups that can be submitted independently now
Diffstat:
drivers/base/devtmpfs.c | 54 +++++---- drivers/md/md-autodetect.c | 3 fs/Makefile | 2 fs/for_init.c | 249 ++++++++++++++++++++++++++++++++++++++++++ fs/internal.h | 19 +-- fs/namei.c | 20 +-- fs/namespace.c | 107 ++++++++---------- fs/open.c | 22 +-- include/linux/init_syscalls.h | 18 +++ include/linux/syscalls.h | 66 ----------- init/do_mounts.c | 12 +- init/do_mounts.h | 7 - init/do_mounts_initrd.c | 26 ++-- init/do_mounts_rd.c | 2 init/initramfs.c | 29 ++-- init/main.c | 10 - init/noinitramfs.c | 8 - 17 files changed, 423 insertions(+), 231 deletions(-)
PATCH 1/21 fs: refactor do_mount
Factor out a path_mount helper that takes a struct path * instead of the actual file name. This will allow to convert the init and devtmpfs code to properly mount based on a kernel pointer instead of relying on the implicit set_fs(KERNEL_DS) during early init.
--- fs/namespace.c | 67 ++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 32 deletions(-)
fs/namespace.c +35 -32
@@ -3115,12 +3115,11 @@ char *copy_mount_string(const void __user *data)* Therefore, if this magic number is present, it carries no information * and must be discarded. */ -long do_mount (const char *dev_name,const char __user *dir_name, +static int path_mount (const char *dev_name,struct path *path,const char *type_page,unsigned long flags,void *data_page) { -struct path path;unsigned int mnt_flags =0 , sb_flags; -int retval =0 ; +int ret;/* Discard magic */ if ((flags &MS_MGC_MSK ) ==MS_MGC_VAL )
@@ -3133,19 +3132,13 @@ long do_mount(const char *dev_name, const char __user *dir_name,if (flags &MS_NOUSER )return -EINVAL ; -/* ... and get the mountpoint */ - retval =user_path_at (AT_FDCWD , dir_name,LOOKUP_FOLLOW , &path); -if (retval) -return retval; - - retval =security_sb_mount (dev_name, &path, - type_page, flags, data_page); -if (!retval && !may_mount ()) - retval = -EPERM ; -if (!retval && (flags &SB_MANDLOCK ) && !may_mandlock ()) - retval = -EPERM ; -if (retval) - goto dput_out; + ret =security_sb_mount (dev_name, path, type_page, flags, data_page); +if (ret) +return ret; +if (!may_mount ()) +return -EPERM ; +if ((flags &SB_MANDLOCK ) && !may_mandlock ()) +return -EPERM ;/* Default to relatime unless overriden */ if (!(flags &MS_NOATIME ))
@@ -3172,7 +3165,7 @@ long do_mount(const char *dev_name, const char __user *dir_name, ((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME | MS_STRICTATIME)) == 0)) { mnt_flags &= ~MNT_ATIME_MASK ; - mnt_flags |= path.mnt->mnt_flags &MNT_ATIME_MASK ; + mnt_flags |= path->mnt->mnt_flags &MNT_ATIME_MASK ; } sb_flags = flags & (SB_RDONLY |
@@ -3185,22 +3178,32 @@ long do_mount(const char *dev_name, const char __user *dir_name, SB_I_VERSION);if ((flags & (MS_REMOUNT |MS_BIND )) == (MS_REMOUNT |MS_BIND )) - retval =do_reconfigure_mnt (&path, mnt_flags); -else if (flags &MS_REMOUNT ) - retval =do_remount (&path, flags, sb_flags, mnt_flags, - data_page); -else if (flags &MS_BIND ) - retval =do_loopback (&path, dev_name, flags &MS_REC ); -else if (flags & (MS_SHARED |MS_PRIVATE |MS_SLAVE |MS_UNBINDABLE )) - retval =do_change_type (&path, flags); -else if (flags &MS_MOVE ) - retval =do_move_mount_old (&path, dev_name); -else - retval =do_new_mount (&path, type_page, sb_flags, mnt_flags, - dev_name, data_page); -dput_out: +return do_reconfigure_mnt (path, mnt_flags); +if (flags &MS_REMOUNT ) +return do_remount (path, flags, sb_flags, mnt_flags, data_page); +if (flags &MS_BIND ) +return do_loopback (path, dev_name, flags &MS_REC ); +if (flags & (MS_SHARED |MS_PRIVATE |MS_SLAVE |MS_UNBINDABLE )) +return do_change_type (path, flags); +if (flags &MS_MOVE ) +return do_move_mount_old (path, dev_name); + +return do_new_mount (path, type_page, sb_flags, mnt_flags, dev_name, + data_page); +} + +long do_mount (const char *dev_name,const char __user *dir_name, +const char *type_page,unsigned long flags,void *data_page) +{ +struct path path; +int ret; + + ret =user_path_at (AT_FDCWD , dir_name,LOOKUP_FOLLOW , &path); +if (ret) +return ret; + ret =path_mount (dev_name, &path, type_page, flags, data_page);path_put (&path); -return retval; +return ret; }static struct ucounts *inc_mnt_namespaces (struct user_namespace *ns)
Signature · 1 line
2.27.0
PATCH 2/21 fs: refactor ksys_umount
In reply to Christoph HellwigFactor out a path_umount helper that takes a struct path * instead of the actual file name. This will allow to convert the init and devtmpfs code to properly mount based on a kernel pointer instead of relying on the implicit set_fs(KERNEL_DS) during early init.
--- fs/namespace.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
fs/namespace.c +18 -22
@@ -1706,36 +1706,19 @@ static inline bool may_mandlock(void) }#endif -/* -* Now umount can handle mount points as well as block devices. -* This is important for filesystems which use unnamed block devices. -* -* We now support a flag for forced unmount like the other 'big iron' -* unixes. Our API is identical to OSF/1 to avoid making a mess of AMD -*/ - -int ksys_umount (char __user *name,int flags) +static int path_umount (struct path *path,int flags) { -struct path path;struct mount *mnt;int retval; -int lookup_flags =LOOKUP_MOUNTPOINT ;if (flags & ~(MNT_FORCE |MNT_DETACH |MNT_EXPIRE |UMOUNT_NOFOLLOW ))return -EINVAL ; -if (!may_mount ())return -EPERM ; -if (!(flags &UMOUNT_NOFOLLOW )) - lookup_flags |=LOOKUP_FOLLOW ; - - retval =user_path_at (AT_FDCWD , name, lookup_flags, &path); -if (retval) - goto out; - mnt =real_mount (path.mnt); + mnt =real_mount (path->mnt); retval = -EINVAL ; -if (path.dentry != path.mnt->mnt_root) +if (path->dentry != path->mnt->mnt_root) goto dput_and_out;if (!check_mnt (mnt)) goto dput_and_out;
@@ -1748,12 +1731,25 @@ int ksys_umount(char __user *name, int flags) retval =do_umount (mnt, flags); dput_and_out:/* we mustn't call path_put() as that would clear mnt_expiry_mark */ -dput (path.dentry); +dput (path->dentry);mntput_no_expire (mnt); -out:return retval; } +int ksys_umount (char __user *name,int flags) +{ +int lookup_flags =LOOKUP_MOUNTPOINT ; +struct path path; +int ret; + +if (!(flags &UMOUNT_NOFOLLOW )) + lookup_flags |=LOOKUP_FOLLOW ; + ret =user_path_at (AT_FDCWD , name, lookup_flags, &path); +if (ret) +return ret; +return path_umount (&path, flags); +} + SYSCALL_DEFINE2(umount, char __user *, name, int, flags) {return ksys_umount (name, flags);
Signature · 1 line
2.27.0
PATCH 3/21 fs: push the getname from do_rmdir into the callers
In reply to Christoph HellwigThis mirrors do_unlinkat and will make life a little easier for the init code to reuse the whole function with a kernel filename.
--- fs/internal.h | 2 +- fs/namei.c | 10 ++++------ include/linux/syscalls.h | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-)
fs/internal.h +1 -1
@@ -65,7 +65,7 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,long do_mknodat (int dfd,const char __user *filename,umode_t mode,unsigned int dev);long do_mkdirat (int dfd,const char __user *pathname,umode_t mode); -long do_rmdir (int dfd,const char __user *pathname); +long do_rmdir (int dfd,struct filename *name);long do_unlinkat (int dfd,struct filename *name);long do_symlinkat (const char __user *oldname,int newdfd,const char __user *newname);
fs/namei.c +4 -6
@@ -3720,17 +3720,16 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry) }EXPORT_SYMBOL (vfs_rmdir); -long do_rmdir (int dfd,const char __user *pathname) +long do_rmdir (int dfd,struct filename *name) {int error =0 ; -struct filename *name;struct dentry *dentry;struct path path;struct qstr last;int type;unsigned int lookup_flags =0 ; retry: - name =filename_parentat (dfd,getname (pathname), lookup_flags, + name =filename_parentat (dfd, name, lookup_flags, &path, &last, &type);if (IS_ERR (name))return PTR_ERR (name);
@@ -3781,7 +3780,7 @@ long do_rmdir(int dfd, const char __user *pathname) SYSCALL_DEFINE1(rmdir, const char __user *, pathname) { -return do_rmdir (AT_FDCWD , pathname); +return do_rmdir (AT_FDCWD ,getname (pathname)); }/**
@@ -3926,8 +3925,7 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, pathname, int, flag)return -EINVAL ;if (flag &AT_REMOVEDIR ) -return do_rmdir (dfd, pathname); - +return do_rmdir (dfd,getname (pathname));return do_unlinkat (dfd,getname (pathname)); }
include/linux/syscalls.h +2 -2
@@ -1281,11 +1281,11 @@ static inline long ksys_unlink(const char __user *pathname)return do_unlinkat (AT_FDCWD ,getname (pathname)); } -extern long do_rmdir (int dfd,const char __user *pathname); +long do_rmdir (int dfd,struct filename *name);static inline long ksys_rmdir (const char __user *pathname) { -return do_rmdir (AT_FDCWD , pathname); +return do_rmdir (AT_FDCWD ,getname (pathname)); }extern long do_mkdirat (int dfd,const char __user *pathname,umode_t mode);
Signature · 1 line
2.27.0
PATCH 4/21 devtmpfs: refactor devtmpfsd()
In reply to Christoph HellwigSplit the main worker loop into a separate function. This allows devtmpfsd itself and devtmpfsd_setup to be marked __init, which will allows us to call __init routines for the setup work.
--- drivers/base/devtmpfs.c | 47 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-)
drivers/base/devtmpfs.c +26 -21
@@ -378,7 +378,30 @@ static int handle(const char *name, umode_t mode, kuid_t uid, kgid_t gid,return handle_remove (name, dev); } -static int devtmpfs_setup (void *p) +static void __noreturn devtmpfs_work_loop (void ) +{ +while (1 ) { +spin_lock (&req_lock); +while (requests) { +struct req *req = requests; + requests =NULL ; +spin_unlock (&req_lock); +while (req) { +struct req *next = req->next; + req->err =handle (req->name, req->mode, + req->uid, req->gid, req->dev); +complete (&req->done); + req = next; + } +spin_lock (&req_lock); + } +__set_current_state (TASK_INTERRUPTIBLE ); +spin_unlock (&req_lock); +schedule (); + } +} + +static int __init devtmpfs_setup (void *p) {int err;
@@ -396,31 +419,13 @@ static int devtmpfs_setup(void *p)return err; } -static int devtmpfsd (void *p) +static int __init devtmpfsd (void *p) {int err =devtmpfs_setup (p);if (err)return err; -while (1 ) { -spin_lock (&req_lock); -while (requests) { -struct req *req = requests; - requests =NULL ; -spin_unlock (&req_lock); -while (req) { -struct req *next = req->next; - req->err =handle (req->name, req->mode, - req->uid, req->gid, req->dev); -complete (&req->done); - req = next; - } -spin_lock (&req_lock); - } -__set_current_state (TASK_INTERRUPTIBLE ); -spin_unlock (&req_lock); -schedule (); - } +devtmpfs_work_loop ();return 0 ; }
Signature · 1 line
2.27.0
Re: [PATCH 04/21] devtmpfs: refactor devtmpfsd()
Quoted 8 lines · Christoph Hellwig
Split the main worker loop into a separate function. This allows devtmpfsd itself and
devtmpfsd_setupto be marked__init, which will allows us to call__initroutines for the setup work.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/base/devtmpfs.c | 47 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-)
Nice cleanup, thanks for doing this:
Re: [PATCH 04/21] devtmpfs: refactor devtmpfsd()
Quoted 11 lines · Greg Kroah-Hartman
Quoted 8 lines · Christoph Hellwig
Split the main worker loop into a separate function. This allows devtmpfsd itself and
devtmpfsd_setupto be marked__init, which will allows us to call__initroutines for the setup work.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/base/devtmpfs.c | 47 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-)Nice cleanup, thanks for doing this:
This was actualy Als idea, I should have probably mentioned that.
PATCH 5/21 init: initialize ramdisk_execute_command at compile time
In reply to Christoph HellwigSet ramdisk_execute_command to "/init" at compile time. The command line can still override it, but this saves a few instructions and removes a NULL check.
--- init/main.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
init/main.c +1 -5
@@ -154,7 +154,7 @@ static bool initargs_found;#endif static char *execute_command; -static char *ramdisk_execute_command; +static char *ramdisk_execute_command ="/init" ;/* * Used to generate warnings if static_key manipulation functions are used
@@ -1514,10 +1514,6 @@ static noinline void __init kernel_init_freeable(void)* check if there is an early userspace init. If yes, let it do all * the work */ - -if (!ramdisk_execute_command) - ramdisk_execute_command ="/init" ; -if (ksys_access ((const char __user *) ramdisk_execute_command,0 ) !=0 ) { ramdisk_execute_command =NULL ;
Signature · 1 line
2.27.0
PATCH 6/21 init: mark create_dev as __init
In reply to Christoph HellwigThe helper is only used for the early init code.
--- init/do_mounts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init/do_mounts.h +1 -1
@@ -13,7 +13,7 @@ void mount_block_root(char *name, int flags);void mount_root (void );extern int root_mountflags; -static inline int create_dev (char *name,dev_t dev) +static inline __init int create_dev (char *name,dev_t dev) {ksys_unlink (name);return ksys_mknod (name,S_IFBLK |0600 ,new_encode_dev (dev));
Signature · 1 line
2.27.0
PATCH 7/21 init: add an init_mount helper
In reply to Christoph HellwigLike do_mount, but takes a kernel pointer for the destination path. Switch over the mounts in the init code and devtmpfs to it, which just happen to work due to the implicit set_fs(KERNEL_DS) during early init right now.
--- drivers/base/devtmpfs.c | 5 +++-- fs/Makefile | 2 +- fs/for_init.c | 21 +++++++++++++++++++++ fs/internal.h | 4 ++++ fs/namespace.c | 2 +- include/linux/init_syscalls.h | 4 ++++ init/do_mounts.c | 8 ++++---- init/do_mounts.h | 1 + init/do_mounts_initrd.c | 6 +++--- 9 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 fs/for_init.c create mode 100644 include/linux/init_syscalls.h
drivers/base/devtmpfs.c +3 -2
@@ -25,6 +25,7 @@#include <linux/sched.h> #include <linux/slab.h> #include <linux/kthread.h> +#include <linux/init_syscalls.h> #include <uapi/linux/mount.h> #include "base.h"
@@ -359,7 +360,7 @@ int __init devtmpfs_mount(void)if (!thread)return 0 ; - err =do_mount ("devtmpfs" ,"dev" ,"devtmpfs" ,MS_SILENT ,NULL ); + err =init_mount ("devtmpfs" ,"dev" ,"devtmpfs" ,MS_SILENT ,NULL );if (err)printk (KERN_INFO "devtmpfs: error mounting %i\n" , err);else
@@ -408,7 +409,7 @@ static int __init devtmpfs_setup(void *p) err =ksys_unshare (CLONE_NEWNS );if (err) goto out; - err =do_mount ("devtmpfs" ,"/" ,"devtmpfs" ,MS_SILENT ,NULL ); + err =init_mount ("devtmpfs" ,"/" ,"devtmpfs" ,MS_SILENT ,NULL );if (err) goto out;ksys_chdir ("/.." );/* will traverse into overmounted root */
fs/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-y := open.o read_write.o file_table.o super.o \ seq_file.o xattr.o libfs.o fs-writeback.o \ pnode.o splice.o sync.o utimes.o d_path.o \ stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \ - fs_types.o fs_context.o fs_parser.o fsopen.o + fs_types.o fs_context.o fs_parser.o fsopen.o for_init.o ifeq ($(CONFIG_BLOCK),y) obj-y += buffer.o block_dev.o direct-io.o mpage.o
fs/for_init.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/init.h> +#include <linux/mount.h> +#include <linux/namei.h> +#include <linux/fs.h> +#include <linux/init_syscalls.h> +#include "internal.h" + +int __init init_mount (const char *dev_name,const char *dir_name, +const char *type_page,unsigned long flags,void *data_page) +{ +struct path path; +int ret; + + ret =kern_path (dir_name,LOOKUP_FOLLOW , &path); +if (ret) +return ret; + ret =path_mount (dev_name, &path, type_page, flags, data_page); +path_put (&path); +return ret; +}
fs/internal.h +4 -0
@@ -89,6 +89,10 @@ extern int __mnt_want_write_file(struct file *);extern void __mnt_drop_write_file (struct file *);extern void dissolve_on_fput (struct vfsmount *); + +int path_mount (const char *dev_name,struct path *path, +const char *type_page,unsigned long flags,void *data_page); +/* * fs_struct.c */
fs/namespace.c +1 -1
@@ -3111,7 +3111,7 @@ char *copy_mount_string(const void __user *data)* Therefore, if this magic number is present, it carries no information * and must be discarded. */ -static int path_mount (const char *dev_name,struct path *path, +int path_mount (const char *dev_name,struct path *path,const char *type_page,unsigned long flags,void *data_page) {unsigned int mnt_flags =0 , sb_flags;
include/linux/init_syscalls.h new file +4 -0
@@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +int __init init_mount (const char *dev_name,const char *dir_name, +const char *type_page,unsigned long flags,void *data_page);
init/do_mounts.c +4 -4
@@ -395,16 +395,16 @@ static int __init do_mount_root(const char *name, const char *fs,int ret;if (data) { -/* do_mount() requires a full page as fifth argument */ +/* init_mount() requires a full page as fifth argument */ p =alloc_page (GFP_KERNEL );if (!p)return -ENOMEM ; data_page =page_address (p); -/* zero-pad. do_mount() will make sure it's terminated */ +/* zero-pad. init_mount() will make sure it's terminated */ strncpy (data_page, data,PAGE_SIZE ); } - ret =do_mount (name,"/root" , fs, flags, data_page); + ret =init_mount (name,"/root" , fs, flags, data_page);if (ret) goto out;
@@ -628,7 +628,7 @@ void __init prepare_namespace(void)mount_root (); out:devtmpfs_mount (); -do_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL ); +init_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL );ksys_chroot ("." ); }
init/do_mounts.h +1 -0
@@ -8,6 +8,7 @@#include <linux/mount.h> #include <linux/major.h> #include <linux/root_dev.h> +#include <linux/init_syscalls.h> void mount_block_root (char *name,int flags);void mount_root (void );
init/do_mounts_initrd.c +3 -3
@@ -62,7 +62,7 @@ static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)console_on_rootfs ();/* move initrd over / and chdir/chroot in initrd root */ ksys_chdir ("/root" ); -do_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL ); +init_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL );ksys_chroot ("." );ksys_setsid ();return 0 ;
@@ -99,7 +99,7 @@ static void __init handle_initrd(void) current->flags &= ~PF_FREEZER_SKIP ;/* move initrd to rootfs' /old */ -do_mount (".." ,"." ,NULL ,MS_MOVE ,NULL ); +init_mount (".." ,"." ,NULL ,MS_MOVE ,NULL );/* switch root and cwd back to / of rootfs */ ksys_chroot (".." );
@@ -113,7 +113,7 @@ static void __init handle_initrd(void)mount_root ();printk (KERN_NOTICE "Trying to move old root to /initrd ... " ); - error =do_mount ("/old" ,"/root/initrd" ,NULL ,MS_MOVE ,NULL ); + error =init_mount ("/old" ,"/root/initrd" ,NULL ,MS_MOVE ,NULL );if (!error)printk ("okay\n" );else {
Signature · 1 line
2.27.0
PATCH 8/21 init: add an init_umount helper
In reply to Christoph HellwigLike ksys_umount, but takes a kernel pointer for the destination path. Switch over the umount in the init code, which just happen to work due to the implicit set_fs(KERNEL_DS) during early init right now.
--- fs/for_init.c | 14 ++++++++++++++ fs/internal.h | 1 + fs/namespace.c | 4 ++-- include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 1 - init/do_mounts_initrd.c | 2 +- 6 files changed, 19 insertions(+), 4 deletions(-)
fs/for_init.c +14 -0
@@ -19,3 +19,17 @@ int __init init_mount(const char *dev_name, const char *dir_name,path_put (&path);return ret; } + +int __init init_umount (const char *name,int flags) +{ +int lookup_flags =LOOKUP_MOUNTPOINT ; +struct path path; +int ret; + +if (!(flags &UMOUNT_NOFOLLOW )) + lookup_flags |=LOOKUP_FOLLOW ; + ret =kern_path (name, lookup_flags, &path); +if (ret) +return ret; +return path_umount (&path, flags); +}
fs/internal.h +1 -0
@@ -92,6 +92,7 @@ extern void dissolve_on_fput(struct vfsmount *);int path_mount (const char *dev_name,struct path *path,const char *type_page,unsigned long flags,void *data_page); +int path_umount (struct path *path,int flags);/* * fs_struct.c
fs/namespace.c +2 -2
@@ -1706,7 +1706,7 @@ static inline bool may_mandlock(void) }#endif -static int path_umount (struct path *path,int flags) +int path_umount (struct path *path,int flags) {struct mount *mnt;int retval;
@@ -1736,7 +1736,7 @@ static int path_umount(struct path *path, int flags)return retval; } -int ksys_umount (char __user *name,int flags) +static int ksys_umount (char __user *name,int flags) {int lookup_flags =LOOKUP_MOUNTPOINT ;struct path path;
include/linux/init_syscalls.h +1 -0
@@ -2,3 +2,4 @@int __init init_mount (const char *dev_name,const char *dir_name,const char *type_page,unsigned long flags,void *data_page); +int __init init_umount (const char *name,int flags);
include/linux/syscalls.h +0 -1
@@ -1236,7 +1236,6 @@ asmlinkage long sys_ni_syscall(void);* the ksys_xyzyyz() functions prototyped below. */ -int ksys_umount (char __user *name,int flags);int ksys_chroot (const char __user *filename);ssize_t ksys_write (unsigned int fd,const char __user *buf,size_t count);int ksys_chdir (const char __user *filename);
init/do_mounts_initrd.c +1 -1
@@ -122,7 +122,7 @@ static void __init handle_initrd(void)else printk ("failed\n" );printk (KERN_NOTICE "Unmounting old root\n" ); -ksys_umount ("/old" ,MNT_DETACH ); +init_umount ("/old" ,MNT_DETACH ); } }
Signature · 1 line
2.27.0
PATCH 9/21 init: add an init_unlink helper
In reply to Christoph HellwigAdd a simple helper to unlink with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_unlink.
--- fs/for_init.c | 5 +++++ include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 7 ------- init/do_mounts.h | 2 +- init/do_mounts_initrd.c | 4 ++-- init/do_mounts_rd.c | 2 +- init/initramfs.c | 3 ++- 7 files changed, 12 insertions(+), 12 deletions(-)
fs/for_init.c +5 -0
@@ -33,3 +33,8 @@ int __init init_umount(const char *name, int flags)return ret;return path_umount (&path, flags); } + +int __init init_unlink (const char *pathname) +{ +return do_unlinkat (AT_FDCWD ,getname_kernel (pathname)); +}
include/linux/init_syscalls.h +1 -0
@@ -3,3 +3,4 @@int __init init_mount (const char *dev_name,const char *dir_name,const char *type_page,unsigned long flags,void *data_page);int __init init_umount (const char *name,int flags); +int __init init_unlink (const char *pathname);
include/linux/syscalls.h +0 -7
@@ -1273,13 +1273,6 @@ int compat_ksys_ipc(u32 call, int first, int second,* The following kernel syscall equivalents are just wrappers to fs-internal * functions. Therefore, provide stubs to be inlined at the callsites. */ -extern long do_unlinkat (int dfd,struct filename *name); - -static inline long ksys_unlink (const char __user *pathname) -{ -return do_unlinkat (AT_FDCWD ,getname (pathname)); -} -long do_rmdir (int dfd,struct filename *name);static inline long ksys_rmdir (const char __user *pathname)
init/do_mounts.h +1 -1
@@ -16,7 +16,7 @@ extern int root_mountflags;static inline __init int create_dev (char *name,dev_t dev) { -ksys_unlink (name); +init_unlink (name);return ksys_mknod (name,S_IFBLK |0600 ,new_encode_dev (dev)); }
init/do_mounts_initrd.c +2 -2
@@ -137,11 +137,11 @@ bool __init initrd_load(void)* mounted in the normal path. */ if (rd_load_image ("/initrd.image" ) &&ROOT_DEV != Root_RAM0) { -ksys_unlink ("/initrd.image" ); +init_unlink ("/initrd.image" );handle_initrd ();return true; } } -ksys_unlink ("/initrd.image" ); +init_unlink ("/initrd.image" );return false; }
init/do_mounts_rd.c +1 -1
@@ -271,7 +271,7 @@ int __init rd_load_image(char *from)fput (out_file); out:kfree (buf); -ksys_unlink ("/dev/ram" ); +init_unlink ("/dev/ram" );return res; }
init/initramfs.c +2 -1
@@ -12,6 +12,7 @@#include <linux/file.h> #include <linux/memblock.h> #include <linux/namei.h> +#include <linux/init_syscalls.h> static ssize_t __init xwrite (struct file *file,const char *p,size_t count) {
@@ -300,7 +301,7 @@ static void __init clean_path(char *path, umode_t fmode)if (S_ISDIR (st.mode))ksys_rmdir (path);else -ksys_unlink (path); +init_unlink (path); } }
Signature · 1 line
2.27.0
PATCH 10/21 init: add an init_rmdir helper
In reply to Christoph HellwigAdd a simple helper to rmdir with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_rmdir.
--- fs/for_init.c | 5 +++++ include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 7 ------- init/initramfs.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-)
fs/for_init.c +5 -0
@@ -38,3 +38,8 @@ int __init init_unlink(const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname)); } + +int __init init_rmdir (const char *pathname) +{ +return do_rmdir (AT_FDCWD ,getname_kernel (pathname)); +}
include/linux/init_syscalls.h +1 -0
@@ -4,3 +4,4 @@ int __init init_mount(const char *dev_name, const char *dir_name, const char *type_page, unsigned long flags, void *data_page);int __init init_umount (const char *name,int flags);int __init init_unlink (const char *pathname); +int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -7
@@ -1273,13 +1273,6 @@ int compat_ksys_ipc(u32 call, int first, int second,* The following kernel syscall equivalents are just wrappers to fs-internal * functions. Therefore, provide stubs to be inlined at the callsites. */ -long do_rmdir (int dfd,struct filename *name); - -static inline long ksys_rmdir (const char __user *pathname) -{ -return do_rmdir (AT_FDCWD ,getname (pathname)); -} -extern long do_mkdirat (int dfd,const char __user *pathname,umode_t mode);static inline long ksys_mkdir (const char __user *pathname,umode_t mode)
init/initramfs.c +1 -1
@@ -299,7 +299,7 @@ static void __init clean_path(char *path, umode_t fmode)if (!vfs_lstat (path, &st) && (st.mode ^ fmode) &S_IFMT ) {if (S_ISDIR (st.mode)) -ksys_rmdir (path); +init_rmdir (path);else init_unlink (path); }
Signature · 1 line
2.27.0
PATCH 11/21 init: add an init_chdir helper
In reply to Christoph HellwigAdd a simple helper to chdir with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_chdir.
--- drivers/base/devtmpfs.c | 2 +- fs/for_init.c | 16 ++++++++++++++++ fs/open.c | 7 +------ include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 1 - init/do_mounts.c | 2 +- init/do_mounts_initrd.c | 8 ++++---- 7 files changed, 24 insertions(+), 13 deletions(-)
drivers/base/devtmpfs.c +1 -1
@@ -412,7 +412,7 @@ static int __init devtmpfs_setup(void *p) err =init_mount ("devtmpfs" ,"/" ,"devtmpfs" ,MS_SILENT ,NULL );if (err) goto out; -ksys_chdir ("/.." );/* will traverse into overmounted root */ +init_chdir ("/.." );/* will traverse into overmounted root */ ksys_chroot ("." ); out: *(int *)p = err;
fs/for_init.c +16 -0
@@ -3,6 +3,7 @@#include <linux/mount.h> #include <linux/namei.h> #include <linux/fs.h> +#include <linux/fs_struct.h> #include <linux/init_syscalls.h> #include "internal.h"
@@ -34,6 +35,21 @@ int __init init_umount(const char *name, int flags)return path_umount (&path, flags); } +int __init init_chdir (const char *filename) +{ +struct path path; +int error; + + error =kern_path (filename,LOOKUP_FOLLOW |LOOKUP_DIRECTORY , &path); +if (error) +return error; + error =inode_permission (path.dentry->d_inode,MAY_EXEC |MAY_CHDIR ); +if (!error) +set_fs_pwd (current->fs, &path); +path_put (&path); +return error; +} +int __init init_unlink (const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname));
fs/open.c +1 -6
@@ -482,7 +482,7 @@ SYSCALL_DEFINE2(access, const char __user *, filename, int, mode)return do_faccessat (AT_FDCWD , filename, mode,0 ); } -int ksys_chdir (const char __user *filename) +SYSCALL_DEFINE1(chdir, const char __user *, filename) {struct path path;int error;
@@ -508,11 +508,6 @@ int ksys_chdir(const char __user *filename)return error; } -SYSCALL_DEFINE1(chdir, const char __user *, filename) -{ -return ksys_chdir (filename); -} - SYSCALL_DEFINE1(fchdir, unsigned int, fd) {struct fd f =fdget_raw (fd);
include/linux/init_syscalls.h +1 -0
@@ -3,5 +3,6 @@int __init init_mount (const char *dev_name,const char *dir_name,const char *type_page,unsigned long flags,void *data_page);int __init init_umount (const char *name,int flags); +int __init init_chdir (const char *filename);int __init init_unlink (const char *pathname);int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -1
@@ -1238,7 +1238,6 @@ asmlinkage long sys_ni_syscall(void);int ksys_chroot (const char __user *filename);ssize_t ksys_write (unsigned int fd,const char __user *buf,size_t count); -int ksys_chdir (const char __user *filename);int ksys_fchown (unsigned int fd,uid_t user,gid_t group);ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count);void ksys_sync (void );
init/do_mounts.c +1 -1
@@ -408,7 +408,7 @@ static int __init do_mount_root(const char *name, const char *fs,if (ret) goto out; -ksys_chdir ("/root" ); +init_chdir ("/root" ); s = current->fs->pwd.dentry->d_sb;ROOT_DEV = s->s_dev; printk(KERN_INFO
init/do_mounts_initrd.c +4 -4
@@ -61,7 +61,7 @@ static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)ksys_unshare (CLONE_FS |CLONE_FILES );console_on_rootfs ();/* move initrd over / and chdir/chroot in initrd root */ -ksys_chdir ("/root" ); +init_chdir ("/root" );init_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL );ksys_chroot ("." );ksys_setsid ();
@@ -82,7 +82,7 @@ static void __init handle_initrd(void)/* mount initrd on rootfs' /root */ mount_block_root ("/dev/root.old" , root_mountflags & ~MS_RDONLY );ksys_mkdir ("/old" ,0700 ); -ksys_chdir ("/old" ); +init_chdir ("/old" );/* * In case that a resume from disk is carried out by linuxrc or one of
@@ -104,11 +104,11 @@ static void __init handle_initrd(void)ksys_chroot (".." );if (new_decode_dev (real_root_dev) == Root_RAM0) { -ksys_chdir ("/old" ); +init_chdir ("/old" );return ; } -ksys_chdir ("/" ); +init_chdir ("/" );ROOT_DEV =new_decode_dev (real_root_dev);mount_root ();
Signature · 1 line
2.27.0
PATCH 12/21 init: add an init_chroot helper
In reply to Christoph HellwigAdd a simple helper to chroot with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_chroot.
--- drivers/base/devtmpfs.c | 2 +- fs/for_init.c | 24 ++++++++++++++++++++++++ fs/open.c | 7 +------ include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 2 -- init/do_mounts.c | 2 +- init/do_mounts_initrd.c | 4 ++-- 7 files changed, 30 insertions(+), 12 deletions(-)
drivers/base/devtmpfs.c +1 -1
@@ -413,7 +413,7 @@ static int __init devtmpfs_setup(void *p)if (err) goto out;init_chdir ("/.." );/* will traverse into overmounted root */ -ksys_chroot ("." ); +init_chroot ("." ); out: *(int *)p = err;complete (&setup_done);
fs/for_init.c +24 -0
@@ -5,6 +5,7 @@#include <linux/fs.h> #include <linux/fs_struct.h> #include <linux/init_syscalls.h> +#include <linux/security.h> #include "internal.h" int __init init_mount(const char *dev_name, const char *dir_name,
@@ -50,6 +51,29 @@ int __init init_chdir(const char *filename)return error; } +int __init init_chroot (const char *filename) +{ +struct path path; +int error; + + error =kern_path (filename,LOOKUP_FOLLOW |LOOKUP_DIRECTORY , &path); +if (error) +return error; + error =inode_permission (path.dentry->d_inode,MAY_EXEC |MAY_CHDIR ); +if (error) + goto dput_and_out; + error = -EPERM ; +if (!ns_capable (current_user_ns (),CAP_SYS_CHROOT )) + goto dput_and_out; + error =security_path_chroot (&path); +if (error) + goto dput_and_out; +set_fs_root (current->fs, &path); +dput_and_out: +path_put (&path); +return error; +} +int __init init_unlink (const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname));
fs/open.c +1 -6
@@ -530,7 +530,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)return error; } -int ksys_chroot (const char __user *filename) +SYSCALL_DEFINE1(chroot, const char __user *, filename) {struct path path;int error;
@@ -563,11 +563,6 @@ int ksys_chroot(const char __user *filename)return error; } -SYSCALL_DEFINE1(chroot, const char __user *, filename) -{ -return ksys_chroot (filename); -} -static int chmod_common (const struct path *path,umode_t mode) {struct inode *inode = path->dentry->d_inode;
include/linux/init_syscalls.h +1 -0
@@ -4,5 +4,6 @@ int __init init_mount(const char *dev_name, const char *dir_name, const char *type_page, unsigned long flags, void *data_page);int __init init_umount (const char *name,int flags);int __init init_chdir (const char *filename); +int __init init_chroot (const char *filename);int __init init_unlink (const char *pathname);int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -2
@@ -1235,8 +1235,6 @@ asmlinkage long sys_ni_syscall(void);* Instead, use one of the functions which work equivalently, such as * the ksys_xyzyyz() functions prototyped below. */ - -int ksys_chroot (const char __user *filename);ssize_t ksys_write (unsigned int fd,const char __user *buf,size_t count);int ksys_fchown (unsigned int fd,uid_t user,gid_t group);ssize_t ksys_read (unsigned int fd,char __user *buf,size_t count);
init/do_mounts.c +1 -1
@@ -629,7 +629,7 @@ void __init prepare_namespace(void) out:devtmpfs_mount ();init_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL ); -ksys_chroot ("." ); +init_chroot ("." ); }static bool is_tmpfs;
init/do_mounts_initrd.c +2 -2
@@ -63,7 +63,7 @@ static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)/* move initrd over / and chdir/chroot in initrd root */ init_chdir ("/root" );init_mount ("." ,"/" ,NULL ,MS_MOVE ,NULL ); -ksys_chroot ("." ); +init_chroot ("." );ksys_setsid ();return 0 ; }
@@ -101,7 +101,7 @@ static void __init handle_initrd(void)/* move initrd to rootfs' /old */ init_mount (".." ,"." ,NULL ,MS_MOVE ,NULL );/* switch root and cwd back to / of rootfs */ -ksys_chroot (".." ); +init_chroot (".." );if (new_decode_dev (real_root_dev) == Root_RAM0) {init_chdir ("/old" );
Signature · 1 line
2.27.0
PATCH 13/21 init: add an init_chown helper
In reply to Christoph HellwigAdd a simple helper to chown with a kernel space file name and switch the early init code over to it.
--- fs/for_init.c | 18 ++++++++++++++++++ fs/internal.h | 2 +- fs/open.c | 2 +- include/linux/init_syscalls.h | 1 + init/initramfs.c | 6 +++--- 5 files changed, 24 insertions(+), 5 deletions(-)
fs/for_init.c +18 -0
@@ -74,6 +74,24 @@ int __init init_chroot(const char *filename)return error; } +int __init init_chown (const char *filename,uid_t user,gid_t group,int flags) +{ +int lookup_flags = (flags &AT_SYMLINK_NOFOLLOW ) ?0 :LOOKUP_FOLLOW ; +struct path path; +int error; + + error =kern_path (filename, lookup_flags, &path); +if (error) +return error; + error =mnt_want_write (path.mnt); +if (!error) { + error =chown_common (&path, user, group); +mnt_drop_write (path.mnt); + } +path_put (&path); +return error; +} +int __init init_unlink (const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname));
fs/internal.h +1 -1
@@ -134,7 +134,7 @@ long do_sys_ftruncate(unsigned int fd, loff_t length, int small);int do_fchmodat (int dfd,const char __user *filename,umode_t mode);int do_fchownat (int dfd,const char __user *filename,uid_t user,gid_t group,int flag); - +int chown_common (const struct path *path,uid_t user,gid_t group);extern int vfs_open (const struct path *,struct file *);/*
fs/open.c +1 -1
@@ -639,7 +639,7 @@ SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode)return do_fchmodat (AT_FDCWD , filename, mode); } -static int chown_common (const struct path *path,uid_t user,gid_t group) +int chown_common (const struct path *path,uid_t user,gid_t group) {struct inode *inode = path->dentry->d_inode;struct inode *delegated_inode =NULL ;
include/linux/init_syscalls.h +1 -0
@@ -5,5 +5,6 @@ int __init init_mount(const char *dev_name, const char *dir_name,int __init init_umount (const char *name,int flags);int __init init_chdir (const char *filename);int __init init_chroot (const char *filename); +int __init init_chown (const char *filename,uid_t user,gid_t group,int flags);int __init init_unlink (const char *pathname);int __init init_rmdir (const char *pathname);
init/initramfs.c +3 -3
@@ -346,14 +346,14 @@ static int __init do_name(void) } }else if (S_ISDIR (mode)) {ksys_mkdir (collected, mode); -ksys_chown (collected, uid, gid); +init_chown (collected, uid, gid,0 );ksys_chmod (collected, mode);dir_add (collected, mtime); }else if (S_ISBLK (mode) ||S_ISCHR (mode) ||S_ISFIFO (mode) ||S_ISSOCK (mode)) {if (maybe_link () ==0 ) {ksys_mknod (collected, mode, rdev); -ksys_chown (collected, uid, gid); +init_chown (collected, uid, gid,0 );ksys_chmod (collected, mode);do_utime (collected, mtime); }
@@ -391,7 +391,7 @@ static int __init do_symlink(void) collected[N_ALIGN (name_len) + body_len] ='\0' ;clean_path (collected,0 );ksys_symlink (collected +N_ALIGN (name_len), collected); -ksys_lchown (collected, uid, gid); +init_chown (collected, uid, gid,AT_SYMLINK_NOFOLLOW );do_utime (collected, mtime); state = SkipIt; next_state = Reset;
Signature · 1 line
2.27.0
PATCH 14/21 init: add an init_chmod helper
In reply to Christoph HellwigAdd a simple helper to chmod with a kernel space file name and switch the early init code over to it.
--- fs/for_init.c | 13 +++++++++++++ fs/internal.h | 2 +- fs/open.c | 4 ++-- include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 7 ------- init/initramfs.c | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-)
fs/for_init.c +13 -0
@@ -92,6 +92,19 @@ int __init init_chown(const char *filename, uid_t user, gid_t group, int flags)return error; } +int __init init_chmod (const char *filename,umode_t mode) +{ +struct path path; +int error; + + error =kern_path (filename,LOOKUP_FOLLOW , &path); +if (error) +return error; + error =chmod_common (&path, mode); +path_put (&path); +return error; +} +int __init init_unlink (const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname));
fs/internal.h +1 -1
@@ -131,7 +131,7 @@ extern struct open_how build_open_how(int flags, umode_t mode);extern int build_open_flags (const struct open_how *how,struct open_flags *op);long do_sys_ftruncate (unsigned int fd,loff_t length,int small); -int do_fchmodat (int dfd,const char __user *filename,umode_t mode); +int chmod_common (const struct path *path,umode_t mode);int do_fchownat (int dfd,const char __user *filename,uid_t user,gid_t group,int flag);int chown_common (const struct path *path,uid_t user,gid_t group);
fs/open.c +2 -2
@@ -563,7 +563,7 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)return error; } -static int chmod_common (const struct path *path,umode_t mode) +int chmod_common (const struct path *path,umode_t mode) {struct inode *inode = path->dentry->d_inode;struct inode *delegated_inode =NULL ;
@@ -610,7 +610,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)return err; } -int do_fchmodat (int dfd,const char __user *filename,umode_t mode) +static int do_fchmodat (int dfd,const char __user *filename,umode_t mode) {struct path path;int error;
include/linux/init_syscalls.h +1 -0
@@ -6,5 +6,6 @@ int __init init_umount(const char *name, int flags);int __init init_chdir (const char *filename);int __init init_chroot (const char *filename);int __init init_chown (const char *filename,uid_t user,gid_t group,int flags); +int __init init_chmod (const char *filename,umode_t mode);int __init init_unlink (const char *pathname);int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -7
@@ -1304,13 +1304,6 @@ static inline long ksys_link(const char __user *oldname,return do_linkat (AT_FDCWD , oldname,AT_FDCWD , newname,0 ); } -extern int do_fchmodat (int dfd,const char __user *filename,umode_t mode); - -static inline int ksys_chmod (const char __user *filename,umode_t mode) -{ -return do_fchmodat (AT_FDCWD , filename, mode); -} -long do_faccessat (int dfd,const char __user *filename,int mode,int flags);static inline long ksys_access (const char __user *filename,int mode)
init/initramfs.c +2 -2
@@ -347,14 +347,14 @@ static int __init do_name(void) }else if (S_ISDIR (mode)) {ksys_mkdir (collected, mode);init_chown (collected, uid, gid,0 ); -ksys_chmod (collected, mode); +init_chmod (collected, mode);dir_add (collected, mtime); }else if (S_ISBLK (mode) ||S_ISCHR (mode) ||S_ISFIFO (mode) ||S_ISSOCK (mode)) {if (maybe_link () ==0 ) {ksys_mknod (collected, mode, rdev);init_chown (collected, uid, gid,0 ); -ksys_chmod (collected, mode); +init_chmod (collected, mode);do_utime (collected, mtime); } }
Signature · 1 line
2.27.0
PATCH 15/21 init: add an init_eaccess helper
In reply to Christoph HellwigAdd a simple helper to check if a file exists based on kernel space file name and switch the early init code over to it. Note that this theoretically changes behavior as it always is based on the effective permissions. But during early init that doesn't make a difference.
--- fs/for_init.c | 13 +++++++++++++ fs/open.c | 2 +- include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 7 ------- init/main.c | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-)
fs/for_init.c +13 -0
@@ -105,6 +105,19 @@ int __init init_chmod(const char *filename, umode_t mode)return error; } +int __init init_eaccess (const char *filename) +{ +struct path path; +int error; + + error =kern_path (filename,LOOKUP_FOLLOW , &path); +if (error) +return error; + error =inode_permission (d_inode (path.dentry),MAY_ACCESS ); +path_put (&path); +return error; +} +int __init init_unlink (const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname));
fs/open.c +1 -1
@@ -394,7 +394,7 @@ static const struct cred *access_override_creds(void)return old_cred; } -long do_faccessat (int dfd,const char __user *filename,int mode,int flags) +static long do_faccessat (int dfd,const char __user *filename,int mode,int flags) {struct path path;struct inode *inode;
include/linux/init_syscalls.h +1 -0
@@ -7,5 +7,6 @@ int __init init_chdir(const char *filename);int __init init_chroot (const char *filename);int __init init_chown (const char *filename,uid_t user,gid_t group,int flags);int __init init_chmod (const char *filename,umode_t mode); +int __init init_eaccess (const char *filename);int __init init_unlink (const char *pathname);int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -7
@@ -1304,13 +1304,6 @@ static inline long ksys_link(const char __user *oldname,return do_linkat (AT_FDCWD , oldname,AT_FDCWD , newname,0 ); } -long do_faccessat (int dfd,const char __user *filename,int mode,int flags); - -static inline long ksys_access (const char __user *filename,int mode) -{ -return do_faccessat (AT_FDCWD , filename, mode,0 ); -} -extern int do_fchownat (int dfd,const char __user *filename,uid_t user,gid_t group,int flag);
init/main.c +2 -2
@@ -96,6 +96,7 @@#include <linux/jump_label.h> #include <linux/mem_encrypt.h> #include <linux/kcsan.h> +#include <linux/init_syscalls.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -1514,8 +1515,7 @@ static noinline void __init kernel_init_freeable(void)* check if there is an early userspace init. If yes, let it do all * the work */ -if (ksys_access ((const char __user *) - ramdisk_execute_command,0 ) !=0 ) { +if (init_eaccess (ramdisk_execute_command) !=0 ) { ramdisk_execute_command =NULL ;prepare_namespace (); }
Signature · 1 line
2.27.0
PATCH 16/21 init: add an init_link helper
In reply to Christoph HellwigAdd a simple helper to link with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_link.
--- fs/for_init.c | 33 +++++++++++++++++++++++++++++++++ fs/internal.h | 3 +-- fs/namei.c | 4 ++-- include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 9 --------- init/initramfs.c | 2 +- 6 files changed, 38 insertions(+), 14 deletions(-)
fs/for_init.c +33 -0
@@ -118,6 +118,39 @@ int __init init_eaccess(const char *filename)return error; } +int __init init_link (const char *oldname,const char *newname) +{ +struct dentry *new_dentry; +struct path old_path, new_path; +int error; + + error =kern_path (oldname,0 , &old_path); +if (error) +return error; + + new_dentry =kern_path_create (AT_FDCWD , newname, &new_path,0 ); + error =PTR_ERR (new_dentry); +if (IS_ERR (new_dentry)) + goto out; + + error = -EXDEV ; +if (old_path.mnt != new_path.mnt) + goto out_dput; + error =may_linkat (&old_path); +if (unlikely (error)) + goto out_dput; + error =security_path_link (old_path.dentry, &new_path, new_dentry); +if (error) + goto out_dput; + error =vfs_link (old_path.dentry, new_path.dentry->d_inode, new_dentry, +NULL ); +out_dput: +done_path_create (&new_path, new_dentry); +out: +path_put (&old_path); +return error; +} +int __init init_unlink (const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname));
fs/internal.h +1 -2
@@ -69,8 +69,7 @@ long do_rmdir(int dfd, struct filename *name);long do_unlinkat (int dfd,struct filename *name);long do_symlinkat (const char __user *oldname,int newdfd,const char __user *newname); -int do_linkat (int olddfd,const char __user *oldname,int newdfd, -const char __user *newname,int flags); +int may_linkat (struct path *link);/* * namespace.c
fs/namei.c +2 -2
@@ -1024,7 +1024,7 @@ static bool safe_hardlink_source(struct inode *inode)* * Returns 0 if successful, -ve on error. */ -static int may_linkat (struct path *link) +int may_linkat (struct path *link) {struct inode *inode = link->dentry->d_inode;
@@ -4086,7 +4086,7 @@ EXPORT_SYMBOL(vfs_link);* with linux 2.0, and to avoid hard-linking to directories * and other special files. --ADM */ -int do_linkat (int olddfd,const char __user *oldname,int newdfd, +static int do_linkat (int olddfd,const char __user *oldname,int newdfd,const char __user *newname,int flags) {struct dentry *new_dentry;
include/linux/init_syscalls.h +1 -0
@@ -8,5 +8,6 @@ int __init init_chroot(const char *filename);int __init init_chown (const char *filename,uid_t user,gid_t group,int flags);int __init init_chmod (const char *filename,umode_t mode);int __init init_eaccess (const char *filename); +int __init init_link (const char *oldname,const char *newname);int __init init_unlink (const char *pathname);int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -9
@@ -1295,15 +1295,6 @@ static inline long ksys_mknod(const char __user *filename, umode_t mode,return do_mknodat (AT_FDCWD , filename, mode, dev); } -extern int do_linkat (int olddfd,const char __user *oldname,int newdfd, -const char __user *newname,int flags); - -static inline long ksys_link (const char __user *oldname, -const char __user *newname) -{ -return do_linkat (AT_FDCWD , oldname,AT_FDCWD , newname,0 ); -} -extern int do_fchownat (int dfd,const char __user *filename,uid_t user,gid_t group,int flag);
init/initramfs.c +1 -1
@@ -311,7 +311,7 @@ static int __init maybe_link(void)char *old =find_link (major, minor, ino, mode, collected);if (old) {clean_path (collected,0 ); -return (ksys_link (old, collected) <0 ) ?-1 :1 ; +return (init_link (old, collected) <0 ) ?-1 :1 ; } }return 0 ;
Signature · 1 line
2.27.0
PATCH 17/21 init: add an init_symlink helper
In reply to Christoph HellwigAdd a simple helper to symlink with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_symlink.
--- fs/for_init.c | 16 ++++++++++++++++ fs/internal.h | 2 -- fs/namei.c | 2 +- include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 9 --------- init/initramfs.c | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-)
fs/for_init.c +16 -0
@@ -151,6 +151,22 @@ int __init init_link(const char *oldname, const char *newname)return error; } +int __init init_symlink (const char *oldname,const char *newname) +{ +struct dentry *dentry; +struct path path; +int error; + + dentry =kern_path_create (AT_FDCWD , newname, &path,0 ); +if (IS_ERR (dentry)) +return PTR_ERR (dentry); + error =security_path_symlink (&path, dentry, oldname); +if (!error) + error =vfs_symlink (path.dentry->d_inode, dentry, oldname); +done_path_create (&path, dentry); +return error; +} +int __init init_unlink (const char *pathname) {return do_unlinkat (AT_FDCWD ,getname_kernel (pathname));
fs/internal.h +0 -2
@@ -67,8 +67,6 @@ long do_mknodat(int dfd, const char __user *filename, umode_t mode,long do_mkdirat (int dfd,const char __user *pathname,umode_t mode);long do_rmdir (int dfd,struct filename *name);long do_unlinkat (int dfd,struct filename *name); -long do_symlinkat (const char __user *oldname,int newdfd, -const char __user *newname);int may_linkat (struct path *link);/*
fs/namei.c +1 -1
@@ -3955,7 +3955,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname) }EXPORT_SYMBOL (vfs_symlink); -long do_symlinkat (const char __user *oldname,int newdfd, +static long do_symlinkat (const char __user *oldname,int newdfd,const char __user *newname) {int error;
include/linux/init_syscalls.h +1 -0
@@ -9,5 +9,6 @@ int __init init_chown(const char *filename, uid_t user, gid_t group, int flags);int __init init_chmod (const char *filename,umode_t mode);int __init init_eaccess (const char *filename);int __init init_link (const char *oldname,const char *newname); +int __init init_symlink (const char *oldname,const char *newname);int __init init_unlink (const char *pathname);int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -9
@@ -1277,15 +1277,6 @@ static inline long ksys_mkdir(const char __user *pathname, umode_t mode)return do_mkdirat (AT_FDCWD , pathname, mode); } -extern long do_symlinkat (const char __user *oldname,int newdfd, -const char __user *newname); - -static inline long ksys_symlink (const char __user *oldname, -const char __user *newname) -{ -return do_symlinkat (oldname,AT_FDCWD , newname); -} -extern long do_mknodat (int dfd,const char __user *filename,umode_t mode,unsigned int dev);
init/initramfs.c +1 -1
@@ -390,7 +390,7 @@ static int __init do_symlink(void) { collected[N_ALIGN (name_len) + body_len] ='\0' ;clean_path (collected,0 ); -ksys_symlink (collected +N_ALIGN (name_len), collected); +init_symlink (collected +N_ALIGN (name_len), collected);init_chown (collected, uid, gid,AT_SYMLINK_NOFOLLOW );do_utime (collected, mtime); state = SkipIt;
Signature · 1 line
2.27.0
PATCH 18/21 init: add an init_mkdir helper
In reply to Christoph HellwigAdd a simple helper to mkdir with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_mkdir.
--- fs/for_init.c | 18 ++++++++++++++++++ fs/internal.h | 1 - fs/namei.c | 2 +- include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 7 ------- init/do_mounts_initrd.c | 2 +- init/initramfs.c | 2 +- init/noinitramfs.c | 5 +++-- 8 files changed, 25 insertions(+), 13 deletions(-)
fs/for_init.c +18 -0
@@ -172,6 +172,24 @@ int __init init_unlink(const char *pathname)return do_unlinkat (AT_FDCWD ,getname_kernel (pathname)); } +int __init init_mkdir (const char *pathname,umode_t mode) +{ +struct dentry *dentry; +struct path path; +int error; + + dentry =kern_path_create (AT_FDCWD , pathname, &path,LOOKUP_DIRECTORY ); +if (IS_ERR (dentry)) +return PTR_ERR (dentry); +if (!IS_POSIXACL (path.dentry->d_inode)) + mode &= ~current_umask (); + error =security_path_mkdir (&path, dentry, mode); +if (!error) + error =vfs_mkdir (path.dentry->d_inode, dentry, mode); +done_path_create (&path, dentry); +return error; +} +int __init init_rmdir (const char *pathname) {return do_rmdir (AT_FDCWD ,getname_kernel (pathname));
fs/internal.h +0 -1
@@ -64,7 +64,6 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *, const char *, unsigned int, struct path *);long do_mknodat (int dfd,const char __user *filename,umode_t mode,unsigned int dev); -long do_mkdirat (int dfd,const char __user *pathname,umode_t mode);long do_rmdir (int dfd,struct filename *name);long do_unlinkat (int dfd,struct filename *name);int may_linkat (struct path *link);
fs/namei.c +1 -1
@@ -3645,7 +3645,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) }EXPORT_SYMBOL (vfs_mkdir); -long do_mkdirat (int dfd,const char __user *pathname,umode_t mode) +static long do_mkdirat (int dfd,const char __user *pathname,umode_t mode) {struct dentry *dentry;struct path path;
include/linux/init_syscalls.h +1 -0
@@ -11,4 +11,5 @@ int __init init_eaccess(const char *filename);int __init init_link (const char *oldname,const char *newname);int __init init_symlink (const char *oldname,const char *newname);int __init init_unlink (const char *pathname); +int __init init_mkdir (const char *pathname,umode_t mode);int __init init_rmdir (const char *pathname);
include/linux/syscalls.h +0 -7
@@ -1270,13 +1270,6 @@ int compat_ksys_ipc(u32 call, int first, int second,* The following kernel syscall equivalents are just wrappers to fs-internal * functions. Therefore, provide stubs to be inlined at the callsites. */ -extern long do_mkdirat (int dfd,const char __user *pathname,umode_t mode); - -static inline long ksys_mkdir (const char __user *pathname,umode_t mode) -{ -return do_mkdirat (AT_FDCWD , pathname, mode); -} -extern long do_mknodat (int dfd,const char __user *filename,umode_t mode,unsigned int dev);
init/do_mounts_initrd.c +1 -1
@@ -81,7 +81,7 @@ static void __init handle_initrd(void)create_dev ("/dev/root.old" , Root_RAM0);/* mount initrd on rootfs' /root */ mount_block_root ("/dev/root.old" , root_mountflags & ~MS_RDONLY ); -ksys_mkdir ("/old" ,0700 ); +init_mkdir ("/old" ,0700 );init_chdir ("/old" );/*
init/initramfs.c +1 -1
@@ -345,7 +345,7 @@ static int __init do_name(void) state = CopyFile; } }else if (S_ISDIR (mode)) { -ksys_mkdir (collected, mode); +init_mkdir (collected, mode);init_chown (collected, uid, gid,0 );init_chmod (collected, mode);dir_add (collected, mtime);
init/noinitramfs.c +3 -2
@@ -9,6 +9,7 @@#include <linux/stat.h> #include <linux/kdev_t.h> #include <linux/syscalls.h> +#include <linux/init_syscalls.h> /* * Create a simple rootfs that is similar to the default initramfs
@@ -17,7 +18,7 @@ static int __init default_rootfs(void) {int err; - err =ksys_mkdir ((const char __user __force *)"/dev" ,0755 ); + err =init_mkdir ("/dev" ,0755 );if (err <0 ) goto out;
@@ -27,7 +28,7 @@ static int __init default_rootfs(void)if (err <0 ) goto out; - err =ksys_mkdir ((const char __user __force *)"/root" ,0700 ); + err =init_mkdir ("/root" ,0700 );if (err <0 ) goto out;
Signature · 1 line
2.27.0
PATCH 19/21 init: add an init_mknod helper
In reply to Christoph HellwigAdd a simple helper to mknod with a kernel space file name and switch the early init code over to it. Remove the now unused ksys_mknod.
--- fs/for_init.c | 25 +++++++++++++++++++++++++ fs/internal.h | 2 -- fs/namei.c | 2 +- include/linux/init_syscalls.h | 1 + include/linux/syscalls.h | 9 --------- init/do_mounts.h | 2 +- init/initramfs.c | 2 +- init/noinitramfs.c | 3 +-- 8 files changed, 30 insertions(+), 16 deletions(-)
fs/for_init.c +25 -0
@@ -118,6 +118,31 @@ int __init init_eaccess(const char *filename)return error; } +int __init init_mknod (const char *filename,umode_t mode,unsigned int dev) +{ +struct dentry *dentry; +struct path path; +int error; + +if (S_ISFIFO (mode) ||S_ISSOCK (mode)) + dev =0 ; +else if (!(S_ISBLK (mode) ||S_ISCHR (mode))) +return -EINVAL ; + + dentry =kern_path_create (AT_FDCWD , filename, &path,0 ); +if (IS_ERR (dentry)) +return PTR_ERR (dentry); + +if (!IS_POSIXACL (path.dentry->d_inode)) + mode &= ~current_umask (); + error =security_path_mknod (&path, dentry, mode, dev); +if (!error) + error =vfs_mknod (path.dentry->d_inode, dentry, mode, +new_decode_dev (dev)); +done_path_create (&path, dentry); +return error; +} +int __init init_link (const char *oldname,const char *newname) {struct dentry *new_dentry;
fs/internal.h +0 -2
@@ -62,8 +62,6 @@ extern int filename_lookup(int dfd, struct filename *name, unsigned flags, struct path *path, struct path *root);extern int vfs_path_lookup (struct dentry *,struct vfsmount *,const char *,unsigned int ,struct path *); -long do_mknodat (int dfd,const char __user *filename,umode_t mode, -unsigned int dev);long do_rmdir (int dfd,struct filename *name);long do_unlinkat (int dfd,struct filename *name);int may_linkat (struct path *link);
fs/namei.c +1 -1
@@ -3564,7 +3564,7 @@ static int may_mknod(umode_t mode) } } -long do_mknodat (int dfd,const char __user *filename,umode_t mode, +static long do_mknodat (int dfd,const char __user *filename,umode_t mode,unsigned int dev) {struct dentry *dentry;
include/linux/init_syscalls.h +1 -0
@@ -8,6 +8,7 @@ int __init init_chroot(const char *filename);int __init init_chown (const char *filename,uid_t user,gid_t group,int flags);int __init init_chmod (const char *filename,umode_t mode);int __init init_eaccess (const char *filename); +int __init init_mknod (const char *filename,umode_t mode,unsigned int dev);int __init init_link (const char *oldname,const char *newname);int __init init_symlink (const char *oldname,const char *newname);int __init init_unlink (const char *pathname);
include/linux/syscalls.h +0 -9
@@ -1270,15 +1270,6 @@ int compat_ksys_ipc(u32 call, int first, int second,* The following kernel syscall equivalents are just wrappers to fs-internal * functions. Therefore, provide stubs to be inlined at the callsites. */ -extern long do_mknodat (int dfd,const char __user *filename,umode_t mode, -unsigned int dev); - -static inline long ksys_mknod (const char __user *filename,umode_t mode, -unsigned int dev) -{ -return do_mknodat (AT_FDCWD , filename, mode, dev); -} -extern int do_fchownat (int dfd,const char __user *filename,uid_t user,gid_t group,int flag);
init/do_mounts.h +1 -1
@@ -17,7 +17,7 @@ extern int root_mountflags;static inline __init int create_dev (char *name,dev_t dev) {init_unlink (name); -return ksys_mknod (name,S_IFBLK |0600 ,new_encode_dev (dev)); +return init_mknod (name,S_IFBLK |0600 ,new_encode_dev (dev)); }#ifdef CONFIG_BLK_DEV_RAM
init/initramfs.c +1 -1
@@ -352,7 +352,7 @@ static int __init do_name(void) }else if (S_ISBLK (mode) ||S_ISCHR (mode) ||S_ISFIFO (mode) ||S_ISSOCK (mode)) {if (maybe_link () ==0 ) { -ksys_mknod (collected, mode, rdev); +init_mknod (collected, mode, rdev);init_chown (collected, uid, gid,0 );init_chmod (collected, mode);do_utime (collected, mtime);
init/noinitramfs.c +1 -2
@@ -22,8 +22,7 @@ static int __init default_rootfs(void)if (err <0 ) goto out; - err =ksys_mknod ((const char __user __force *)"/dev/console" , -S_IFCHR |S_IRUSR |S_IWUSR , + err =init_mknod ("/dev/console" ,S_IFCHR |S_IRUSR |S_IWUSR ,new_encode_dev (MKDEV (5 ,1 )));if (err <0 ) goto out;
Signature · 1 line
2.27.0
PATCH 20/21 init: add an init_stat helper
In reply to Christoph HellwigAdd a simple helper to stat with a kernel space file name and switch the early init code over to it.
--- drivers/md/md-autodetect.c | 3 ++- fs/for_init.c | 15 +++++++++++++++ include/linux/init_syscalls.h | 1 + init/initramfs.c | 3 ++- 4 files changed, 20 insertions(+), 2 deletions(-)
drivers/md/md-autodetect.c +2 -1
@@ -5,6 +5,7 @@#include <linux/mount.h> #include <linux/major.h> #include <linux/delay.h> +#include <linux/init_syscalls.h> #include <linux/raid/detect.h> #include <linux/raid/md_u.h> #include <linux/raid/md_p.h>
@@ -151,7 +152,7 @@ static void __init md_setup_drive(struct md_setup_args *args)if (strncmp (devname,"/dev/" ,5 ) ==0 ) devname +=5 ;snprintf (comp_name,63 ,"/dev/%s" , devname); -if (vfs_stat (comp_name, &stat) ==0 &&S_ISBLK (stat.mode)) +if (init_stat (comp_name, &stat,0 ) ==0 &&S_ISBLK (stat.mode)) dev =new_decode_dev (stat.rdev);if (!dev) {pr_warn ("md: Unknown device name: %s\n" , devname);
fs/for_init.c +15 -0
@@ -118,6 +118,21 @@ int __init init_eaccess(const char *filename)return error; } +int __init init_stat (const char *filename,struct kstat *stat,int flags) +{ +int lookup_flags = (flags &AT_SYMLINK_NOFOLLOW ) ?0 :LOOKUP_FOLLOW ; +struct path path; +int error; + + error =kern_path (filename, lookup_flags, &path); +if (error) +return error; + error =vfs_getattr (&path, stat,STATX_BASIC_STATS , + flags |AT_NO_AUTOMOUNT ); +path_put (&path); +return error; +} +int __init init_mknod (const char *filename,umode_t mode,unsigned int dev) {struct dentry *dentry;
include/linux/init_syscalls.h +1 -0
@@ -8,6 +8,7 @@ int __init init_chroot(const char *filename);int __init init_chown (const char *filename,uid_t user,gid_t group,int flags);int __init init_chmod (const char *filename,umode_t mode);int __init init_eaccess (const char *filename); +int __init init_stat (const char *filename,struct kstat *stat,int flags);int __init init_mknod (const char *filename,umode_t mode,unsigned int dev);int __init init_link (const char *oldname,const char *newname);int __init init_symlink (const char *oldname,const char *newname);
init/initramfs.c +2 -1
@@ -297,7 +297,8 @@ static void __init clean_path(char *path, umode_t fmode) {struct kstat st; -if (!vfs_lstat (path, &st) && (st.mode ^ fmode) &S_IFMT ) { +if (init_stat (path, &st,AT_SYMLINK_NOFOLLOW ) && + (st.mode ^ fmode) &S_IFMT ) {if (S_ISDIR (st.mode))init_rmdir (path);else
Signature · 1 line
2.27.0
PATCH 21/21 init: add an init_utimes helper
In reply to Christoph HellwigAdd a simple helper to set timestamps with a kernel space file name and switch the early init code over to it.
--- fs/for_init.c | 13 +++++++++++++ include/linux/init_syscalls.h | 1 + init/initramfs.c | 3 +-- 3 files changed, 15 insertions(+), 2 deletions(-)
fs/for_init.c +13 -0
@@ -234,3 +234,16 @@ int __init init_rmdir(const char *pathname) {return do_rmdir (AT_FDCWD ,getname_kernel (pathname)); } + +int __init init_utimes (char *filename,struct timespec64 *ts) +{ +struct path path; +int error; + + error =kern_path (filename,0 , &path); +if (error) +return error; + error =vfs_utimes (&path, ts); +path_put (&path); +return error; +}
include/linux/init_syscalls.h +1 -0
@@ -15,3 +15,4 @@ int __init init_symlink(const char *oldname, const char *newname);int __init init_unlink (const char *pathname);int __init init_mkdir (const char *pathname,umode_t mode);int __init init_rmdir (const char *pathname); +int __init init_utimes (char *filename,struct timespec64 *ts);
init/initramfs.c +1 -2
@@ -110,8 +110,7 @@ static long __init do_utime(char *filename, time64_t mtime) t[0 ].tv_nsec =0 ; t[1 ].tv_sec = mtime; t[1 ].tv_nsec =0 ; - -return do_utimes (AT_FDCWD , filename, t,AT_SYMLINK_NOFOLLOW ); +return init_utimes (filename, t); }static __initdata LIST_HEAD (dir_list);
Signature · 1 line
2.27.0
Quoted 10 lines · Christoph Hellwig
Hi Al and Linus,
currently a lot of the file system calls in the early in code (and the devtmpfs kthread) rely on the implicit
set_fs(KERNEL_DS)during boot. This is one of the few last remaining places we need to deal with to kill offset_fsentirely, so this series adds new helpers that take kernel pointers. These helpers are ininit/and marked__initand thus will be discarded after bootup. A few also need to be duplicated in devtmpfs, though unfortunately.
I see nothing objectionable here.
The only bikeshed comment I have is that I think the "for_init.c" name is ugly and pointless - I think you could just call it "fs/init.c" and it's both simpler and more straightforward. It _is_ init code, it's not "for" init.
Other than that it all looked straightforward to me.
Linus
Quoted 12 lines · Linus Torvalds
Quoted 10 lines · Christoph Hellwig
Hi Al and Linus,
currently a lot of the file system calls in the early in code (and the devtmpfs kthread) rely on the implicit
set_fs(KERNEL_DS)during boot. This is one of the few last remaining places we need to deal with to kill offset_fsentirely, so this series adds new helpers that take kernel pointers. These helpers are ininit/and marked__initand thus will be discarded after bootup. A few also need to be duplicated in devtmpfs, though unfortunately.
Quoted 6 lines
I see nothing objectionable here.
The only bikeshed comment I have is that I think the "
for_init.c" name is ugly and pointless - I think you could just call it "fs/init.c" and it's both simpler and more straightforward. It _is_ init code, it's not "for" init.
That was Al's suggestion. I personally don't care, so if between the two of you, you can come up with a preferred choice I'll switch to it.
Al Viro
maintainerQuoted 15 lines · Christoph Hellwig
Quoted 14 lines · Linus Torvalds
Quoted 10 lines · Christoph Hellwig
Hi Al and Linus,
currently a lot of the file system calls in the early in code (and the devtmpfs kthread) rely on the implicit
set_fs(KERNEL_DS)during boot. This is one of the few last remaining places we need to deal with to kill offset_fsentirely, so this series adds new helpers that take kernel pointers. These helpers are ininit/and marked__initand thus will be discarded after bootup. A few also need to be duplicated in devtmpfs, though unfortunately.I see nothing objectionable here.
Quoted 7 lines
Quoted 4 lines
The only bikeshed comment I have is that I think the "
for_init.c" name is ugly and pointless - I think you could just call it "fs/init.c" and it's both simpler and more straightforward. It _is_ init code, it's not "for" init.That was Al's suggestion. I personally don't care, so if between the two of you, you can come up with a preferred choice I'll switch to it.
I can live with either variant; the only problem with fs/init.c is that such name would imply the init code _of_ VFS, rather than VFS helpers for init.
Anyway, the series looks generally sane; if no other objections are raised, I'm adding it to vfs.git#for-next
Quoted 24 lines · Al Viro
Quoted 15 lines · Christoph Hellwig
Quoted 14 lines · Linus Torvalds
Quoted 10 lines · Christoph Hellwig
Hi Al and Linus,
currently a lot of the file system calls in the early in code (and the devtmpfs kthread) rely on the implicit
set_fs(KERNEL_DS)during boot. This is one of the few last remaining places we need to deal with to kill offset_fsentirely, so this series adds new helpers that take kernel pointers. These helpers are ininit/and marked__initand thus will be discarded after bootup. A few also need to be duplicated in devtmpfs, though unfortunately.I see nothing objectionable here.
Quoted 7 lines
Quoted 4 lines
The only bikeshed comment I have is that I think the "
for_init.c" name is ugly and pointless - I think you could just call it "fs/init.c" and it's both simpler and more straightforward. It _is_ init code, it's not "for" init.That was Al's suggestion. I personally don't care, so if between the two of you, you can come up with a preferred choice I'll switch to it.
Quoted 6 lines
I can live with either variant; the only problem with
fs/init.cis that such name would imply the init code _of_ VFS, rather than VFS helpers for init.Anyway, the series looks generally sane; if no other objections are raised, I'm adding it to vfs.git#for-next
Thanks!
Note that this is based on top of my init-user-pointers branch, so you'll need to pull that in as.
Btw, care to take a look at
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/kernel_readwrite
it has been in linux-next for 2 1/2 weeks, and the only interesting thing found was that btrfs didn't wire up iter_splice_write, which has already been fixed in mainline.
Quoted 7 lines · Christoph Hellwig
Btw, care to take a look at
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/kernel_readwrite
it has been in linux-next for 2 1/2 weeks, and the only interesting thing found was that btrfs didn't wire up
iter_splice_write, which has already been fixed in mainline.
Actually, the above is a stale old branch sorry. The real one that has been in linux-next is:
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/set_fs-rw
Al Viro
maintainerQuoted 5 lines · Christoph Hellwig
Quoted 4 lines · Christoph Hellwig
Btw, care to take a look at
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/kernel_readwrite
Quoted 8 lines
Quoted 3 lines
it has been in linux-next for 2 1/2 weeks, and the only interesting thing found was that btrfs didn't wire up
iter_splice_write, which has already been fixed in mainline.Actually, the above is a stale old branch sorry. The real one that has been in linux-next is:
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/set_fs-rw
Will check... still crawling through the accumulated VFS-related threads from the last weeks ;-/