Skip to contentSkip to conversation

erofs: option validation in remount

PATCH New Chengguang Xu 2 participants 4 messages Sep 11, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs: option validation in remount

Add option validation in remount. After this patch, remount can change recognized options, and for unknown options remount will fail and report error.

Signed-off-by Chengguang Xu <cgxu519 at gmx.com>
---
 drivers/staging/erofs/super.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/staging/erofs/super.c +17 -0
index 1aec509c805f..8bab077381ad 100644
@@ -625,10 +625,27 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
 
 static int erofs_remount(struct super_block *sb, int *flags, char *data)
 {
+	struct erofs_sb_info *sbi = EROFS_SB(sb);
+	struct erofs_fault_info *ffi = &sbi->fault_info;
+	unsigned int orig_mount_opt = sbi->mount_opt;
+	unsigned int orig_inject_rate = ffi->inject_rate;
+	int err;
+
 	BUG_ON(!sb_rdonly(sb));
 
+	err = parse_options(sb, data);
+	if (err)
+		goto out;
+
 	*flags |= MS_RDONLY;
 	return 0;
+
+out:
+	if (ffi->inject_rate != orig_inject_rate)
+		erofs_build_fault_attr(sbi, orig_inject_rate);
+	sbi->mount_opt = orig_mount_opt;
+
+	return err;
 }
 
 const struct super_operations erofs_sops = {
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 erofs: option validation in remount

Hi Chengguang,

Thanks for your patch.

The patch title should be "staging: erofs: " since erofs is still in staging.

The same as your previous patch "erofs: surround fault_injection ralted option parsing using CONFIG_EROFS_FAULT_INJECTION".

Quoted 25 lines · Chengguang Xu

Add option validation in remount. After this patch, remount can change recognized options, and for unknown options remount will fail and report error.

Signed-off-by Chengguang Xu <cgxu519 at gmx.com>
---
 drivers/staging/erofs/super.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/staging/erofs/super.c +6 -0
index 1aec509c805f..8bab077381ad 100644
@@ -625,10 +625,27 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
 
 static int erofs_remount(struct super_block *sb, int *flags, char *data)
 {
+	struct erofs_sb_info *sbi = EROFS_SB(sb);
+	struct erofs_fault_info *ffi = &sbi->fault_info;
+	unsigned int orig_mount_opt = sbi->mount_opt;
+	unsigned int orig_inject_rate = ffi->inject_rate;
+	int err;
+
 	BUG_ON(!sb_rdonly(sb));
 

drivers/staging/erofs/super.c static int erofs_show_options(struct seq_file *seq, struct dentry *root) · line 645

Quoted 10 lines
drivers/staging/erofs/super.c +8 -0
+	err = parse_options(sb, data);
+	if (err)
+		goto out;
+
 	*flags |= MS_RDONLY;
 	return 0;
+
+out:
+	if (ffi->inject_rate != orig_inject_rate)
+		erofs_build_fault_attr(sbi, orig_inject_rate);

Currently should be with "#ifdef CONFIG_EROFS_FAULT_INJECTION"? and have you tried to compile without EROFS_FAULT_INJECTION?

Thanks,
Gao Xiang

Quoted 7 lines
drivers/staging/erofs/super.c +3 -0
+	sbi->mount_opt = orig_mount_opt;
+
+	return err;
 }
 
 const struct super_operations erofs_sops = {
author
#2 lore raw

PATCH 1/1 erofs: option validation in remount

Quoted 5 lines · Gao Xiang

Hi Chengguang,

Thanks for your patch.

The patch title should be "staging: erofs: " since erofs is still in staging.

Hi Xiang,

Thanks for your review. I'll add the tag from next version.

Quoted 30 lines

The same as your previous patch "erofs: surround fault_injection ralted option parsing using CONFIG_EROFS_FAULT_INJECTION".

Quoted 25 lines · Chengguang Xu

Add option validation in remount. After this patch, remount can change recognized options, and for unknown options remount will fail and report error.

Signed-off-by Chengguang Xu <cgxu519 at gmx.com>
---
  drivers/staging/erofs/super.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/staging/erofs/super.c +6 -0
index 1aec509c805f..8bab077381ad 100644
@@ -625,10 +625,27 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
 
  static int erofs_remount(struct super_block *sb, int *flags, char *data)
  {
+	struct erofs_sb_info *sbi = EROFS_SB(sb);
+	struct erofs_fault_info *ffi = &sbi->fault_info;
+	unsigned int orig_mount_opt = sbi->mount_opt;
+	unsigned int orig_inject_rate = ffi->inject_rate;
+	int err;
+
  	BUG_ON(!sb_rdonly(sb));
 
Quoted 12 lines

drivers/staging/erofs/super.c static int erofs_show_options(struct seq_file *seq, struct dentry *root) · line 645

Quoted 10 lines
drivers/staging/erofs/super.c +8 -0
+	err = parse_options(sb, data);
+	if (err)
+		goto out;
+
  	*flags |= MS_RDONLY;
  	return 0;
+
+out:
+	if (ffi->inject_rate != orig_inject_rate)
+		erofs_build_fault_attr(sbi, orig_inject_rate);

Currently should be with "#ifdef CONFIG_EROFS_FAULT_INJECTION"? and have you tried to compile without EROFS_FAULT_INJECTION?

Ah, It must be enabled in my environment.
However, adding the macro in every calling place seems not convenient, I'll try to do some code cleanups, so please hold on this and previous patch for
a moment, I'll resend those in a patch set.

Thanks,
Chengguang

#3 lore raw

PATCH 1/1 erofs: option validation in remount

Hi Chengguang,

Quoted 50 lines · On 2018/9/11 23:37, cgxu519 wrote:
Quoted 5 lines · Gao Xiang

Hi Chengguang,

Thanks for your patch.

The patch title should be "staging: erofs: " since erofs is still in staging.

Hi Xiang,

Thanks for your review. I'll add the tag from next version.

Quoted 32 lines

The same as your previous patch "erofs: surround fault_injection ralted option parsing using CONFIG_EROFS_FAULT_INJECTION".

Quoted 27 lines · Chengguang Xu

Add option validation in remount. After this patch, remount can change recognized options, and for unknown options remount will fail and report error.

Signed-off-by Chengguang Xu <cgxu519 at gmx.com>

---
? drivers/staging/erofs/super.c | 17 +++++++++++++++++ ? 1 file changed, 17 insertions(+)

drivers/staging/erofs/super.c +9 -0
index 1aec509c805f..8bab077381ad 100644
@@ -625,10 +625,27 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root)
 ? ? static int erofs_remount(struct super_block *sb, int *flags, char *data)
 ? {
+??? struct erofs_sb_info *sbi = EROFS_SB(sb);
+??? struct erofs_fault_info *ffi = &sbi->fault_info;
+??? unsigned int orig_mount_opt = sbi->mount_opt;
+??? unsigned int orig_inject_rate = ffi->inject_rate;
+??? int err;
+
 ????? BUG_ON(!sb_rdonly(sb));
 ? +??? err = parse_options(sb, data);
+??? if (err)
+??????? goto out;
+
Quoted 8 lines

drivers/staging/erofs/super.c static int erofs_show_options(struct seq_file *seq, struct dentry *root) · line 643

Quoted 6 lines
drivers/staging/erofs/super.c +4 -0
 ????? *flags |= MS_RDONLY;
 ????? return 0;
+
+out:
+??? if (ffi->inject_rate != orig_inject_rate)
+??????? erofs_build_fault_attr(sbi, orig_inject_rate);

Currently should be with "#ifdef CONFIG_EROFS_FAULT_INJECTION"? and have you tried to compile without EROFS_FAULT_INJECTION?

Quoted 5 lines

Ah, It must be enabled in my environment.
However, adding the macro in every calling place seems not convenient, I'll try to do some code cleanups, so please hold on this and previous patch for a moment, I'll resend those in a patch set.

OK, that is fine. look forword to your next patch. ;)

Thanks,
Gao Xiang

Quoted 3 lines

Thanks,
Chengguang