diff options
author | Seunghun Lee <waydi1@gmail.com> | 2015-01-02 12:26:49 -0500 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2015-01-08 08:47:21 -0500 |
commit | 3cdf6fe91041b3afd6761f76254f7b6cbe8020fc (patch) | |
tree | 5ec7e50d2280727e59da23dd6af59c12d3c009d2 /fs | |
parent | a425c037f3dd8a56469158ab5f37beb46402d958 (diff) |
ovl: Prevent rw remount when it should be ro mount
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/overlayfs/super.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 9e94f4acef1a..b90952f528b1 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c | |||
@@ -525,10 +525,22 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry) | |||
525 | return 0; | 525 | return 0; |
526 | } | 526 | } |
527 | 527 | ||
528 | static int ovl_remount(struct super_block *sb, int *flags, char *data) | ||
529 | { | ||
530 | struct ovl_fs *ufs = sb->s_fs_info; | ||
531 | |||
532 | if (!(*flags & MS_RDONLY) && | ||
533 | (!ufs->upper_mnt || (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY))) | ||
534 | return -EROFS; | ||
535 | |||
536 | return 0; | ||
537 | } | ||
538 | |||
528 | static const struct super_operations ovl_super_operations = { | 539 | static const struct super_operations ovl_super_operations = { |
529 | .put_super = ovl_put_super, | 540 | .put_super = ovl_put_super, |
530 | .statfs = ovl_statfs, | 541 | .statfs = ovl_statfs, |
531 | .show_options = ovl_show_options, | 542 | .show_options = ovl_show_options, |
543 | .remount_fs = ovl_remount, | ||
532 | }; | 544 | }; |
533 | 545 | ||
534 | enum { | 546 | enum { |