Skip to content

Commit

Permalink
ovl: check lowerdir amount for non-upper mount
Browse files Browse the repository at this point in the history
Recently multi-lower layer mount support allow upperdir and workdir
to be omitted, then cause overlayfs can be mount with only one
lowerdir directory. This action make no sense and have potential risk.

This patch check the total number of lower directories to prevent
mounting overlayfs with only one directory.

Also, an error message is added to indicate lower directories exceed
OVL_MAX_STACK limit.

Signed-off-by: hujianyang <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
  • Loading branch information
hujianyang authored and Miklos Szeredi committed Mar 18, 2015
1 parent bead55e commit 6be4506
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,14 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)

err = -EINVAL;
stacklen = ovl_split_lowerdirs(lowertmp);
if (stacklen > OVL_MAX_STACK)
if (stacklen > OVL_MAX_STACK) {
pr_err("overlayfs: too many lower directries, limit is %d\n",
OVL_MAX_STACK);
goto out_free_lowertmp;
} else if (!ufs->config.upperdir && stacklen == 1) {
pr_err("overlayfs: at least 2 lowerdir are needed while upperdir nonexistent\n");
goto out_free_lowertmp;
}

stack = kcalloc(stacklen, sizeof(struct path), GFP_KERNEL);
if (!stack)
Expand Down

0 comments on commit 6be4506

Please sign in to comment.