]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ovl: force r/o mount when index dir creation fails
authorAmir Goldstein <amir73il@gmail.com>
Tue, 19 Sep 2017 09:14:18 +0000 (12:14 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 24 Jan 2018 09:19:14 +0000 (10:19 +0100)
When work dir creation fails, a warning is emitted and overlay is
mounted r/o. Trying to remount r/w will fail with no work dir.

When index dir creation fails, the same warning is emitted and overlay
is mounted r/o, but trying to remount r/w will succeed. This may cause
unintentional corruption of filesystem consistency.

Adjust the behavior of index dir creation failure to that of work dir
creation failure and do not allow to remount r/w. User needs to state
an explicitly intention to work without an index by mounting with
option 'index=off' to allow r/w mount with no index dir.

When mounting with option 'index=on' and no 'upperdir', index is
implicitly disabled, so do not warn about no file handle support.

The issue was introduced with inodes index feature in v4.13, but this
patch will not apply cleanly before ovl_fill_super() re-factoring in
v4.15.

Fixes: 02bcd1577400 ("ovl: introduce the inodes index dir feature")
Cc: <stable@vger.kernel.org> #v4.13
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/super.c

index f3281f0b2388c48b92f1d2901692f2a168f12a5a..9aa5d32af427fbf87354d4aabfeb1197e70f03ec 100644 (file)
@@ -699,7 +699,8 @@ static int ovl_lower_dir(const char *name, struct path *path,
         * The inodes index feature needs to encode and decode file
         * handles, so it requires that all layers support them.
         */
-       if (ofs->config.index && !ovl_can_decode_fh(path->dentry->d_sb)) {
+       if (ofs->config.index && ofs->config.upperdir &&
+           !ovl_can_decode_fh(path->dentry->d_sb)) {
                ofs->config.index = false;
                pr_warn("overlayfs: fs on '%s' does not support file handles, falling back to index=off.\n", name);
        }
@@ -1268,11 +1269,16 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
                if (err)
                        goto out_free_oe;
 
-               if (!ofs->indexdir)
+               /* Force r/o mount with no index dir */
+               if (!ofs->indexdir) {
+                       dput(ofs->workdir);
+                       ofs->workdir = NULL;
                        sb->s_flags |= SB_RDONLY;
+               }
+
        }
 
-       /* Show index=off/on in /proc/mounts for any of the reasons above */
+       /* Show index=off in /proc/mounts for forced r/o mount */
        if (!ofs->indexdir)
                ofs->config.index = false;