linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hujianyang <hujianyang@huawei.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: <linux-unionfs@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	Seunghun Lee <waydi1@gmail.com>,
	"Fabian Sturm" <fabian.sturm@aduu.de>
Subject: [PATCH 2/3] ovl: check lowerdir amount for non-upper mount
Date: Thu, 15 Jan 2015 13:19:21 +0800	[thread overview]
Message-ID: <54B74DD9.2020607@huawei.com> (raw)
In-Reply-To: <54B74D70.3000205@huawei.com>

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>
---
 fs/overlayfs/super.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index ab3c8cb..edbb3eb 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)
-- 
1.6.0.2


  reply	other threads:[~2015-01-15  5:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15  5:17 [PATCH 1/3] ovl: print error message for invalid mount options hujianyang
2015-01-15  5:19 ` hujianyang [this message]
2015-01-15  5:20 ` [PATCH 3/3] ovl: upper fs should not be R/O hujianyang
2015-01-15  8:20   ` Seunghun Lee
2015-01-15 17:09     ` A. Wan
2015-01-16  2:39       ` hujianyang
2015-03-18  9:35   ` Miklos Szeredi
2015-01-15  5:52 ` [PATCH 1/3] ovl: print error message for invalid mount options hujianyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54B74DD9.2020607@huawei.com \
    --to=hujianyang@huawei.com \
    --cc=fabian.sturm@aduu.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=waydi1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).