public inbox for linux-unionfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Subject: [PATCH 06/10] ovl: force read-only mount with no index dir
Date: Tue, 11 Jul 2017 15:58:39 +0300	[thread overview]
Message-ID: <1499777923-29410-7-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1499777923-29410-1-git-send-email-amir73il@gmail.com>

When workdir creation fails, overlay is mounted read-only and
remount,rw is not allowed. When index dir creation fails, overlay
is mounted readonly, but we also need to enforce no remount,rw in
that case.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/overlayfs/super.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 6381e71b0d5d..215b6d23d944 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -274,7 +274,8 @@ static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)
 /* Will this overlay be forced to mount/remount ro? */
 static bool ovl_force_readonly(struct ovl_fs *ufs)
 {
-	return (!ufs->upper_mnt || !ufs->workdir);
+	return (!ufs->upper_mnt || !ufs->workdir ||
+		(ufs->config.index && !ufs->indexdir));
 }
 
 /**
@@ -298,7 +299,7 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
 	if (ufs->config.redirect_dir != ovl_redirect_dir_def)
 		seq_printf(m, ",redirect_dir=%s",
 			   ufs->config.redirect_dir ? "on" : "off");
-	if (ufs->config.index != ovl_index_def)
+	if (!ovl_force_readonly(ufs) && ufs->config.index != ovl_index_def)
 		seq_printf(m, ",index=%s",
 			   ufs->config.index ? "on" : "off");
 	return 0;
@@ -1050,7 +1051,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 	else if (ufs->upper_mnt->mnt_sb != ufs->same_sb)
 		ufs->same_sb = NULL;
 
-	if (!(ovl_force_readonly(ufs)) && ufs->config.index) {
+	if (ufs->upper_mnt && ufs->workdir && ufs->config.index) {
 		/* Verify lower root is upper root origin */
 		err = ovl_verify_origin(upperpath.dentry, ufs->lower_mnt[0],
 					stack[0].dentry, false, true);
@@ -1080,10 +1081,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 			goto out_put_indexdir;
 	}
 
-	/* Show index=off/on in /proc/mounts for any of the reasons above */
-	if (!ufs->indexdir)
-		ufs->config.index = false;
-
 	if (remote)
 		sb->s_d_op = &ovl_reval_dentry_operations;
 	else
-- 
2.7.4

  parent reply	other threads:[~2017-07-11 12:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 12:58 [PATCH 00/10] overlayfs assorted fixes for v4.13 Amir Goldstein
2017-07-11 12:58 ` [PATCH 01/10] ovl: mark parent impure on ovl_link() Amir Goldstein
2017-07-11 12:58 ` [PATCH 02/10] ovl: fix random return value on mount Amir Goldstein
2017-07-11 12:58 ` [PATCH 03/10] ovl: fix origin verification of index dir Amir Goldstein
2017-07-11 12:58 ` [PATCH 04/10] ovl: remove unneeded check for IS_ERR() Amir Goldstein
2017-07-11 12:58 ` [PATCH 05/10] ovl: suppress file handle support warnings on read-only mount Amir Goldstein
2017-07-11 12:58 ` Amir Goldstein [this message]
2017-07-13 20:11   ` [PATCH 06/10] ovl: force read-only mount with no index dir Miklos Szeredi
2017-07-14  6:11     ` Amir Goldstein
2017-07-14  9:47       ` Miklos Szeredi
2017-07-11 12:58 ` [PATCH 07/10] ovl: mount overlay read-only on failure to verify " Amir Goldstein
2017-07-13 20:13   ` Miklos Szeredi
2017-07-14  6:51     ` Amir Goldstein
2017-07-14 10:05       ` Miklos Szeredi
2017-07-14 10:35         ` Amir Goldstein
2017-07-14 10:53           ` Miklos Szeredi
2017-07-14 11:17             ` Amir Goldstein
2017-07-24  8:33               ` Miklos Szeredi
2017-08-07 16:12                 ` Amir Goldstein
2017-07-11 12:58 ` [PATCH 08/10] ovl: do not cleanup directory and whiteout index entries Amir Goldstein
2017-07-11 12:58 ` [PATCH 09/10] ovl: verify origin of merge dir lower Amir Goldstein
2017-07-11 12:58 ` [PATCH 10/10] ovl: follow decoded origin file handle of merge dir Amir Goldstein
2017-07-13 20:19   ` Miklos Szeredi
2017-07-14  7:42     ` Amir Goldstein
2017-07-14 10:21       ` Miklos Szeredi
2017-07-14 10:58         ` Amir Goldstein
2017-07-24  8:48           ` Miklos Szeredi
2017-07-24 12:14             ` Amir Goldstein
2017-07-25 11:33               ` Miklos Szeredi
2017-07-25 14:30                 ` Amir Goldstein
2017-07-25 15:16                   ` Miklos Szeredi
2017-07-25 22:19                     ` Amir Goldstein
2017-07-26  8:47                       ` Miklos Szeredi
2017-07-26  8:51                         ` Miklos Szeredi
2017-07-26  8:54                           ` Miklos Szeredi
2017-07-26 19:06                             ` Amir Goldstein
2017-07-11 19:32 ` [PATCH 00/10] overlayfs assorted fixes for v4.13 Amir Goldstein

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=1499777923-29410-7-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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