* [PATCH 0/2] ovl: fix regression from new mount api conversion
@ 2023-10-12 13:44 Amir Goldstein
2023-10-12 13:44 ` [PATCH 1/2] fs: factor out vfs_parse_monolithic_sep() helper Amir Goldstein
2023-10-12 13:44 ` [PATCH 2/2] ovl: fix regression in parsing of mount options with esacped comma Amir Goldstein
0 siblings, 2 replies; 4+ messages in thread
From: Amir Goldstein @ 2023-10-12 13:44 UTC (permalink / raw)
To: Miklos Szeredi, Christian Brauner; +Cc: linux-unionfs, linux-fsdevel
Miklos, Christian,
I decided this was easy enough to fix with a generic helper without
duplicating code, so we'd better fix it while 6.5.y is still taking
fixed.
It looks like smb3_fs_context_parse_monolithic() could also use the
generic helper, but it is not a straight forward change, so I will leave
that to smb client developers.
Thanks,
Amir.
Amir Goldstein (2):
fs: factor out vfs_parse_monolithic_sep() helper
ovl: fix regression in parsing of mount options with esacped comma
fs/fs_context.c | 34 +++++++++++++++++++++++++++++-----
fs/overlayfs/params.c | 29 +++++++++++++++++++++++++++++
include/linux/fs_context.h | 2 ++
3 files changed, 60 insertions(+), 5 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] fs: factor out vfs_parse_monolithic_sep() helper
2023-10-12 13:44 [PATCH 0/2] ovl: fix regression from new mount api conversion Amir Goldstein
@ 2023-10-12 13:44 ` Amir Goldstein
2023-10-12 15:19 ` Christian Brauner
2023-10-12 13:44 ` [PATCH 2/2] ovl: fix regression in parsing of mount options with esacped comma Amir Goldstein
1 sibling, 1 reply; 4+ messages in thread
From: Amir Goldstein @ 2023-10-12 13:44 UTC (permalink / raw)
To: Miklos Szeredi, Christian Brauner; +Cc: linux-unionfs, linux-fsdevel
Factor out vfs_parse_monolithic_sep() from generic_parse_monolithic(),
so filesystems could use it with a custom option separator callback.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
Christian,
If you can ack this patch, I'd rather send it to Linus for 6.6-rc6,
along with the two ovl option parsing fixes.
I checked that it does not conflict with any code on vfs.all OTM.
Thanks,
Amir.
fs/fs_context.c | 34 +++++++++++++++++++++++++++++-----
include/linux/fs_context.h | 2 ++
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/fs/fs_context.c b/fs/fs_context.c
index a0ad7a0c4680..98589aae5208 100644
--- a/fs/fs_context.c
+++ b/fs/fs_context.c
@@ -192,17 +192,19 @@ int vfs_parse_fs_string(struct fs_context *fc, const char *key,
EXPORT_SYMBOL(vfs_parse_fs_string);
/**
- * generic_parse_monolithic - Parse key[=val][,key[=val]]* mount data
+ * vfs_parse_monolithic_sep - Parse key[=val][,key[=val]]* mount data
* @fc: The superblock configuration to fill in.
* @data: The data to parse
+ * @sep: callback for separating next option
*
- * Parse a blob of data that's in key[=val][,key[=val]]* form. This can be
- * called from the ->monolithic_mount_data() fs_context operation.
+ * Parse a blob of data that's in key[=val][,key[=val]]* form with a custom
+ * option separator callback.
*
* Returns 0 on success or the error returned by the ->parse_option() fs_context
* operation on failure.
*/
-int generic_parse_monolithic(struct fs_context *fc, void *data)
+int vfs_parse_monolithic_sep(struct fs_context *fc, void *data,
+ char *(*sep)(char **))
{
char *options = data, *key;
int ret = 0;
@@ -214,7 +216,7 @@ int generic_parse_monolithic(struct fs_context *fc, void *data)
if (ret)
return ret;
- while ((key = strsep(&options, ",")) != NULL) {
+ while ((key = sep(&options)) != NULL) {
if (*key) {
size_t v_len = 0;
char *value = strchr(key, '=');
@@ -233,6 +235,28 @@ int generic_parse_monolithic(struct fs_context *fc, void *data)
return ret;
}
+EXPORT_SYMBOL(vfs_parse_monolithic_sep);
+
+static char *vfs_parse_comma_sep(char **s)
+{
+ return strsep(s, ",");
+}
+
+/**
+ * generic_parse_monolithic - Parse key[=val][,key[=val]]* mount data
+ * @fc: The superblock configuration to fill in.
+ * @data: The data to parse
+ *
+ * Parse a blob of data that's in key[=val][,key[=val]]* form. This can be
+ * called from the ->monolithic_mount_data() fs_context operation.
+ *
+ * Returns 0 on success or the error returned by the ->parse_option() fs_context
+ * operation on failure.
+ */
+int generic_parse_monolithic(struct fs_context *fc, void *data)
+{
+ return vfs_parse_monolithic_sep(fc, data, vfs_parse_comma_sep);
+}
EXPORT_SYMBOL(generic_parse_monolithic);
/**
diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h
index 96332db693d5..c13e99cbbf81 100644
--- a/include/linux/fs_context.h
+++ b/include/linux/fs_context.h
@@ -136,6 +136,8 @@ extern struct fs_context *vfs_dup_fs_context(struct fs_context *fc);
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);
+int vfs_parse_monolithic_sep(struct fs_context *fc, void *data,
+ char *(*sep)(char **));
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);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ovl: fix regression in parsing of mount options with esacped comma
2023-10-12 13:44 [PATCH 0/2] ovl: fix regression from new mount api conversion Amir Goldstein
2023-10-12 13:44 ` [PATCH 1/2] fs: factor out vfs_parse_monolithic_sep() helper Amir Goldstein
@ 2023-10-12 13:44 ` Amir Goldstein
1 sibling, 0 replies; 4+ messages in thread
From: Amir Goldstein @ 2023-10-12 13:44 UTC (permalink / raw)
To: Miklos Szeredi, Christian Brauner
Cc: linux-unionfs, linux-fsdevel, Ryan Hendrickson
Ever since commit 91c77947133f ("ovl: allow filenames with comma"), the
following example was legit overlayfs mount options:
mount -t overlay overlay -o 'lowerdir=/tmp/a\,b/lower' /mnt
The conversion to new mount api moved to using the common helper
generic_parse_monolithic() and discarded the specialized ovl_next_opt()
option separator.
Bring back ovl_next_opt() and use vfs_parse_monolithic_sep() to fix the
regression.
Reported-by: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
Closes: https://lore.kernel.org/r/8da307fb-9318-cf78-8a27-ba5c5a0aef6d@alum.mit.edu/
Fixes: 1784fbc2ed9c ("ovl: port to new mount api")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/params.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c
index 1429767a84bc..c2c3820b86f2 100644
--- a/fs/overlayfs/params.c
+++ b/fs/overlayfs/params.c
@@ -157,6 +157,34 @@ const struct fs_parameter_spec ovl_parameter_spec[] = {
{}
};
+static char *ovl_next_opt(char **s)
+{
+ char *sbegin = *s;
+ char *p;
+
+ if (sbegin == NULL)
+ return NULL;
+
+ for (p = sbegin; *p; p++) {
+ if (*p == '\\') {
+ p++;
+ if (!*p)
+ break;
+ } else if (*p == ',') {
+ *p = '\0';
+ *s = p + 1;
+ return sbegin;
+ }
+ }
+ *s = NULL;
+ return sbegin;
+}
+
+static int ovl_parse_monolithic(struct fs_context *fc, void *data)
+{
+ return vfs_parse_monolithic_sep(fc, data, ovl_next_opt);
+}
+
static ssize_t ovl_parse_param_split_lowerdirs(char *str)
{
ssize_t nr_layers = 1, nr_colons = 0;
@@ -683,6 +711,7 @@ static int ovl_reconfigure(struct fs_context *fc)
}
static const struct fs_context_operations ovl_context_ops = {
+ .parse_monolithic = ovl_parse_monolithic,
.parse_param = ovl_parse_param,
.get_tree = ovl_get_tree,
.reconfigure = ovl_reconfigure,
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] fs: factor out vfs_parse_monolithic_sep() helper
2023-10-12 13:44 ` [PATCH 1/2] fs: factor out vfs_parse_monolithic_sep() helper Amir Goldstein
@ 2023-10-12 15:19 ` Christian Brauner
0 siblings, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2023-10-12 15:19 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Miklos Szeredi, linux-unionfs, linux-fsdevel
On Thu, Oct 12, 2023 at 04:44:27PM +0300, Amir Goldstein wrote:
> Factor out vfs_parse_monolithic_sep() from generic_parse_monolithic(),
> so filesystems could use it with a custom option separator callback.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>
> Christian,
>
> If you can ack this patch, I'd rather send it to Linus for 6.6-rc6,
> along with the two ovl option parsing fixes.
Sounds good to me.
Acked-by: Christian Brauner <brauner@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-12 15:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 13:44 [PATCH 0/2] ovl: fix regression from new mount api conversion Amir Goldstein
2023-10-12 13:44 ` [PATCH 1/2] fs: factor out vfs_parse_monolithic_sep() helper Amir Goldstein
2023-10-12 15:19 ` Christian Brauner
2023-10-12 13:44 ` [PATCH 2/2] ovl: fix regression in parsing of mount options with esacped comma Amir Goldstein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).