vfs: verify param type in vfs_parse_sb_flag()
Subsystems (11)
PATCH 1/13 vfs: verify param type in vfs_parse_sb_flag()
vfs_parse_sb_flag() accepted any kind of param with a matching key, not just a flag. This is wrong, only allow flag type and return -EINVAL otherwise.
--- fs/fs_context.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
fs/fs_context.c +15 -16
@@ -81,30 +81,29 @@ static const char *const forbidden_sb_flag[] = {/* * Check for a common mount option that manipulates s_flags. */ -static int vfs_parse_sb_flag (struct fs_context *fc,const char *key) +static int vfs_parse_sb_flag (struct fs_context *fc,struct fs_parameter *param) { -unsigned int token; +const char *key = param->key; +unsigned int set, clear;unsigned int i;for (i =0 ; i <ARRAY_SIZE (forbidden_sb_flag); i++)if (strcmp (key, forbidden_sb_flag[i]) ==0 )return -EINVAL ; - token =lookup_constant (common_set_sb_flag, key,0 ); -if (token) { - fc->sb_flags |= token; - fc->sb_flags_mask |= token; -return 0 ; - } + set =lookup_constant (common_set_sb_flag, key,0 ); + clear =lookup_constant (common_clear_sb_flag, key,0 ); +if (!set && !clear) +return -ENOPARAM ; - token =lookup_constant (common_clear_sb_flag, key,0 ); -if (token) { - fc->sb_flags &= ~token; - fc->sb_flags_mask |= token; -return 0 ; - } +if (param->type != fs_value_is_flag) +return invalf (fc,"%s: Unexpected value for '%s'" , + fc->fs_type->name, param->key); -return -ENOPARAM ; + fc->sb_flags |= set; + fc->sb_flags &= ~clear; + fc->sb_flags_mask |= set | clear; +return 0 ; }/**
@@ -130,7 +129,7 @@ int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param)if (!param->key)return invalf (fc,"Unnamed parameter\n" ); - ret =vfs_parse_sb_flag (fc, param->key); + ret =vfs_parse_sb_flag (fc, param);if (ret != -ENOPARAM )return ret;
Signature · 1 line
2.21.0
PATCH 2/13 vfs: move vfs_parse_sb_flag() calls into filesystems
Move parsing "standard" options into filesystems' ->parse_param(). This patch doesn't change behavior.
This is in preparation for allowing filesystems to reject options that they don't support.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 +++++- fs/afs/super.c | 6 +++++- fs/fs_context.c | 12 +++++++----- fs/fuse/control.c | 1 + fs/hugetlbfs/inode.c | 6 +++++- fs/proc/root.c | 6 +++++- fs/sysfs/mount.c | 1 + include/linux/fs_context.h | 1 + ipc/mqueue.c | 1 + kernel/cgroup/cgroup-v1.c | 6 +++++- kernel/cgroup/cgroup.c | 6 +++++- kernel/cgroup/cpuset.c | 1 + 12 files changed, 42 insertions(+), 11 deletions(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +5 -1
@@ -2051,7 +2051,11 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) {struct rdt_fs_context *ctx =rdt_fc2context (fc);struct fs_parse_result result; -int opt; +int ret, opt; + + ret =vfs_parse_sb_flag (fc, param); +if (ret != -ENOPARAM ) +return ret; opt =fs_parse (fc, &rdt_fs_parameters, param, &result);if (opt <0 )
fs/afs/super.c +5 -1
@@ -321,7 +321,11 @@ static int afs_parse_param(struct fs_context *fc, struct fs_parameter *param) {struct fs_parse_result result;struct afs_fs_context *ctx = fc->fs_private; -int opt; +int ret, opt; + + ret =vfs_parse_sb_flag (fc, param); +if (ret != -ENOPARAM ) +return ret; opt =fs_parse (fc, &afs_fs_parameters, param, &result);if (opt <0 )
fs/fs_context.c +7 -5
@@ -81,7 +81,7 @@ static const char *const forbidden_sb_flag[] = {/* * Check for a common mount option that manipulates s_flags. */ -static int vfs_parse_sb_flag (struct fs_context *fc,struct fs_parameter *param) +int vfs_parse_sb_flag (struct fs_context *fc,struct fs_parameter *param) {const char *key = param->key;unsigned int set, clear;
@@ -105,6 +105,7 @@ static int vfs_parse_sb_flag(struct fs_context *fc, struct fs_parameter *param) fc->sb_flags_mask |= set | clear;return 0 ; } +EXPORT_SYMBOL (vfs_parse_sb_flag);/** * vfs_parse_fs_param - Add a single parameter to a superblock config
@@ -129,10 +130,6 @@ int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param)if (!param->key)return invalf (fc,"Unnamed parameter\n" ); - ret =vfs_parse_sb_flag (fc, param); -if (ret != -ENOPARAM ) -return ret; - ret =security_fs_context_parse_param (fc, param);if (ret != -ENOPARAM )/* Param belongs to the LSM or is disallowed by the LSM; so
@@ -561,6 +558,11 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param)struct legacy_fs_context *ctx = fc->fs_private;unsigned int size = ctx->data_size;size_t len =0 ; +int ret; + + ret =vfs_parse_sb_flag (fc, param); +if (ret != -ENOPARAM ) +return ret;if (strcmp (param->key,"source" ) ==0 ) {if (param->type != fs_value_is_string)
fs/fuse/control.c +1 -0
@@ -351,6 +351,7 @@ static int fuse_ctl_get_tree(struct fs_context *fc)static const struct fs_context_operations fuse_ctl_context_ops = { .get_tree = fuse_ctl_get_tree, + .parse_param = vfs_parse_fs_param, };static int fuse_ctl_init_fs_context (struct fs_context *fc)
fs/hugetlbfs/inode.c +5 -1
@@ -1149,7 +1149,11 @@ static int hugetlbfs_parse_param(struct fs_context *fc, struct fs_parameter *parstruct fs_parse_result result;char *rest;unsigned long ps; -int opt; +int ret, opt; + + ret =vfs_parse_sb_flag (fc, param); +if (ret != -ENOPARAM ) +return ret; opt =fs_parse (fc, &hugetlb_fs_parameters, param, &result);if (opt <0 )
fs/proc/root.c +5 -1
@@ -56,7 +56,11 @@ static int proc_parse_param(struct fs_context *fc, struct fs_parameter *param) {struct proc_fs_context *ctx = fc->fs_private;struct fs_parse_result result; -int opt; +int ret, opt; + + ret =vfs_parse_sb_flag (fc, param); +if (ret != -ENOPARAM ) +return ret; opt =fs_parse (fc, &proc_fs_parameters, param, &result);if (opt <0 )
fs/sysfs/mount.c +1 -0
@@ -49,6 +49,7 @@ static void sysfs_fs_context_free(struct fs_context *fc)static const struct fs_context_operations sysfs_fs_context_ops = { .free = sysfs_fs_context_free, + .parse_param = vfs_parse_sb_flag, .get_tree = sysfs_get_tree, };
include/linux/fs_context.h +1 -0
@@ -127,6 +127,7 @@ extern struct fs_context *fs_context_for_submount(struct file_system_type *fs_ty struct dentry *reference);extern struct fs_context *vfs_dup_fs_context (struct fs_context *fc); +extern int vfs_parse_sb_flag (struct fs_context *fc,struct fs_parameter *param);extern int vfs_parse_fs_param (struct fs_context *fc,struct fs_parameter *param);extern int vfs_parse_fs_string (struct fs_context *fc,const char *key,const char *value,size_t v_size);
ipc/mqueue.c +1 -0
@@ -1577,6 +1577,7 @@ static const struct super_operations mqueue_super_ops = {static const struct fs_context_operations mqueue_fs_context_ops = { .free = mqueue_fs_context_free, + .parse_param = vfs_parse_sb_flag, .get_tree = mqueue_get_tree, };
kernel/cgroup/cgroup-v1.c +5 -1
@@ -927,7 +927,11 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)struct cgroup_fs_context *ctx =cgroup_fc2context (fc);struct cgroup_subsys *ss;struct fs_parse_result result; -int opt, i; +int ret, opt, i; + + ret =vfs_parse_sb_flag (fc, param); +if (ret != -ENOPARAM ) +return ret; opt =fs_parse (fc, &cgroup1_fs_parameters, param, &result);if (opt == -ENOPARAM ) {
kernel/cgroup/cgroup.c +5 -1
@@ -1834,7 +1834,11 @@ static int cgroup2_parse_param(struct fs_context *fc, struct fs_parameter *param {struct cgroup_fs_context *ctx =cgroup_fc2context (fc);struct fs_parse_result result; -int opt; +int ret, opt; + + ret =vfs_parse_sb_flag (fc, param); +if (ret != -ENOPARAM ) +return ret; opt =fs_parse (fc, &cgroup2_fs_parameters, param, &result);if (opt <0 )
kernel/cgroup/cpuset.c +1 -0
@@ -394,6 +394,7 @@ static int cpuset_get_tree(struct fs_context *fc) }static const struct fs_context_operations cpuset_fs_context_ops = { + .parse_param = vfs_parse_sb_flag, .get_tree = cpuset_get_tree, };
Signature · 1 line
2.21.0
PATCH 3/13 vfs: don't parse forbidden flags
In reply to Miklos SzerediImpossible to keep this blacklist properly synced with what mount(8) parses and what it doesn't. E.g. it has various forms of "*atime" options, but not "atime"...
Other than being impossible to maintain, it also makes little sense. So just get rid of it.
--- fs/fs_context.c | 28 ---------------------------- 1 file changed, 28 deletions(-)
fs/fs_context.c +0 -28
@@ -55,29 +55,6 @@ static const struct constant_table common_clear_sb_flag[] = { { "silent", SB_SILENT }, }; -static const char *const forbidden_sb_flag[] = { -"bind" , -"dev" , -"exec" , -"move" , -"noatime" , -"nodev" , -"nodiratime" , -"noexec" , -"norelatime" , -"nostrictatime" , -"nosuid" , -"private" , -"rec" , -"relatime" , -"remount" , -"shared" , -"slave" , -"strictatime" , -"suid" , -"unbindable" , -}; -/* * Check for a common mount option that manipulates s_flags. */
@@ -85,11 +62,6 @@ int vfs_parse_sb_flag(struct fs_context *fc, struct fs_parameter *param) {const char *key = param->key;unsigned int set, clear; -unsigned int i; - -for (i =0 ; i <ARRAY_SIZE (forbidden_sb_flag); i++) -if (strcmp (key, forbidden_sb_flag[i]) ==0 ) -return -EINVAL ; set =lookup_constant (common_set_sb_flag, key,0 ); clear =lookup_constant (common_clear_sb_flag, key,0 );
Signature · 1 line
2.21.0
PATCH 4/13 vfs: don't parse "posixacl" option
In reply to Miklos SzerediUnlike the others, this is _not_ a standard option accepted by mount(8).
In fact SB_POSIXACL is an internal flag, and accepting MS_POSIXACL on the mount(2) interface is possibly a bug.
The only filesystem that apparently wants to handle the "posixacl" option is 9p, but it has special handling of that option besides setting SB_POSIXACL.
--- fs/fs_context.c | 1 - 1 file changed, 1 deletion(-)
fs/fs_context.c +0 -1
@@ -42,7 +42,6 @@ static const struct constant_table common_set_sb_flag[] = { { "dirsync", SB_DIRSYNC }, { "lazytime", SB_LAZYTIME }, { "mand", SB_MANDLOCK }, - { "posixacl", SB_POSIXACL }, { "ro", SB_RDONLY }, { "sync", SB_SYNCHRONOUS }, };
Signature · 1 line
2.21.0
PATCH 5/13 vfs: don't parse "silent" option
In reply to Miklos SzerediWhile this is a standard option as documented in mount(8), it is ignored by most filesystems. So reject, unless filesystem explicitly wants to handle it.
The exception is unconverted filesystems, where it is unknown if the filesystem handles this or not.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- fs/fs_context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/fs_context.c +3 -1
@@ -51,7 +51,6 @@ static const struct constant_table common_clear_sb_flag[] = { { "nolazytime", SB_LAZYTIME }, { "nomand", SB_MANDLOCK }, { "rw", SB_RDONLY }, - { "silent", SB_SILENT }, };/*
@@ -535,6 +534,9 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param)if (ret != -ENOPARAM )return ret; +if (strcmp (param->key,"silent" ) ==0 ) + fc->sb_flags |=SB_SILENT ; +if (strcmp (param->key,"source" ) ==0 ) {if (param->type != fs_value_is_string)return invalf (fc,"VFS: Legacy: Non-string source" );
Signature · 1 line
2.21.0
Re: [PATCH 05/13] vfs: don't parse "silent" option
Quoted 9 lines · Miklos Szeredi
While this is a standard option as documented in mount(8), it is ignored by most filesystems. So reject, unless filesystem explicitly wants to handle it.
The exception is unconverted filesystems, where it is unknown if the filesystem handles this or not.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from
fsconfig().
In theory this is fine but every time someone has attempted to change the handling of this in the past autofs has had problems so I'm a bit wary of the change.
It was originally meant to tell the file system to ignore invalid options such as could be found in automount maps that are used with multiple OS implementations that have differences in their options.
That was, IIRC, primarily NFS although NFS should handle most (if not all of those) cases these days.
Nevertheless I'm a bit nervous about it, ;)
Quoted 30 lines
Signed-off-by Miklos Szeredi <[email protected]>--- fs/fs_context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/fs_context.c +0
-1@@ -51,7 +51,6 @@ static const struct constant_table common_clear_sb_flag[] = { { "nolazytime", SB_LAZYTIME }, { "nomand", SB_MANDLOCK }, { "rw", SB_RDONLY }, - { "silent", SB_SILENT }, };/*
fs/fs_context.c +3
-0@@ -535,6 +534,9 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param)if (ret != -ENOPARAM )return ret; +if (strcmp (param->key,"silent" ) ==0 ) + fc->sb_flags |=SB_SILENT ; +if (strcmp (param->key,"source" ) ==0 ) {if (param->type != fs_value_is_string)return
invalf(fc, "VFS: Legacy: Non-string source");
Re: [PATCH 05/13] vfs: don't parse "silent" option
Quoted 21 lines · Ian Kent
Quoted 9 lines · Miklos Szeredi
While this is a standard option as documented in mount(8), it is ignored by most filesystems. So reject, unless filesystem explicitly wants to handle it.
The exception is unconverted filesystems, where it is unknown if the filesystem handles this or not.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from
fsconfig().In theory this is fine but every time someone has attempted to change the handling of this in the past autofs has had problems so I'm a bit wary of the change.
It was originally meant to tell the file system to ignore invalid options such as could be found in automount maps that are used with multiple OS implementations that have differences in their options.
Quoted 4 lines
That was, IIRC, primarily NFS although NFS should handle most (if not all of those) cases these days.
Nevertheless I'm a bit nervous about it, ;)
What I'm saying is that with a new interface the rules need not follow the rules of the old interface, because at the start no one is using the new interface, so no chance of breaking anything.
Yes, there's a chance of making the interface difficult to use, but I don't think this is one of those things.
For one, "silent" should not be needed on the new interface at all, because error messages relating to the setup of the filesystem can be redirected to a log buffer dedicated to the setup instance, effectively enabling silent operation by default.
Thanks.,
Miklos
David Howells
maintainerRe: [PATCH 05/13] vfs: don't parse "silent" option
Quoted 3 lines · Miklos Szeredi
What I'm saying is that with a new interface the rules need not follow the rules of the old interface, because at the start no one is using the new interface, so no chance of breaking anything.
Er. No. That's not true, since the old interface comes through the new one.
David
Re: [PATCH 05/13] vfs: don't parse "silent" option
Quoted 8 lines · David Howells
Quoted 3 lines · Miklos Szeredi
What I'm saying is that with a new interface the rules need not follow the rules of the old interface, because at the start no one is using the new interface, so no chance of breaking anything.
Er. No. That's not true, since the old interface comes through the new one.
No, old interface sets SB_* directly from arg 4 of mount(2) and not via parsing arg 5.
Thanks,
Miklos
Re: [PATCH 05/13] vfs: don't parse "silent" option
Quoted 5 lines · Miklos Szeredi
Quoted 3 lines · David Howells
Miklos Szeredi <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
What I'm saying is that with a new interface the rules need not follow the rules of the old interface, because at the start no one is using the new interface, so no chance of breaking anything.
Er. No. That's not true, since the old interface comes through the new one.
No, old interface sets SB_* directly from arg 4 of mount(2) and not via parsing arg 5.
See also 9p mess up of "posixacl" handling *on the old interface* due to exactly because the internal API doesn't differentiate between options coming from the old interface and ones coming from the new.
So you are right that there's breakage, but it's due to the fact that common code parses anything, and not because it doesn't.
Thanks,
Miklos
PATCH 6/13 vfs: new helper: vfs_parse_ro_rw()
In reply to Miklos SzerediThis just parses the "ro" and "rw" options and sets sb_flags accordingly.
--- fs/fs_context.c | 18 ++++++++++++++++++ include/linux/fs_context.h | 1 + 2 files changed, 19 insertions(+)
fs/fs_context.c +18 -0
@@ -77,6 +77,24 @@ int vfs_parse_sb_flag(struct fs_context *fc, struct fs_parameter *param) }EXPORT_SYMBOL (vfs_parse_sb_flag); +int vfs_parse_ro_rw (struct fs_context *fc,struct fs_parameter *param) +{ +if (strcmp (param->key,"ro" ) ==0 ) + fc->sb_flags |=SB_RDONLY ; +else if (strcmp (param->key,"rw" ) ==0 ) + fc->sb_flags &= ~SB_RDONLY ; +else +return -ENOPARAM ; + +if (param->type != fs_value_is_flag) +return invalf (fc,"%s: Unexpected value for '%s'" , + fc->fs_type->name, param->key); + + fc->sb_flags_mask |=SB_RDONLY ; +return 0 ; +} +EXPORT_SYMBOL (vfs_parse_ro_rw); +/** * vfs_parse_fs_param - Add a single parameter to a superblock config * @fc: The filesystem context to modify
include/linux/fs_context.h +1 -0
@@ -128,6 +128,7 @@ extern struct fs_context *fs_context_for_submount(struct file_system_type *fs_tyextern struct fs_context *vfs_dup_fs_context (struct fs_context *fc);extern int vfs_parse_sb_flag (struct fs_context *fc,struct fs_parameter *param); +extern int vfs_parse_ro_rw (struct fs_context *fc,struct fs_parameter *param);extern int vfs_parse_fs_param (struct fs_context *fc,struct fs_parameter *param);extern int vfs_parse_fs_string (struct fs_context *fc,const char *key,const char *value,size_t v_size);
Signature · 1 line
2.21.0
PATCH 7/13 proc: don't ignore options
In reply to Miklos SzerediThe options "sync", "async", "dirsync", "lazytime", "nolazytime", "mand" and "nomand" make no sense for the proc filesystem. If these options are supplied to fsconfig(FSCONFIG_SET_FLAG), then return -EINVAL instead of silently ignoring the option.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- fs/proc/root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/root.c +1 -1
@@ -58,7 +58,7 @@ static int proc_parse_param(struct fs_context *fc, struct fs_parameter *param)struct fs_parse_result result;int ret, opt; - ret =vfs_parse_sb_flag (fc, param); + ret =vfs_parse_ro_rw (fc, param);if (ret != -ENOPARAM )return ret;
Signature · 1 line
2.21.0
PATCH 8/13 sysfs: don't ignore options
In reply to Miklos SzerediThe options "sync", "async", "dirsync", "lazytime", "nolazytime", "mand" and "nomand" make no sense for the sysfs filesystem. If these options are supplied to fsconfig(FSCONFIG_SET_FLAG), then return -EINVAL instead of silently ignoring the option.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- fs/sysfs/mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/sysfs/mount.c +1 -1
@@ -49,7 +49,7 @@ static void sysfs_fs_context_free(struct fs_context *fc)static const struct fs_context_operations sysfs_fs_context_ops = { .free = sysfs_fs_context_free, - .parse_param = vfs_parse_sb_flag, + .parse_param = vfs_parse_ro_rw, .get_tree = sysfs_get_tree, };
Signature · 1 line
2.21.0
PATCH 9/13 mqueue: don't ignore options
In reply to Miklos SzerediThe options "sync", "async", "dirsync", "lazytime", "nolazytime", "mand" and "nomand" make no sense for the mqueue filesystem. If these options are supplied to fsconfig(FSCONFIG_SET_FLAG), then return -EINVAL instead of silently ignoring the option.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- ipc/mqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ipc/mqueue.c +1 -1
@@ -1577,7 +1577,7 @@ static const struct super_operations mqueue_super_ops = {static const struct fs_context_operations mqueue_fs_context_ops = { .free = mqueue_fs_context_free, - .parse_param = vfs_parse_sb_flag, + .parse_param = vfs_parse_ro_rw, .get_tree = mqueue_get_tree, };
Signature · 1 line
2.21.0
PATCH 10/13 cpuset: don't ignore options
In reply to Miklos SzerediThe options "sync", "async", "dirsync", "lazytime", "nolazytime", "mand" and "nomand" make no sense for the cpuset filesystem. If these options are supplied to fsconfig(FSCONFIG_SET_FLAG), then return -EINVAL instead of silently ignoring the option.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- kernel/cgroup/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cpuset.c +1 -1
@@ -394,7 +394,7 @@ static int cpuset_get_tree(struct fs_context *fc) }static const struct fs_context_operations cpuset_fs_context_ops = { - .parse_param = vfs_parse_sb_flag, + .parse_param = vfs_parse_ro_rw, .get_tree = cpuset_get_tree, };
Signature · 1 line
2.21.0
PATCH 11/13 cgroup: don't ignore options
In reply to Miklos SzerediThe options "sync", "async", "dirsync", "lazytime", "nolazytime", "mand" and "nomand" make no sense for the cgroup filesystem. If these options are supplied to fsconfig(FSCONFIG_SET_FLAG), then return -EINVAL instead of silently ignoring the option.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- kernel/cgroup/cgroup-v1.c | 2 +- kernel/cgroup/cgroup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cgroup-v1.c +1 -1
@@ -929,7 +929,7 @@ int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param)struct fs_parse_result result;int ret, opt, i; - ret =vfs_parse_sb_flag (fc, param); + ret =vfs_parse_ro_rw (fc, param);if (ret != -ENOPARAM )return ret;
kernel/cgroup/cgroup.c +1 -1
@@ -1836,7 +1836,7 @@ static int cgroup2_parse_param(struct fs_context *fc, struct fs_parameter *paramstruct fs_parse_result result;int ret, opt; - ret =vfs_parse_sb_flag (fc, param); + ret =vfs_parse_ro_rw (fc, param);if (ret != -ENOPARAM )return ret;
Signature · 1 line
2.21.0
PATCH 12/13 fusectl: don't ignore options
In reply to Miklos SzerediThe options "sync", "async", "dirsync", "lazytime", "nolazytime", "mand" and "nomand" make no sense for the fusectl filesystem. If these options are supplied to fsconfig(FSCONFIG_SET_FLAG), then return -EINVAL instead of silently ignoring the option.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- fs/fuse/control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/control.c +1 -1
@@ -351,7 +351,7 @@ static int fuse_ctl_get_tree(struct fs_context *fc)static const struct fs_context_operations fuse_ctl_context_ops = { .get_tree = fuse_ctl_get_tree, - .parse_param = vfs_parse_fs_param, + .parse_param = vfs_parse_ro_rw, };static int fuse_ctl_init_fs_context (struct fs_context *fc)
Signature · 1 line
2.21.0
PATCH 13/13 resctrl: don't ignore options
In reply to Miklos SzerediThe options "sync", "async", "dirsync", "lazytime", "nolazytime", "mand" and "nomand" make no sense for the resctrl filesystem. If these options are supplied to fsconfig(FSCONFIG_SET_FLAG), then return -EINVAL instead of silently ignoring the option.
Any implementation, such as mount(8) that needs to parse this option without failing should simply ignore the return value from fsconfig().
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +1 -1
@@ -2053,7 +2053,7 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param)struct fs_parse_result result;int ret, opt; - ret =vfs_parse_sb_flag (fc, param); + ret =vfs_parse_ro_rw (fc, param);if (ret != -ENOPARAM )return ret;
Signature · 1 line
2.21.0
Miklos Szeredi
maintainerHi David,
Ping? Have you had a chance of looking at this series?
Köszi,
Miklos
Quoted 71 lines · Miklos Szeredi
vfs_parse_sb_flag()accepted any kind of param with a matching key, not just a flag. This is wrong, only allow flag type and return-EINVALotherwise.Signed-off-by Miklos Szeredi <[email protected]>--- fs/fs_context.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)fs/fs_context.c +15
-17@@ -81,30 +81,29 @@ static const char *const forbidden_sb_flag[] = {/* * Check for a common mount option that manipulates s_flags. */ -static int vfs_parse_sb_flag (struct fs_context *fc,const char *key) +static int vfs_parse_sb_flag (struct fs_context *fc,struct fs_parameter *param) { -unsigned int token; +const char *key = param->key; +unsigned int set, clear;unsigned int i;for (i =0 ; i <ARRAY_SIZE (forbidden_sb_flag); i++)if (strcmp (key, forbidden_sb_flag[i]) ==0 )return -EINVAL ; - token =lookup_constant (common_set_sb_flag, key,0 ); -if (token) { - fc->sb_flags |= token; - fc->sb_flags_mask |= token; -return 0 ; - } + set =lookup_constant (common_set_sb_flag, key,0 ); + clear =lookup_constant (common_clear_sb_flag, key,0 ); +if (!set && !clear) +return -ENOPARAM ; - token =lookup_constant (common_clear_sb_flag, key,0 ); -if (token) { - fc->sb_flags &= ~token; - fc->sb_flags_mask |= token; -return 0 ; - } +if (param->type != fs_value_is_flag) +return invalf (fc,"%s: Unexpected value for '%s'" , + fc->fs_type->name, param->key); -return -ENOPARAM ; + fc->sb_flags |= set; + fc->sb_flags &= ~clear; + fc->sb_flags_mask |= set | clear; +return 0 ; }/** @@ -130,7 +129,7 @@ int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param)if (!param->key)return invalf (fc,"Unnamed parameter\n" ); - ret =vfs_parse_sb_flag (fc, param->key); + ret =vfs_parse_sb_flag (fc, param);if (ret != -ENOPARAM )return ret; --2.21.0
David Howells
maintainerQuoted 1 line · Miklos Szeredi
Ping? Have you had a chance of looking at this series?
Yeah, through due to time pressure, I haven't managed to do much with it.
I don't agree with all your changes, and also I'd like them to wait till after the branch of mount API filesystem conversions that I've given to Al has had a chance to hopefully go in in this merge window, along with whatever changes Al has made to it.
Bocsánat,
David
Miklos Szeredi
maintainerQuoted 11 lines · David Howells
Quoted 1 line · Miklos Szeredi
Ping? Have you had a chance of looking at this series?
Yeah, through due to time pressure, I haven't managed to do much with it.
I don't agree with all your changes, and also I'd like them to wait till after the branch of mount API filesystem conversions that I've given to Al has had a chance to hopefully go in in this merge window, along with whatever changes Al has made to it.
Ping?
Thanks,
Miklos