summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhujianyang <hujianyang@huawei.com>2015-01-15 08:19:21 +0300
committerMiklos Szeredi <mszeredi@suse.cz>2015-03-18 12:29:47 +0300
commit6be4506e34cf6075a1307b646e0a6c46c1c9010d (patch)
treeb7d1dd8992d90151862fcc6cdfdfda6c58e9084e
parentbead55ef775f6e25a8d286c0d47030580f577bec (diff)
downloadlinux-6be4506e34cf6075a1307b646e0a6c46c1c9010d.tar.xz
ovl: check lowerdir amount for non-upper mount
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 <hujianyang@huawei.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
-rw-r--r--fs/overlayfs/super.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index ab3c8cb8e52d..edbb3ebcdaad 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -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)