summaryrefslogtreecommitdiff
path: root/fs/overlayfs
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2020-07-13 17:19:43 +0300
committerMiklos Szeredi <mszeredi@redhat.com>2020-07-16 00:11:15 +0200
commit470c15636125d1591bc901f6aa2d8e4a60ed2190 (patch)
treee3f64b6e6167e7bf9f5e2483b404933b5385bd1e /fs/overlayfs
parenta888db310195400f050b89c47673f0f8babfbb41 (diff)
ovl: force read-only sb on failure to create index dir
With index feature enabled, on failure to create index dir, overlay is being mounted read-only. However, we do not forbid user to remount overlay read-write. Fix that by setting ofs->workdir to NULL, which prevents remount read-write. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r--fs/overlayfs/super.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 94ca095b2a9e..f41ef1dd384c 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1352,12 +1352,13 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs,
goto out;
}
+ /* index dir will act also as workdir */
+ iput(ofs->workdir_trap);
+ ofs->workdir_trap = NULL;
+ dput(ofs->workdir);
+ ofs->workdir = NULL;
ofs->indexdir = ovl_workdir_create(ofs, OVL_INDEXDIR_NAME, true);
if (ofs->indexdir) {
- /* index dir will act also as workdir */
- iput(ofs->workdir_trap);
- ofs->workdir_trap = NULL;
- dput(ofs->workdir);
ofs->workdir = dget(ofs->indexdir);
err = ovl_setup_trap(sb, ofs->indexdir, &ofs->indexdir_trap,
@@ -1869,7 +1870,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
if (!ovl_upper_mnt(ofs))
sb->s_flags |= SB_RDONLY;
- if (!(ovl_force_readonly(ofs)) && ofs->config.index) {
+ if (!ovl_force_readonly(ofs) && ofs->config.index) {
err = ovl_get_indexdir(sb, ofs, oe, &upperpath);
if (err)
goto out_free_oe;