Skip to contentSkip to conversation

ovl: Prevent rw remount when it should be ro mount

PATCH In review Seunghun Lee 3 participants 4 messages Jan 1, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ovl: Prevent rw remount when it should be ro mount

Overlayfs should be mounted read-only when upper fs is r/o or nonexistend. But now it can be remounted read-write and this can causes kernel panic. So we should prevent read-write remount when the above situation.

---
 fs/overlayfs/super.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/overlayfs/super.c +8 -0
index 84f3144..1faa5e5 100644
@@ -522,6 +522,14 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
 	return 0;
 }
 
+static int squashfs_remount(struct super_block *sb, int *flags, char *data)
+{
+	if (!ufs->upper_mnt || (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY))
+		*flags |= MS_RDONLY;
+
+	return 0;
+}
+
 static const struct super_operations ovl_super_operations = {
 	.put_super	= ovl_put_super,
 	.statfs		= ovl_statfs,
Signature · 1 line
2.1.3
#1 lore raw
Quoted 5 lines · Seunghun Lee

Overlayfs should be mounted read-only when upper fs is r/o or nonexistend. But now it can be remounted read-write and this can causes kernel panic. So we should prevent read-write remount when the above situation.

This patch makes zero sense, did you use the wrong diff?

Quoted 31 lines
---
 fs/overlayfs/super.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/overlayfs/super.c +8 -1
index 84f3144..1faa5e5 100644
@@ -522,6 +522,14 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
        return 0;
 }
 
+static int squashfs_remount(struct super_block *sb, int *flags, char *data)
+{
+       if (!ufs->upper_mnt || (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY))
+               *flags |= MS_RDONLY;
+
+       return 0;
+}
+
 static const struct super_operations ovl_super_operations = {
        .put_super      = ovl_put_super,
        .statfs         = ovl_statfs,
--

2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
Thanks,
//richard
#2 lore raw
Quoted 9 lines · Richard Weinberger
Quoted 5 lines · Seunghun Lee

Overlayfs should be mounted read-only when upper fs is r/o or nonexistend. But now it can be remounted read-write and this can causes kernel panic. So we should prevent read-write remount when the above situation.

This patch makes zero sense, did you use the wrong diff?

Hmm, was also my 1st thoughts when I saw squashfs_remount() in overlayfs code.

- Sedat -

Quoted 41 lines
Quoted 26 lines
---
 fs/overlayfs/super.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/overlayfs/super.c +8 -1
index 84f3144..1faa5e5 100644
@@ -522,6 +522,14 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
        return 0;
 }
 
+static int squashfs_remount(struct super_block *sb, int *flags, char *data)
+{
+       if (!ufs->upper_mnt || (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY))
+               *flags |= MS_RDONLY;
+
+       return 0;
+}
+
 static const struct super_operations ovl_super_operations = {
        .put_super      = ovl_put_super,
        .statfs         = ovl_statfs,
--

2.1.3

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 7 lines · Sedat Dilek
Quoted 5 lines · Richard Weinberger
Quoted 4 lines · Seunghun Lee

Overlayfs should be mounted read-only when upper fs is r/o or nonexistend. But now it can be remounted read-write and this can causes kernel panic. So we should prevent read-write remount when the above situation.

Quoted 47 lines
Quoted 3 lines
Quoted 1 line

This patch makes zero sense, did you use the wrong diff?

Hmm, was also my 1st thoughts when I saw squashfs_remount() in overlayfs code.

- Sedat -

Quoted 40 lines
Quoted 26 lines
---
 fs/overlayfs/super.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/overlayfs/super.c +8 -1
index 84f3144..1faa5e5 100644
@@ -522,6 +522,14 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
        return 0;
 }
 
+static int squashfs_remount(struct super_block *sb, int *flags, char *data)
+{
+       if (!ufs->upper_mnt || (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY))
+               *flags |= MS_RDONLY;
+
+       return 0;
+}
+
 static const struct super_operations ovl_super_operations = {
        .put_super      = ovl_put_super,
        .statfs         = ovl_statfs,
--

2.1.3

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Sorry, I sent wrong patch.

I will resend it.

Thanks.