Skip to content

Commit

Permalink
ovl: fix regression in parsing of mount options with escaped comma
Browse files Browse the repository at this point in the history
Ever since commit 91c7794 ("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 <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Fixes: 1784fbc ("ovl: port to new mount api")
Signed-off-by: Amir Goldstein <[email protected]>
  • Loading branch information
amir73il committed Oct 12, 2023
1 parent e001d14 commit c34706a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions fs/overlayfs/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -682,6 +710,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,
Expand Down

0 comments on commit c34706a

Please sign in to comment.