Skip to content

Commit

Permalink
ovl: Prevent rw remount when it should be ro mount
Browse files Browse the repository at this point in the history
Overlayfs should be mounted read-only when upper-fs is read-only or nonexistent.
But now it can be remounted read-write and this can cause kernel panic.
So we should prevent read-write remount when the above situation happens.

Signed-off-by: Seunghun Lee <waydi1@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Seunghun Lee authored and Miklos Szeredi committed Jan 8, 2015
1 parent a425c03 commit 3cdf6fe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,22 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
return 0;
}

static int ovl_remount(struct super_block *sb, int *flags, char *data)
{
struct ovl_fs *ufs = sb->s_fs_info;

if (!(*flags & MS_RDONLY) &&
(!ufs->upper_mnt || (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY)))
return -EROFS;

return 0;
}

static const struct super_operations ovl_super_operations = {
.put_super = ovl_put_super,
.statfs = ovl_statfs,
.show_options = ovl_show_options,
.remount_fs = ovl_remount,
};

enum {
Expand Down

0 comments on commit 3cdf6fe

Please sign in to comment.