mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
Merge patch series "ovl: simplify ovl_parse_param_lowerdir()"
Simplify and fix overlayfs layer parsing so the maximum of 500 layers can be used. * patches from https://lore.kernel.org/r/20240705011510.794025-1-chengzhihao1@huawei.com: ovl: ovl_parse_param_lowerdir: Add missed '\n' for pr_err ovl: fix wrong lowerdir number check for parameter Opt_lowerdir ovl: pass string to ovl_parse_layer() Link: https://lore.kernel.org/r/20240705011510.794025-1-chengzhihao1@huawei.com Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
commit
d10771d51b
@ -353,6 +353,8 @@ static void ovl_add_layer(struct fs_context *fc, enum ovl_opt layer,
|
||||
case Opt_datadir_add:
|
||||
ctx->nr_data++;
|
||||
fallthrough;
|
||||
case Opt_lowerdir:
|
||||
fallthrough;
|
||||
case Opt_lowerdir_add:
|
||||
WARN_ON(ctx->nr >= ctx->capacity);
|
||||
l = &ctx->lower[ctx->nr++];
|
||||
@ -365,10 +367,9 @@ static void ovl_add_layer(struct fs_context *fc, enum ovl_opt layer,
|
||||
}
|
||||
}
|
||||
|
||||
static int ovl_parse_layer(struct fs_context *fc, struct fs_parameter *param,
|
||||
enum ovl_opt layer)
|
||||
static int ovl_parse_layer(struct fs_context *fc, const char *layer_name, enum ovl_opt layer)
|
||||
{
|
||||
char *name = kstrdup(param->string, GFP_KERNEL);
|
||||
char *name = kstrdup(layer_name, GFP_KERNEL);
|
||||
bool upper = (layer == Opt_upperdir || layer == Opt_workdir);
|
||||
struct path path;
|
||||
int err;
|
||||
@ -376,7 +377,7 @@ static int ovl_parse_layer(struct fs_context *fc, struct fs_parameter *param,
|
||||
if (!name)
|
||||
return -ENOMEM;
|
||||
|
||||
if (upper)
|
||||
if (upper || layer == Opt_lowerdir)
|
||||
err = ovl_mount_dir(name, &path);
|
||||
else
|
||||
err = ovl_mount_dir_noesc(name, &path);
|
||||
@ -432,7 +433,6 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
|
||||
{
|
||||
int err;
|
||||
struct ovl_fs_context *ctx = fc->fs_private;
|
||||
struct ovl_fs_context_layer *l;
|
||||
char *dup = NULL, *iter;
|
||||
ssize_t nr_lower, nr;
|
||||
bool data_layer = false;
|
||||
@ -449,7 +449,7 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
|
||||
return 0;
|
||||
|
||||
if (*name == ':') {
|
||||
pr_err("cannot append lower layer");
|
||||
pr_err("cannot append lower layer\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -472,35 +472,11 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
if (nr_lower > ctx->capacity) {
|
||||
err = -ENOMEM;
|
||||
l = krealloc_array(ctx->lower, nr_lower, sizeof(*ctx->lower),
|
||||
GFP_KERNEL_ACCOUNT);
|
||||
if (!l)
|
||||
goto out_err;
|
||||
|
||||
ctx->lower = l;
|
||||
ctx->capacity = nr_lower;
|
||||
}
|
||||
|
||||
iter = dup;
|
||||
l = ctx->lower;
|
||||
for (nr = 0; nr < nr_lower; nr++, l++) {
|
||||
ctx->nr++;
|
||||
memset(l, 0, sizeof(*l));
|
||||
|
||||
err = ovl_mount_dir(iter, &l->path);
|
||||
for (nr = 0; nr < nr_lower; nr++) {
|
||||
err = ovl_parse_layer(fc, iter, Opt_lowerdir);
|
||||
if (err)
|
||||
goto out_put;
|
||||
|
||||
err = ovl_mount_dir_check(fc, &l->path, Opt_lowerdir, iter, false);
|
||||
if (err)
|
||||
goto out_put;
|
||||
|
||||
err = -ENOMEM;
|
||||
l->name = kstrdup(iter, GFP_KERNEL_ACCOUNT);
|
||||
if (!l->name)
|
||||
goto out_put;
|
||||
goto out_err;
|
||||
|
||||
if (data_layer)
|
||||
ctx->nr_data++;
|
||||
@ -517,8 +493,8 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
|
||||
* there are no data layers.
|
||||
*/
|
||||
if (ctx->nr_data > 0) {
|
||||
pr_err("regular lower layers cannot follow data lower layers");
|
||||
goto out_put;
|
||||
pr_err("regular lower layers cannot follow data lower layers\n");
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
data_layer = false;
|
||||
@ -532,9 +508,6 @@ static int ovl_parse_param_lowerdir(const char *name, struct fs_context *fc)
|
||||
kfree(dup);
|
||||
return 0;
|
||||
|
||||
out_put:
|
||||
ovl_reset_lowerdirs(ctx);
|
||||
|
||||
out_err:
|
||||
kfree(dup);
|
||||
|
||||
@ -582,7 +555,7 @@ static int ovl_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
||||
case Opt_datadir_add:
|
||||
case Opt_upperdir:
|
||||
case Opt_workdir:
|
||||
err = ovl_parse_layer(fc, param, opt);
|
||||
err = ovl_parse_layer(fc, param->string, opt);
|
||||
break;
|
||||
case Opt_default_permissions:
|
||||
config->default_permissions = true;
|
||||
|
Loading…
Reference in New Issue
Block a user