Skip to content

Commit

Permalink
ovl: force read-only sb on failure to create index dir
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Amir Goldstein authored and Miklos Szeredi committed Jul 15, 2020
1 parent a888db3 commit 470c156
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 470c156

Please sign in to comment.