introduce configfd as generalisation of fsconfig
Subsystems (18)
James Bottomley
maintainerv2 cover introduce configfd as generalisation of fsconfig
fsconfig is a very powerful configuration mechanism except that it only works for filesystems with superblocks. This patch series generalises the useful concept of a multiple step configurational mechanism carried by a file descriptor. The object of this patch series is to get bind mounts to be configurable in the same way that superblock based ones are, but it should have utility beyond the filesytem realm. Patch 4 also reimplements fsconfig in terms of configfd, but that's not a strictly necessary patch, it is merely a useful demonstration that configfd is a superset of the properties of fsconfig.
v1 of this patch series was originally sent as an rfc in reply to a thread about feature bugs with the new mount API:
https://lore.kernel.org/linux-fsdevel/[email protected]/
James
---
James Bottomley (6):
logger: add a limited buffer logging facility
configfd: add generic file descriptor based configuration parser
configfd: syscall: wire up configfd syscalls
fs: implement fsconfig via configfd
fs: expose internal interfaces open_detached_copy and
do_reconfigure_mount
fs: bind: add configfs type for bind mounts
arch/alpha/kernel/syscalls/syscall.tbl | 2 + arch/arm/tools/syscall.tbl | 2 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 4 + arch/ia64/kernel/syscalls/syscall.tbl | 2 + arch/m68k/kernel/syscalls/syscall.tbl | 2 + arch/microblaze/kernel/syscalls/syscall.tbl | 2 + arch/mips/kernel/syscalls/syscall_n32.tbl | 2 + arch/mips/kernel/syscalls/syscall_n64.tbl | 2 + arch/mips/kernel/syscalls/syscall_o32.tbl | 2 + arch/parisc/kernel/syscalls/syscall.tbl | 2 + arch/powerpc/kernel/syscalls/syscall.tbl | 2 + arch/s390/kernel/syscalls/syscall.tbl | 2 + arch/sh/kernel/syscalls/syscall.tbl | 2 + arch/sparc/kernel/syscalls/syscall.tbl | 2 + arch/x86/entry/syscalls/syscall_32.tbl | 2 + arch/x86/entry/syscalls/syscall_64.tbl | 2 + arch/xtensa/kernel/syscalls/syscall.tbl | 2 + fs/Makefile | 3 +- fs/bind.c | 232 ++++++++++++ fs/configfd.c | 450 +++++++++++++++++++++++ fs/filesystems.c | 8 +- fs/fs_context.c | 124 +------ fs/fsopen.c | 535 ++++++++++++++-------------- fs/internal.h | 7 + fs/namespace.c | 115 +++--- include/linux/configfd.h | 61 ++++ include/linux/fs.h | 2 + include/linux/fs_context.h | 29 +- include/linux/fs_parser.h | 2 + include/linux/logger.h | 34 ++ include/linux/syscalls.h | 5 + include/uapi/asm-generic/unistd.h | 7 +- include/uapi/linux/configfd.h | 20 ++ lib/Makefile | 3 +- lib/logger.c | 211 +++++++++++ 36 files changed, 1413 insertions(+), 473 deletions(-) create mode 100644 fs/bind.c create mode 100644 fs/configfd.c create mode 100644 include/linux/configfd.h create mode 100644 include/linux/logger.h create mode 100644 include/uapi/linux/configfd.h create mode 100644 lib/logger.c
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v2 1/6 logger: add a limited buffer logging facility
Can be used by anything that wants to add to a list of messages and then spit them back at a particular time. The current use case for this is the filesystem configuration descriptor, which can accumulate messages about config options which can then be read from the file descriptor later via a .read operation.
This code was based on fc_log originally written by David Howells in commit e7582e16a170db4c85995c1c03d194ea1ea621fc "vfs: Implement logging through fs_context".
--- include/linux/logger.h | 34 ++++++++ lib/Makefile | 3 +- lib/logger.c | 211 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 include/linux/logger.h create mode 100644 lib/logger.c
include/linux/logger.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef _LINUX_LOGGER_H +#define _LINUX_LOGGER_H + +#include <stdarg.h> + +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/refcount.h> +#include <linux/types.h> + +struct logger { +refcount_t usage; +struct mutex mutex; +u8 head;/* Insertion index in buffer[] */ +u8 tail;/* Removal index in buffer[] */ +u8 need_free;/* Mask of kfree'able items in buffer[] */ +struct module *owner;/* Owner module for strings that don't then need freeing */ +const char *buffer[8 ]; +}; + +extern __printf(2, 3) +void logger_log(struct logger *, const char *fmt, ...); +extern __printf(2, 0) +void logger_valog(struct logger *, const char *fmt, va_list va); +ssize_t logger_read(struct logger *log, char __user *_buf, size_t len); +struct logger *logger_alloc(struct module *owner); +void logger_put(struct logger **logp); +void logger_get(struct logger *log); + +#define logger_err(log, fmt, ...) ({ logger_log(log, "e "fmt, ## __VA_ARGS__); }) +#define logger_warn(log, fmt, ...) ({ logger_log(log, "w "fmt, ## __VA_ARGS__); }) +#define logger_info(log, fmt, ...) ({ logger_log(log, "i "fmt, ## __VA_ARGS__); }) + +#endif
lib/Makefile +2 -1
@@ -30,7 +30,8 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ flex_proportions.o ratelimit.o show_mem.o \ is_single_threaded.o plist.o decompress.o kobject_uevent.o \ earlycpio.o seq_buf.o siphash.o dec_and_lock.o \ - nmi_backtrace.o nodemask.o win_minmax.o memcat_p.o + nmi_backtrace.o nodemask.o win_minmax.o memcat_p.o \ + logger.o lib-$(CONFIG_PRINTK) += dump_stack.o lib-$(CONFIG_MMU) += ioremap.o
lib/logger.c new file +211 -0
211 lines not on this page · raw message
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v2 2/6 configfd: add generic file descriptor based configuration parser
In reply to James BottomleyThis code is based on the original filesystem context based configuration parser by David Howells, but lifted up so it can apply to anything rather than only filesystem contexts.
--- fs/Makefile | 3 +- fs/configfd.c | 450 ++++++++++++++++++++++++++++++++++++++++++ include/linux/configfd.h | 61 ++++++ include/uapi/linux/configfd.h | 20 ++ 4 files changed, 533 insertions(+), 1 deletion(-) create mode 100644 fs/configfd.c create mode 100644 include/linux/configfd.h create mode 100644 include/uapi/linux/configfd.h
fs/Makefile +2 -1
@@ -13,7 +13,8 @@ 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 \ + configfd.o ifeq ($(CONFIG_BLOCK),y) obj-y += buffer.o block_dev.o direct-io.o mpage.o
fs/configfd.c new file +450 -0
450 lines not on this page · raw message
include/linux/configfd.h new file +61 -0
61 lines not on this page · raw message
include/uapi/linux/configfd.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */ + +#ifndef _UAPI_LINUX_CONFIGFD_H +#define _UAPI_LINUX_CONFIGFD_H + +enum configfd_cmd { +CONFIGFD_SET_FLAG =0 , +CONFIGFD_SET_STRING =1 , +CONFIGFD_SET_BINARY =2 , +CONFIGFD_SET_PATH =3 , +CONFIGFD_SET_PATH_EMPTY =4 , +CONFIGFD_SET_FD =5 , +CONFIGFD_CMD_CREATE =6 , +CONFIGFD_CMD_RECONFIGURE =7 , +/* gap for 30 other commands */ +CONFIGFD_SET_INT =38 , +CONFIGFD_GET_FD =39 , +}; + +#endif
Signature · 1 line
2.16.4
kbuild test robot
build botRe: [PATCH v2 2/6] configfd: add generic file descriptor based configuration parser
I love your patch! Perhaps something to improve:
Hi James,
I love your patch! Perhaps something to improve:
[auto build test WARNING on s390/features]
[also build test WARNING on linus/master v5.5-rc4 next-20191220]
[cannot apply to arm64/for-next/core tip/x86/asm arm/for-next ia64/next m68k/for-next hp-parisc/for-next powerpc/next sparc-next/master] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/James-Bottomley/introduce-configfd-as-generalisation-of-fsconfig/20200105-080415 base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features reproduce: # apt-get install sparse # sparse version: v0.6.1-129-g341daf20-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> fs/configfd.c:53:30: sparse: sparse: symbol 'configfd_context_fops' was not declared. Should it be static? >> fs/configfd.c:96:25: sparse: sparse: symbol 'configfd_context_alloc' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
kbuild test robot
build bot[RFC PATCH] configfd: configfd_context_fops can be static
In reply to James BottomleyFixes: 74148c8fa2fc ("configfd: add generic file descriptor based configuration parser")
--- configfd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/configfd.c +3 -3
@@ -50,7 +50,7 @@ static int configfd_release(struct inode *inode, struct file *file)return 0 ; } -const struct file_operations configfd_context_fops = { +static const struct file_operations configfd_context_fops = { .read = configfd_read, .release = configfd_release, .llseek = no_llseek,
@@ -93,8 +93,8 @@ static struct configfd_type *configfd_type_get(const char *name)return cft; } -struct configfd_context *configfd_context_alloc (const struct configfd_type *cft, -unsigned int op) +static struct configfd_context *configfd_context_alloc (const struct configfd_type *cft, +unsigned int op) {struct configfd_context *cfc;struct logger *log;
James Bottomley
maintainerPATCH v2 3/6 configfd: syscall: wire up configfd syscalls
In reply to James Bottomley--- arch/alpha/kernel/syscalls/syscall.tbl | 2 ++ arch/arm/tools/syscall.tbl | 2 ++ arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 4 ++++ arch/ia64/kernel/syscalls/syscall.tbl | 2 ++ arch/m68k/kernel/syscalls/syscall.tbl | 2 ++ arch/microblaze/kernel/syscalls/syscall.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_n32.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_n64.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_o32.tbl | 2 ++ arch/parisc/kernel/syscalls/syscall.tbl | 2 ++ arch/powerpc/kernel/syscalls/syscall.tbl | 2 ++ arch/s390/kernel/syscalls/syscall.tbl | 2 ++ arch/sh/kernel/syscalls/syscall.tbl | 2 ++ arch/sparc/kernel/syscalls/syscall.tbl | 2 ++ arch/x86/entry/syscalls/syscall_32.tbl | 2 ++ arch/x86/entry/syscalls/syscall_64.tbl | 2 ++ arch/xtensa/kernel/syscalls/syscall.tbl | 2 ++ include/linux/syscalls.h | 5 +++++ include/uapi/asm-generic/unistd.h | 7 ++++++- 20 files changed, 48 insertions(+), 2 deletions(-)
arch/alpha/kernel/syscalls/syscall.tbl +2 -0
@@ -475,3 +475,5 @@ 543 common fspick sys_fspick 544 common pidfd_open sys_pidfd_open # 545 reserved for clone3 +546 common configfd_open configfd_open +547 common configfd_action configfd_action
arch/arm/tools/syscall.tbl +2 -0
@@ -449,3 +449,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 435 common clone3 sys_clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/arm64/include/asm/unistd.h +1 -1
@@ -38,7 +38,7 @@#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800) -#define __NR_compat_syscalls 436 +#define __NR_compat_syscalls 438#endif #define __ARCH_WANT_SYS_CLONE
arch/arm64/include/asm/unistd32.h +4 -0
@@ -879,6 +879,10 @@ __SYSCALL(__NR_fspick, sys_fspick) __SYSCALL(__NR_pidfd_open, sys_pidfd_open)#define __NR_clone3 435 __SYSCALL(__NR_clone3, sys_clone3) +#define __NR_configfd_open 436 +__SYSCALL(__NR_configfd_open, sys_configfd_open) +#define __NR_configfd_action 437 +__SYSCALL (__NR_configfd_action, sys_configfd_action)/* * Please add new compat syscalls above this comment and update
arch/ia64/kernel/syscalls/syscall.tbl +2 -0
@@ -356,3 +356,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open # 435 reserved for clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/m68k/kernel/syscalls/syscall.tbl +2 -0
@@ -435,3 +435,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open # 435 reserved for clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/microblaze/kernel/syscalls/syscall.tbl +2 -0
@@ -441,3 +441,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 435 common clone3 sys_clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/mips/kernel/syscalls/syscall_n32.tbl +2 -0
@@ -374,3 +374,5 @@ 433 n32 fspick sys_fspick 434 n32 pidfd_open sys_pidfd_open 435 n32 clone3 __sys_clone3 +436 n32 configfd_open sys_configfd_open +437 n32 configfd_action sys_configfd_action
arch/mips/kernel/syscalls/syscall_n64.tbl +2 -0
@@ -350,3 +350,5 @@ 433 n64 fspick sys_fspick 434 n64 pidfd_open sys_pidfd_open 435 n64 clone3 __sys_clone3 +436 n64 configfd_open sys_configfd_open +437 n64 configfd_action sys_configfd_action
arch/mips/kernel/syscalls/syscall_o32.tbl +2 -0
@@ -423,3 +423,5 @@ 433 o32 fspick sys_fspick 434 o32 pidfd_open sys_pidfd_open 435 o32 clone3 __sys_clone3 +436 o32 configfd_open sys_configfd_open +437 o32 configfd_action sys_configfd_action
arch/parisc/kernel/syscalls/syscall.tbl +2 -0
@@ -433,3 +433,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 435 common clone3 sys_clone3_wrapper +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/powerpc/kernel/syscalls/syscall.tbl +2 -0
@@ -517,3 +517,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 435 nospu clone3 ppc_clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/s390/kernel/syscalls/syscall.tbl +2 -0
@@ -438,3 +438,5 @@ 433 common fspick sys_fspick sys_fspick 434 common pidfd_open sys_pidfd_open sys_pidfd_open 435 common clone3 sys_clone3 sys_clone3 +436 common configfd_open sys_configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action sys_configfd_action
arch/sh/kernel/syscalls/syscall.tbl +2 -0
@@ -438,3 +438,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open # 435 reserved for clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/sparc/kernel/syscalls/syscall.tbl +2 -0
@@ -481,3 +481,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open # 435 reserved for clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
arch/x86/entry/syscalls/syscall_32.tbl +2 -0
@@ -440,3 +440,5 @@ 433 i386 fspick sys_fspick __ia32_sys_fspick 434 i386 pidfd_open sys_pidfd_open __ia32_sys_pidfd_open 435 i386 clone3 sys_clone3 __ia32_sys_clone3 +436 i386 configfd_open sys_configfd_open __ia32_sys_configfd_open +437 i386 configfd_action sys_configfd_action __ia32_sys_configfd_action
arch/x86/entry/syscalls/syscall_64.tbl +2 -0
@@ -357,6 +357,8 @@ 433 common fspick __x64_sys_fspick 434 common pidfd_open __x64_sys_pidfd_open 435 common clone3 __x64_sys_clone3/ptregs +436 common configfd_open __x64_sys_configfd_open +437 common configfd_action __x64_sys_configfd_action # # x32-specific system call numbers start at 512 to avoid cache impact
arch/xtensa/kernel/syscalls/syscall.tbl +2 -0
@@ -406,3 +406,5 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 435 common clone3 sys_clone3 +436 common configfd_open sys_configfd_open +437 common configfd_action sys_configfd_action
include/linux/syscalls.h +5 -0
@@ -1000,6 +1000,11 @@ asmlinkage long sys_fspick(int dfd, const char __user *path, unsigned int flags)asmlinkage long sys_pidfd_send_signal (int pidfd,int sig,siginfo_t __user *info,unsigned int flags); +asmlinkage long sys_configfd_open (const char __user *config_name, +unsigned int flags,unsigned int op); +asmlinkage long sys_configfd_action (int fd,unsigned int cmd, +const char __user *key,void __user *value, +int aux);/* * Architecture-specific system calls
include/uapi/asm-generic/unistd.h +6 -1
@@ -849,10 +849,15 @@ __SYSCALL(__NR_pidfd_open, sys_pidfd_open)#ifdef __ARCH_WANT_SYS_CLONE3#define __NR_clone3 435 __SYSCALL(__NR_clone3, sys_clone3) +#endif +#define __NR_configfd_open 436 +__SYSCALL(__NR_configfd_open, sys_configfd_open) +#define __NR_configfd_action 437 +__SYSCALL(__NR_configfd_action, sys_configfd_action)#undef __NR_syscalls -#define __NR_syscalls 436 +#define __NR_syscalls 438/* * 32 bit systems traditionally used different
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v2 4/6 fs: implement fsconfig via configfd
In reply to James BottomleyThis changes the internal implementation of fsconfig, while keeping all the external system calls. However, it now becomes possible to all the same operations via configfd instead of fsconfig.
For example a filesystem remount read-only can be done:
fd = configfd_open("mount", O_CLOEXEC, CONFIGFD_CMD_RECONFIGURE); mntpnt = open("/path/to/mount", O_PATH); configfd_action(fd, CONFIGFD_SET_FD, "pathfd", NULL, mntpnt); configfd_action(fd, CONFIGFD_SET_FLAG, "ro", NULL, 0); configfd_action(fd, CONFIGFD_CMD_RECONFIGURE, NULL, NULL, 0);
And mounting a tmpfs filesystem nodev,noexec:
fd = configfd_open("tmpfs", O_CLOEXEC, CONFIGFD_CMD_CREATE); configfd_action(fd, CONFIGFD_SET_INT, "mount_attrs", NULL,
MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC);
configfd_action(fd, CONFIGFD_CMD_CREATE, NULL, NULL, 0); configfd_action(fd, CONFIGFD_GET_FD, "mountfd", &mfd, O_CLOEXEC); mount_move("", mfd, AT_FDCWD, "/mountpoint", MOVE_MOUNT_F_EMPTY_PATH);
---
v2: fix a log oops
--- fs/filesystems.c | 8 +- fs/fs_context.c | 124 ++--------- fs/fsopen.c | 535 ++++++++++++++++++++++----------------------- fs/internal.h | 4 + fs/namespace.c | 111 ++++------ include/linux/fs.h | 2 + include/linux/fs_context.h | 29 +-- include/linux/fs_parser.h | 2 + 8 files changed, 348 insertions(+), 467 deletions(-)
fs/filesystems.c +6 -2
@@ -7,6 +7,7 @@* table of configured filesystems */ +#include <linux/configfd.h> #include <linux/syscalls.h> #include <linux/fs.h> #include <linux/proc_fs.h>
@@ -82,10 +83,12 @@ int register_filesystem(struct file_system_type * fs)return -EBUSY ;write_lock (&file_systems_lock); p =find_filesystem (fs->name,strlen (fs->name)); -if (*p) +if (*p) { res = -EBUSY ; -else + }else { *p = fs; + res =fs_context_register (fs); + }write_unlock (&file_systems_lock);return res; }
@@ -114,6 +117,7 @@ int unregister_filesystem(struct file_system_type * fs)if (fs == *tmp) { *tmp = fs->next; fs->next =NULL ; +fs_context_unregister (fs);write_unlock (&file_systems_lock);synchronize_rcu ();return 0 ;
fs/fs_context.c +15 -109
160 lines not on this page · raw message
fs/fsopen.c +261 -274
610 lines not on this page · raw message
fs/internal.h +4 -0
@@ -91,6 +91,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 fsopen_cf_get (const struct configfd_context *cfc, +struct configfd_param *p); +/* * fs_struct.c */
fs/namespace.c +47 -64
160 lines not on this page · raw message
include/linux/fs.h +2 -0
@@ -2,6 +2,7 @@#ifndef _LINUX_FS_H#define _LINUX_FS_H +#include <linux/configfd.h> #include <linux/linkage.h> #include <linux/wait_bit.h> #include <linux/kdev_t.h>
@@ -2240,6 +2241,7 @@ struct file_system_type {struct lock_class_key i_lock_key;struct lock_class_key i_mutex_key;struct lock_class_key i_mutex_dir_key; +struct configfd_type cft; };#define MODULE_ALIAS_FS (NAME ) MODULE_ALIAS("fs-" NAME)
include/linux/fs_context.h +11 -18
@@ -97,10 +97,12 @@ struct fs_context {const char *source;/* The source name (eg. dev path) */ void *security;/* Linux S&M options */ void *s_fs_info;/* Proposed s_fs_info */ +struct configfd_context *cfc;unsigned int sb_flags;/* Proposed superblock flags (SB_*) */ unsigned int sb_flags_mask;/* Superblock flags that were changed */ unsigned int s_iflags;/* OR'd with sb->s_iflags */ unsigned int lsm_flags;/* Information flags from the fs to the LSM */ +unsigned int mnt_flags;/* mnt flags translated from MOUNT_ATTRS */ enum fs_context_purpose purpose:8; enum fs_context_phase phase:8; /* The phase the context is in */ bool need_free:1; /* Need to call ops->free() */
@@ -134,6 +136,8 @@ extern int vfs_parse_fs_string(struct fs_context *fc, const char *key,extern int generic_parse_monolithic (struct fs_context *fc,void *data);extern int vfs_get_tree (struct fs_context *fc);extern void put_fs_context (struct fs_context *fc); +extern void fs_context_set_reconfigure (struct fs_context *fc, +struct dentry *reference);/* * sget() wrappers to be called from the ->get_tree() op.
@@ -166,24 +170,13 @@ extern int get_tree_keyed(struct fs_context *fc,extern int get_tree_bdev (struct fs_context *fc,int (*fill_super)(struct super_block *sb,struct fs_context *fc)); - -extern const struct file_operations fscontext_fops; - -/* -* Mount error, warning and informational message logging. This structure is -* shareable between a mount and a subordinate mount. -*/ -struct fc_log { -refcount_t usage; -u8 head;/* Insertion index in buffer[] */ -u8 tail;/* Removal index in buffer[] */ -u8 need_free;/* Mask of kfree'able items in buffer[] */ -struct module *owner;/* Owner module for strings that don't then need freeing */ -char *buffer[8 ]; -}; - -extern __attribute__((format (printf,2 ,3 ))) -void logfc (struct fs_context *fc,const char *fmt, ...); +#define logfc (fc, fmt, ...) ({ \ + struct fs_context *fsc = (fc); \ + struct logger *log = NULL; \ + if (fsc) \ + log = fsc->cfc->log; \ + logger_log(log, fmt, ## __VA_ARGS__); \ +})/** * infof - Store supplementary informational message
include/linux/fs_parser.h +2 -0
@@ -143,5 +143,7 @@ static inline bool fs_validate_description(const struct fs_parameter_description#define fsparam_path (NAME ,OPT ) __fsparam(fs_param_is_path, NAME, OPT, 0)#define fsparam_fd (NAME ,OPT ) __fsparam(fs_param_is_fd, NAME, OPT, 0) +int fs_context_register (struct file_system_type *fs); +void fs_context_unregister (struct file_system_type *fs);#endif /* _LINUX_FS_PARSER_H */
Signature · 1 line
2.16.4
kbuild test robot
build botRe: [PATCH v2 4/6] fs: implement fsconfig via configfd
I love your patch! Yet something to improve:
Hi James,
I love your patch! Yet something to improve:
[auto build test ERROR on s390/features]
[also build test ERROR on linus/master v5.5-rc4]
[cannot apply to arm64/for-next/core tip/x86/asm arm/for-next ia64/next m68k/for-next hp-parisc/for-next powerpc/next sparc-next/master next-20191220] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/James-Bottomley/introduce-configfd-as-generalisation-of-fsconfig/20200105-080415 base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features config: i386-tinyconfig (attached as .config) compiler: gcc-7 (Debian 7.5.0-3) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=i386
If you fix the issue, kindly add following tag
All error/warnings (new ones prefixed by >>):
In file included from fs/fsopen.c:13:0:
>> include/linux/syscalls.h:239:18: error: conflicting types for 'sys_fsconfig'
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
^
include/linux/syscalls.h:225:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:218:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
>> fs/fsopen.c:412:1: note: in expansion of macro 'SYSCALL_DEFINE5'
SYSCALL_DEFINE5(fsconfig,
^~~~~~~~~~~~~~~ In file included from fs/fsopen.c:13:0:
include/linux/syscalls.h:996:17: note: previous declaration of 'sys_fsconfig' was here
asmlinkage long sys_fsconfig(int fs_fd, unsigned int cmd, const char __user *key,
^~~~~~~~~~~~
vim +/sys_fsconfig +239 include/linux/syscalls.h
1bd21c6c21e848 Dominik Brodowski 2018-04-05 228
e145242ea0df6b Dominik Brodowski 2018-04-09 229 /*
e145242ea0df6b Dominik Brodowski 2018-04-09 230 * The asmlinkage stub is aliased to a function named __se_sys_*() which
e145242ea0df6b Dominik Brodowski 2018-04-09 231 * sign-extends 32-bit ints to longs whenever needed. The actual work is
e145242ea0df6b Dominik Brodowski 2018-04-09 232 * done within __do_sys_*().
e145242ea0df6b Dominik Brodowski 2018-04-09 233 */
1bd21c6c21e848 Dominik Brodowski 2018-04-05 234 #ifndef __SYSCALL_DEFINEx
bed1ffca022cc8 Frederic Weisbecker 2009-03-13 235 #define __SYSCALL_DEFINEx(x, name, ...) \
bee20031772af3 Arnd Bergmann 2018-06-19 236 __diag_push(); \
bee20031772af3 Arnd Bergmann 2018-06-19 237 __diag_ignore(GCC, 8, "-Wattribute-alias", \
bee20031772af3 Arnd Bergmann 2018-06-19 238 "Type aliasing is used to sanitize syscall arguments");\
83460ec8dcac14 Andi Kleen 2013-11-12 @239 asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
e145242ea0df6b Dominik Brodowski 2018-04-09 240 __attribute__((alias(__stringify(__se_sys##name)))); \
c9a211951c7c79 Howard McLauchlan 2018-03-21 241 ALLOW_ERROR_INJECTION(sys##name, ERRNO); \
e145242ea0df6b Dominik Brodowski 2018-04-09 242 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
e145242ea0df6b Dominik Brodowski 2018-04-09 243 asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
e145242ea0df6b Dominik Brodowski 2018-04-09 244 asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
1a94bc34768e46 Heiko Carstens 2009-01-14 245 { \
e145242ea0df6b Dominik Brodowski 2018-04-09 246 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
07fe6e00f6cca6 Al Viro 2013-01-21 247 __MAP(x,__SC_TEST,__VA_ARGS__); \
2cf0966683430b Al Viro 2013-01-21 248 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
2cf0966683430b Al Viro 2013-01-21 249 return ret; \
1a94bc34768e46 Heiko Carstens 2009-01-14 250 } \
bee20031772af3 Arnd Bergmann 2018-06-19 251 __diag_pop(); \
e145242ea0df6b Dominik Brodowski 2018-04-09 252 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
1bd21c6c21e848 Dominik Brodowski 2018-04-05 253 #endif /* __SYSCALL_DEFINEx */
1a94bc34768e46 Heiko Carstens 2009-01-14 254 :::::: The code at line 239 was first introduced by commit
:::::: 83460ec8dcac14142e7860a01fa59c267ac4657c syscalls.h: use gcc alias instead of assembler aliases for syscalls
:::::: TO: Andi Kleen <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
kbuild test robot
build botRe: [PATCH v2 4/6] fs: implement fsconfig via configfd
In reply to James BottomleyI love your patch! Yet something to improve:
Hi James,
I love your patch! Yet something to improve:
[auto build test ERROR on s390/features]
[also build test ERROR on linus/master v5.5-rc4]
[cannot apply to arm64/for-next/core tip/x86/asm arm/for-next ia64/next m68k/for-next hp-parisc/for-next powerpc/next sparc-next/master next-20191220] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/James-Bottomley/introduce-configfd-as-generalisation-of-fsconfig/20200105-080415 base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features config: mips-64r6el_defconfig (attached as .config) compiler: mips64el-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=mips
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from include/linux/module.h:30:0,
from include/linux/logger.h:6,
from include/linux/configfd.h:6,
from include/linux/fs.h:5,
from arch/mips/include/asm/elf.h:12,
from include/linux/elf.h:5,
from arch/mips/kernel/elf.c:8:
arch/mips/include/asm/module.h:20:2: error: unknown type name 'Elf64_Addr'
Elf64_Addr r_offset; /* Address of relocation. */
^~~~~~~~~~
arch/mips/include/asm/module.h:21:2: error: unknown type name 'Elf64_Word'
Elf64_Word r_sym; /* Symbol index. */
^~~~~~~~~~
arch/mips/include/asm/module.h:29:2: error: unknown type name 'Elf64_Addr'
Elf64_Addr r_offset; /* Address of relocation. */
^~~~~~~~~~
arch/mips/include/asm/module.h:30:2: error: unknown type name 'Elf64_Word'
Elf64_Word r_sym; /* Symbol index. */
^~~~~~~~~~
arch/mips/include/asm/module.h:35:2: error: unknown type name 'Elf64_Sxword'
Elf64_Sxword r_addend; /* Addend. */
^~~~~~~~~~~~
>> arch/mips/include/asm/module.h:58:18: error: unknown type name 'Elf64_Sym'
#define Elf_Sym Elf64_Sym
^
include/linux/module.h:335:2: note: in expansion of macro 'Elf_Sym'
Elf_Sym *symtab;
^~~~~~~
>> arch/mips/include/asm/module.h:58:18: error: unknown type name 'Elf64_Sym'
#define Elf_Sym Elf64_Sym
^
include/linux/module.h:519:57: note: in expansion of macro 'Elf_Sym'
static inline unsigned long kallsyms_symbol_value(const Elf_Sym *sym)
^~~~~~~
In file included from include/linux/logger.h:6:0,
from include/linux/configfd.h:6,
from include/linux/fs.h:5,
from arch/mips/include/asm/elf.h:12,
from include/linux/elf.h:5,
from arch/mips/kernel/elf.c:8:
include/linux/module.h: In function 'kallsyms_symbol_value':
include/linux/module.h:521:12: error: request for member 'st_value' in something not a structure or union
return sym->st_value;
^~
In file included from include/linux/module.h:30:0,
from include/linux/logger.h:6,
from include/linux/configfd.h:6,
from include/linux/fs.h:5,
from arch/mips/include/asm/elf.h:12,
from include/linux/elf.h:5,
from arch/mips/kernel/elf.c:8:
include/linux/module.h: At top level:
>> arch/mips/include/asm/module.h:59:18: error: unknown type name 'Elf64_Ehdr'
#define Elf_Ehdr Elf64_Ehdr
^
include/linux/module.h:870:46: note: in expansion of macro 'Elf_Ehdr'
static inline void module_bug_finalize(const Elf_Ehdr *hdr,
^~~~~~~~
>> arch/mips/include/asm/module.h:57:18: error: unknown type name 'Elf64_Shdr'
#define Elf_Shdr Elf64_Shdr
^ include/linux/module.h:871:12: note: in expansion of macro 'Elf_Shdr'
const Elf_Shdr *sechdrs,
^~~~~~~~
vim +/Elf64_Sym +58 arch/mips/include/asm/module.h
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 27
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 28 typedef struct {
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 @29 Elf64_Addr r_offset; /* Address of relocation. */
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 30 Elf64_Word r_sym; /* Symbol index. */
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 31 Elf64_Byte r_ssym; /* Special symbol. */
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 32 Elf64_Byte r_type3; /* Third relocation. */
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 33 Elf64_Byte r_type2; /* Second relocation. */
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 34 Elf64_Byte r_type; /* First relocation. */
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 35 Elf64_Sxword r_addend; /* Addend. */
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 36 } Elf64_Mips_Rela;
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 37
875d43e72b5bf2 include/asm-mips/module.h Ralf Baechle 2005-09-03 38 #ifdef CONFIG_32BIT
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 39 #define Elf_Shdr Elf32_Shdr
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 40 #define Elf_Sym Elf32_Sym
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 41 #define Elf_Ehdr Elf32_Ehdr
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 42 #define Elf_Addr Elf32_Addr
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 43 #define Elf_Rel Elf32_Rel
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 44 #define Elf_Rela Elf32_Rela
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 45 #define ELF_R_TYPE(X) ELF32_R_TYPE(X)
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 46 #define ELF_R_SYM(X) ELF32_R_SYM(X)
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 47
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 48 #define Elf_Mips_Rel Elf32_Rel
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 49 #define Elf_Mips_Rela Elf32_Rela
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 50
430d0b88943aff arch/mips/include/asm/module.h Paul Burton 2017-03-30 51 #define ELF_MIPS_R_SYM(rel) ELF32_R_SYM((rel).r_info)
430d0b88943aff arch/mips/include/asm/module.h Paul Burton 2017-03-30 52 #define ELF_MIPS_R_TYPE(rel) ELF32_R_TYPE((rel).r_info)
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 53
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 54 #endif
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 55
875d43e72b5bf2 include/asm-mips/module.h Ralf Baechle 2005-09-03 56 #ifdef CONFIG_64BIT
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 @57 #define Elf_Shdr Elf64_Shdr
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 @58 #define Elf_Sym Elf64_Sym
^1da177e4c3f41 include/asm-mips/module.h Linus Torvalds 2005-04-16 @59 #define Elf_Ehdr Elf64_Ehdr
4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 60 #define Elf_Addr Elf64_Addr
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 61 #define Elf_Rel Elf64_Rel
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 62 #define Elf_Rela Elf64_Rela
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 63 #define ELF_R_TYPE(X) ELF64_R_TYPE(X)
786d35d45cc40b arch/mips/include/asm/module.h David Howells 2012-09-28 64 #define ELF_R_SYM(X) ELF64_R_SYM(X)4e6a05fe5f87ef include/asm-mips/module.h Thiemo Seufer 2005-02-21 65
:::::: The code at line 58 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
kbuild test robot
build botRe: [PATCH v2 4/6] fs: implement fsconfig via configfd
In reply to James BottomleyI love your patch! Perhaps something to improve:
Hi James,
I love your patch! Perhaps something to improve:
[auto build test WARNING on s390/features]
[also build test WARNING on linus/master v5.5-rc5]
[cannot apply to arm64/for-next/core tip/x86/asm arm/for-next ia64/next m68k/for-next hp-parisc/for-next powerpc/next sparc-next/master next-20200110] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/James-Bottomley/introduce-configfd-as-generalisation-of-fsconfig/20200105-080415 base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features reproduce: # apt-get install sparse # sparse version: v0.6.1-129-g341daf20-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> fs/fsopen.c:116:31: sparse: sparse: incorrect type in argument 1 (different address spaces) >> fs/fsopen.c:116:31: sparse: expected char const * >> fs/fsopen.c:116:31: sparse: got char const [noderef] <asn:1> *path
vim +116 fs/fsopen.c
78
79 /*
80 * Pick a superblock into a context for reconfiguration.
81 */
82 SYSCALL_DEFINE3(fspick, int, dfd, const char __user *, path, unsigned int, flags)
83 {
84 struct path *target;
85 unsigned int lookup_flags;
86 int ret;
87 int fd;
88 struct configfd_param cp;
89 struct open_flags of;
90 struct filename *name;
91 struct file *file;
92
93 if (!ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN))
94 return -EPERM;
95
96 if ((flags & ~(FSPICK_CLOEXEC |
97 FSPICK_SYMLINK_NOFOLLOW |
98 FSPICK_NO_AUTOMOUNT |
99 FSPICK_EMPTY_PATH)) != 0)
100 return -EINVAL;
101
102 lookup_flags = LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT;
103 if (flags & FSPICK_SYMLINK_NOFOLLOW)
104 lookup_flags &= ~LOOKUP_FOLLOW;
105 if (flags & FSPICK_NO_AUTOMOUNT)
106 lookup_flags &= ~LOOKUP_AUTOMOUNT;
107 if (flags & FSPICK_EMPTY_PATH)
108 lookup_flags |= LOOKUP_EMPTY;
109
110 of.lookup_flags = lookup_flags;
111 of.intent = LOOKUP_OPEN;
112 of.acc_mode = 0;
113 of.mode = 0;
114 of.open_flag = O_PATH;
115
> 116 name = getname_kernel(path); 117 if (IS_ERR(name))
118 return PTR_ERR(name);
119
120 file = do_filp_open(dfd, name, &of);
121 putname(name);
122 if (IS_ERR(file))
123 return PTR_ERR(file);
124
125 target = &file->f_path;
126 ret = -EINVAL;
127 if (target->mnt->mnt_root != target->dentry)
128 goto err_file;
129
130 ret = fd = kern_configfd_open("mount",
131 flags & FSPICK_CLOEXEC ? O_CLOEXEC : 0,
132 CONFIGFD_CMD_RECONFIGURE);
133 if (ret < 0)
134 goto err_file;
135 cp = (struct configfd_param) {
136 .key = "pathfd",
137 .file = file,
138 .cmd = CONFIGFD_SET_FD,
139 };
140 ret = kern_configfd_action(fd, &cp);
141 /* file gets NULL'd if successfully installed otherwise we put */
142 if (cp.file)
143 fput(file);
144 if (ret < 0)
145 goto err_close;
146 return fd;
147
148 err_close:
149 ksys_close(fd);
150 err_file:
151 fput(file);
152 return ret;
153 }
154
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
James Bottomley
maintainerPATCH v2 5/6 fs: expose internal interfaces open_detached_copy and do_reconfigure_mount
In reply to James BottomleyThese are needed for the forthcoming bind configure type to work.
--- fs/internal.h | 3 +++ fs/namespace.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/internal.h +3 -0
@@ -95,6 +95,9 @@ extern void dissolve_on_fput(struct vfsmount *);int fsopen_cf_get (const struct configfd_context *cfc,struct configfd_param *p); +extern int do_reconfigure_mnt (struct path *path,unsigned int mnt_flags); +extern struct file *open_detached_copy (struct path *path,bool recursive); +/* * fs_struct.c */
fs/namespace.c +2 -2
@@ -2318,7 +2318,7 @@ static int do_loopback(struct path *path, const char *old_name,return err; } -static struct file *open_detached_copy (struct path *path,bool recursive) +struct file *open_detached_copy (struct path *path,bool recursive) {struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns;struct mnt_namespace *ns =alloc_mnt_ns (user_ns, true);
@@ -2494,7 +2494,7 @@ static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount ** superblock it refers to. This is triggered by specifying MS_REMOUNT|MS_BIND * to mount(2). */ -static int do_reconfigure_mnt (struct path *path,unsigned int mnt_flags) +int do_reconfigure_mnt (struct path *path,unsigned int mnt_flags) {struct super_block *sb = path->mnt->mnt_sb;struct mount *mnt =real_mount (path->mnt);
Signature · 1 line
2.16.4
James Bottomley
maintainerPATCH v2 6/6 fs: bind: add configfs type for bind mounts
In reply to James BottomleyThis can do the equivalent of open_tree and also do bind mount reconfiguration from ro to rw and vice versa.
To get the equvalent of open tree you need to do
mnt = open("/path/to/tree", O_PATH);
fd = configfs_open(bind, O_CLOEXEC);
configfs_action(fd, CONFIGFD_SET_FD, "pathfd", NULL, mnt);
configfs_action(fd, CONFIGFD_SET_FLAG, "detached", NULL, 0);
configfs_action(fd, CONFIGFD_SET_FLAG, "recursive", NULL, 0);
configfs_action(fd, CONFIGFD_CMD_CREATE, NULL, NULL, 0);
configfs_action(fd, CONFIGFD_GET_FD, "bindfd", &bfd, NULL, O_CLOEXEC);And bfd will now contain the file descriptor to pass to move_tree. There is a deficiency over the original implementation in that the open system call has no way of clearing the LOOKUP_AUTOMOUNT path, but that's fixable.
To do a mount reconfigure to change the bind mount to readonly do
mnt = open("/path/to/tree", O_PATH);
fd = configfs_open(bind, O_CLOEXEC);
configfs_action(fd, CONFIGFD_SET_FD, "pathfd", NULL, mnt);
configfs_action(fd, CONFIGFD_SET_FLAG, "ro", NULL, 0);
configfs_action(fd, CONFIGFD_CMD_RECONFIGURE, NULL, NULL, 0);And the bind properties will be changed. You can also pass the "rw" flag to reset the read only.
---
v2: add nodev and noexec mount reconfigurations
--- fs/Makefile | 2 +- fs/bind.c | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 fs/bind.c
fs/Makefile +1 -1
@@ -14,7 +14,7 @@ obj-y := open.o read_write.o file_table.o super.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 \ - configfd.o + configfd.o bind.o ifeq ($(CONFIG_BLOCK),y) obj-y += buffer.o block_dev.o direct-io.o mpage.o
fs/bind.c new file +232 -0
232 lines not on this page · raw message
Signature · 1 line
2.16.4
kbuild test robot
build botRe: [PATCH v2 6/6] fs: bind: add configfs type for bind mounts
I love your patch! Perhaps something to improve:
Hi James,
I love your patch! Perhaps something to improve:
[auto build test WARNING on s390/features]
[also build test WARNING on linus/master v5.5-rc5]
[cannot apply to arm64/for-next/core tip/x86/asm arm/for-next ia64/next m68k/for-next hp-parisc/for-next powerpc/next sparc-next/master next-20200110] [if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/James-Bottomley/introduce-configfd-as-generalisation-of-fsconfig/20200105-080415 base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features reproduce: # apt-get install sparse # sparse version: v0.6.1-129-g341daf20-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> fs/bind.c:28:18: sparse: sparse: symbol 'to_bind_data' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
kbuild test robot
build bot[RFC PATCH] fs: bind: to_bind_data() can be static
In reply to James BottomleyFixes: 9f2fd15ca3f4 ("fs: bind: add configfs type for bind mounts")
--- bind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bind.c +1 -1
@@ -25,7 +25,7 @@ struct bind_data {struct file *retfile; }; -struct bind_data *to_bind_data (const struct configfd_context *cfc) +static struct bind_data *to_bind_data (const struct configfd_context *cfc) {return cfc->data; }
Quoted 10 lines · James Bottomley
fsconfig is a very powerful configuration mechanism except that it only works for filesystems with superblocks. This patch series generalises the useful concept of a multiple step configurational mechanism carried by a file descriptor. The object of this patch series is to get bind mounts to be configurable in the same way that superblock based ones are, but it should have utility beyond the filesytem realm. Patch 4 also reimplements fsconfig in terms of configfd, but that's not a strictly necessary patch, it is merely a useful demonstration that configfd is a superset of the properties of fsconfig.
Thanks for the patch. I'm glad fsconfig() is picked back up; either by you or by David. We will need this for sure.
But the configfd approach does not strike me as a great idea. Anonymous inode fds provide an abstraction mechanism for kernel objects which we built around fds such as timerfd, pidfd, mountfd and so on. When you stat an anonfd you get ANON_INODE_FS_MAGIC and you get the actual type by looking at fdinfo, or - more common - by parsing out /proc/<pid>/fd/<nr> and discovering "[fscontext]". So it's already a pretty massive abstraction layer we have. But configfd would be yet another fd abstraction based on anonfds.
The idea has been that a new fd type based on anonfds comes with an api specific to that type of fd. That seems way nicer from an api design perspective than implementing new apis as part of yet another generic configfd layer.
Another problem is that these syscalls here would be massive multiplexing syscalls. If they are ever going to be used outside of filesystem use-cases (which is doubtful) they will quickly rival prctl(), seccomp(), and ptrace(). That's not a great thing. Especially, since we recently (a few months ago with Linus chiming in too) had long discussions with the conclusion that multiplexing syscalls are discouraged, from a security and api design perspective. Especially when they are not tied to a specific API (e.g. seccomp() and bpf() are at least tied to a specific API). libcs such as glibc and musl had reservations in that regard as well.
This would also spread the mount api across even more fd types than it already does now which is cumbersome for userspace.
A generic API like that also makes it hard to do interception in userspace which is important for brokers such as e.g. used in Firefox or what we do in various container use-cases.
So I have strong reservations about configfd and would strongly favor the revival of the original fsconfig() patchset.
Christian
James Bottomley
maintainerQuoted 2 lines · Christian Brauner
So I have strong reservations about configfd and would strongly favor the revival of the original
fsconfig()patchset.
Just so I know what I'm replying to, what is the "original fsconfig() patchset"? I simply based configfd on what was upstream ... I couldn't find much discussion in the archives about precursors or original patch sets, so a pointer would be very much appreciated.
James
James Bottomley
maintainerQuoted 12 lines · Christian Brauner
Quoted 10 lines · James Bottomley
fsconfig is a very powerful configuration mechanism except that it only works for filesystems with superblocks. This patch series generalises the useful concept of a multiple step configurational mechanism carried by a file descriptor. The object of this patch series is to get bind mounts to be configurable in the same way that superblock based ones are, but it should have utility beyond the filesytem realm. Patch 4 also reimplements fsconfig in terms of configfd, but that's not a strictly necessary patch, it is merely a useful demonstration that configfd is a superset of the properties of fsconfig.
Quoted 14 lines
Thanks for the patch. I'm glad
fsconfig()is picked back up; either by you or by David. We will need this for sure.
But the configfd approach does not strike me as a great idea. Anonymous inode fds provide an abstraction mechanism for kernel objects which we built around fds such as timerfd, pidfd, mountfd and so on. When you stat an anonfd you getANON_INODE_FS_MAGICand you get the actual type by looking at fdinfo, or - more common - by parsing out /proc/<pid>/fd/<nr> and discovering "[fscontext]". So it's already a pretty massive abstraction layer we have. But configfd would be yet another fd abstraction based on anonfds.
The idea has been that a new fd type based on anonfds comes with an api specific to that type of fd. That seems way nicer from an api design perspective than implementing new apis as part of yet another generic configfd layer.
Really, it's just a fd that gathers config information and can reserve specific errors (and we should really work out the i18n implications of the latter). Whether it's a new fd type or an anonfd with a specific name doesn't seem to be that significant, so the name could be set by the type.
Quoted 4 lines
Another problem is that these syscalls here would be massive multiplexing syscalls. If they are ever going to be used outside of filesystem use-cases (which is doubtful) they will quickly rival
prctl(),seccomp(), andptrace().
Actually, that's partly the point. We do have several systemcalls with variable argument parsing that would benefit from an approach like this. keyctl springs immediately to mind.
Quoted 11 lines
That's not a great thing. Especially, since we recently (a few
months ago with Linus chiming in too) had long discussions with the conclusion that multiplexing syscalls are discouraged, from a security and api design perspective. Especially when they are not tied to a specific API (e.g.seccomp()andbpf()are at least tied to a specific API). libcs such as glibc and musl had reservations in that regard as well.This would also spread the mount api across even more fd types than it already does now which is cumbersome for userspace.
Quoted 6 lines
A generic API like that also makes it hard to do interception in userspace which is important for brokers such as e.g. used in Firefox or what we do in various container use-cases.
So I have strong reservations about configfd and would strongly favor the revival of the original
fsconfig()patchset.
Ah well, I did have plans for configfd to be self describing, so the arguments accepted by each type would be typed and pre-registered and thus parseable generically, so instead of being the usual anonymous multiplex sink, it would at least be an introspectable multiplexed sink. The problem there was I can't make fsconfig fit into that framework but, as I said, it was only done to demo that configfd was a superset, I'm not wedded to that part.
James
[extending the Cc a bit]
Quoted 28 lines · James Bottomley
Quoted 12 lines · Christian Brauner
Quoted 10 lines · James Bottomley
fsconfig is a very powerful configuration mechanism except that it only works for filesystems with superblocks. This patch series generalises the useful concept of a multiple step configurational mechanism carried by a file descriptor. The object of this patch series is to get bind mounts to be configurable in the same way that superblock based ones are, but it should have utility beyond the filesytem realm. Patch 4 also reimplements fsconfig in terms of configfd, but that's not a strictly necessary patch, it is merely a useful demonstration that configfd is a superset of the properties of fsconfig.
Quoted 14 lines
Thanks for the patch. I'm glad
fsconfig()is picked back up; either by you or by David. We will need this for sure.
But the configfd approach does not strike me as a great idea. Anonymous inode fds provide an abstraction mechanism for kernel objects which we built around fds such as timerfd, pidfd, mountfd and so on. When you stat an anonfd you getANON_INODE_FS_MAGICand you get the actual type by looking at fdinfo, or - more common - by parsing out /proc/<pid>/fd/<nr> and discovering "[fscontext]". So it's already a pretty massive abstraction layer we have. But configfd would be yet another fd abstraction based on anonfds.
The idea has been that a new fd type based on anonfds comes with an api specific to that type of fd. That seems way nicer from an api design perspective than implementing new apis as part of yet another generic configfd layer.
Quoted 2 lines
Really, it's just a fd that gathers config information and can reserve specific errors (and we should really work out the i18n implications of
It's rather a complex multiplexer intended to go beyond the realm of filesystems/mount api and that's something we have been burned by before.
Quoted 10 lines
the latter). Whether it's a new fd type or an anonfd with a specific name doesn't seem to be that significant, so the name could be set by the type.
Quoted 4 lines
Another problem is that these syscalls here would be massive multiplexing syscalls. If they are ever going to be used outside of filesystem use-cases (which is doubtful) they will quickly rival
prctl(),seccomp(), andptrace().Actually, that's partly the point. We do have several systemcalls with
Actually I think that's the problem. The keyctl api itself suffers from the problem that it already has a complex multiplexer. That could either point to bad api design (sorry, David :)) or it's just a very complex use-case like the mount api. The good thing is that it's restricted to a single domain: keys. And that's good. Plumbing both e.g. keys and (parts of) mounts on top of another generic api is what strikes me as a bad idea.
Quoted 18 lines
variable argument parsing that would benefit from an approach like this. keyctl springs immediately to mind.
Quoted 15 lines
That's not a great thing. Especially, since we recently (a few
months ago with Linus chiming in too) had long discussions with the conclusion that multiplexing syscalls are discouraged, from a security and api design perspective. Especially when they are not tied to a specific API (e.g.seccomp()andbpf()are at least tied to a specific API). libcs such as glibc and musl had reservations in that regard as well.This would also spread the mount api across even more fd types than it already does now which is cumbersome for userspace.
A generic API like that also makes it hard to do interception in userspace which is important for brokers such as e.g. used in Firefox or what we do in various container use-cases.
Quoted 8 lines
Quoted 2 lines
So I have strong reservations about configfd and would strongly favor the revival of the original
fsconfig()patchset.Ah well, I did have plans for configfd to be self describing, so the arguments accepted by each type would be typed and pre-registered and thus parseable generically, so instead of being the usual anonymous multiplex sink, it would at least be an introspectable multiplexed sink. The problem there was I can't make fsconfig fit into that
We already have fsconfig() to configure mounts so it seems odd to now spread the mount api onto configfd imho.
Christian
James Bottomley
maintainerQuoted 48 lines · Christian Brauner
[extending the Cc a bit]
Quoted 28 lines · James Bottomley
Quoted 12 lines · Christian Brauner
Quoted 10 lines · James Bottomley
fsconfig is a very powerful configuration mechanism except that it only works for filesystems with superblocks. This patch series generalises the useful concept of a multiple step configurationalmechanism carried by a file descriptor. The object of this patch series is to get bind mounts to be configurable in the same way that superblock based ones are, but it should have utility beyond the filesytem realm. Patch 4 also reimplements fsconfig in terms of configfd, but that's not a strictly necessary patch, it is merely a useful demonstration that configfd is a superset of the properties of fsconfig.
Quoted 14 lines
Thanks for the patch. I'm glad
fsconfig()is picked back up; either by you or by David. We will need this for sure. But the configfd approach does not strike me as a great idea. Anonymous inode fds provide an abstraction mechanism for kernel objects which we built around fds such as timerfd, pidfd, mountfd and so on. When you stat an anonfd you getANON_INODE_FS_MAGICand you get the actual type by looking at fdinfo, or - more common - by parsing out /proc/<pid>/fd/<nr> and discovering "[fscontext]". So it's already a pretty massive abstraction layer we have. But configfd would be yet another fd abstraction based on anonfds. The idea has been that a new fd type based on anonfds comes with an api specific to that type of fd. That seems way nicer from an api design perspective than implementing new apis as part of yet another generic configfd layer.Quoted 3 lines
Really, it's just a fd that gathers config information and can reserve specific errors (and we should really work out the i18n implications of
It's rather a complex multiplexer intended to go beyond the realm of filesystems/mount api and that's something we have been burned by before.
Quoted 9 lines
the latter). Whether it's a new fd type or an anonfd with a specific name doesn't seem to be that significant, so the name could be set by the type.
Quoted 4 lines
Another problem is that these syscalls here would be massive multiplexing syscalls. If they are ever going to be used outside of filesystem use-cases (which is doubtful) they will quickly rival
prctl(),seccomp(), andptrace().
Quoted 7 lines
Quoted 2 lines
Actually, that's partly the point. We do have several systemcalls with
Actually I think that's the problem. The keyctl api itself suffers from the problem that it already has a complex multiplexer. That could either point to bad api design (sorry, David :)) or it's just a very complex use-case like the mount api.
I do really think it's a fairly pattern exact use case. The mount API has a complex per-fs-type configuration but simple use via the VFS abstractions, which is why we use a single mount system call instead of one system call per fs. The keyctl API exactly mirrors this: creating keys is complex and highly type dependent but once they're created they're more generically usable. This pattern replicates itself across a lot of subsystems. Storage being an excellent example. Once we have the things configured, we can hide most of the configurational complexity behind a simple use API: the block abstraction.
And the point that annoys me as someone who has to interact with and maintain a few of these systems is that we keep reinventing similar but slightly different solutions for them all.
Quoted 3 lines
The good thing is that it's restricted to a single domain: keys. And
that's good. Plumbing both e.g. keys and (parts of) mounts on top of another generic api is what strikes me as a bad idea.
Actually, I don't think this holds up to examination given the fact that the pattern isn't specific to mount. You can take the view that the configfd approach is wrong ... but that would mean it's wrong for the mount use case as well. I have actually seen people advocate a per-config type system call approach, but that always sank in the plumbing complexity. You could take the view that each problem is a separate domain and needs a separate solution, which is essentially what we do today but that solution then tends to leak (using netlink in SCSI for instance). We've also tried the configuration as filesystem (that's the configfs one that iSCSI and USB gadget does) as an approach to this.
I think the broader question is given the pattern is replicated across subsystems, can we get a solution that works for all the patterns instead of our current patchwork. fsconfig has certain features that make it an interesting solution. It also has the problem that the way its currently constructed means it doesn't apply to a part of its design coverage (bind mounts). Configfd was an attempt to extract the generic part and apply it (initially just on the bit that the coverage was missing for).
I don't disagree that configuration multiplexors are a user space annoyance, but we put up with them because we get a simple and very generic API for the configured object. Given that they're a necessary evil and a widespread pattern, I think examining the question of whether we could cover them all with a single API and what properties it should have is a useful one.
For instance, I think the cardinal annoying missing property in all our above attempts is the lack of introspectability. The inability to enumerate what types and interfaces are available before you start configuring. Even configfs, which is our most introspectable one, has that problem.
So given that we have to have things like this and they do get spread widely, what are the desirable properties to make them more manageable?
The reason I liked fsconfig initially was error return: complex configuration means complex errors and very few of our other solutions have the ability to send them back. The other was the observation that even though fsconfig isn't introspectable, it could be made so.
James