Skip to contentSkip to conversation

reiser4: fix filesystem init error path.

PATCH In review Ivan Shapovalov 2 participants 6 messages Sep 13, 2015 – Sep 14, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 reiser4: fix filesystem init error path.

---
 fs/reiser4/super_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/reiser4/super_ops.c +1 -1
index 76c16af..2afaf3b 100644
@@ -623,9 +623,9 @@ static int fill_super(struct super_block *super, void *data, int silent)
 	reiser4_done_txnmgr(&sbinfo->tmgr);
  failed_init_read_super:
  failed_init_super_data:
+ failed_init_csum_tfm:
 	reiser4_done_fs_info(super);
  failed_init_sinfo:
- failed_init_csum_tfm:
 	reiser4_exit_context(&ctx);
 	return result;
 }
Signature · 1 line
2.5.1
#1 lore raw

PATCH 2/3 reiser4: fix reiser4_init_csum_tfm() error path; return real (negative) error code.

---

This is responsible for the oops on mount reported by Jose (also experienced by me). The problem is that IS_ERR() works only for negative error codes, so somewhere in the VFS an error path is incorrectly not taken.

 fs/reiser4/checksum.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/reiser4/checksum.c +7 -5
index a5052b0..73d40f0 100644
@@ -4,11 +4,13 @@
 
 int reiser4_init_csum_tfm(struct crypto_shash **tfm)
 {
-	*tfm = crypto_alloc_shash("crc32c", 0, 0);
-	if (IS_ERR(*tfm)) {
-		*tfm = NULL;
-		return 1;
-	}
+	struct crypto_shash *new_tfm;
+
+	new_tfm = crypto_alloc_shash("crc32c", 0, 0);
+	if (IS_ERR(new_tfm))
+		return PTR_ERR(new_tfm);
+
+	*tfm = new_tfm;
 	return 0;
 }
 
Signature · 1 line
2.5.1
#2 lore raw

Re: [PATCH 2/3] reiser4: fix reiser4_init_csum_tfm() error path; return real (negative) error code.

OK.
Thanks!

Quoted 33 lines · Ivan Shapovalov

---

This is responsible for the oops on mount reported by Jose (also experienced by me). The problem is that IS_ERR() works only for negative error codes, so somewhere in the VFS an error path is incorrectly not taken.

  fs/reiser4/checksum.c | 12 +++++++-----
  1 file changed, 7 insertions(+), 5 deletions(-)
fs/reiser4/checksum.c +7 -5
index a5052b0..73d40f0 100644
@@ -4,11 +4,13 @@
 
  int reiser4_init_csum_tfm(struct crypto_shash **tfm)
  {
-	*tfm = crypto_alloc_shash("crc32c", 0, 0);
-	if (IS_ERR(*tfm)) {
-		*tfm = NULL;
-		return 1;
-	}
+	struct crypto_shash *new_tfm;
+
+	new_tfm = crypto_alloc_shash("crc32c", 0, 0);
+	if (IS_ERR(new_tfm))
+		return PTR_ERR(new_tfm);
+
+	*tfm = new_tfm;
  	return 0;
  }
 
#3 lore raw

PATCH 3/3 reiser4: report an error on checksum engine load failure.

In reply to Ivan Shapovalov

It is apparently not possible to specify explicit module dependencies. For well-formed setups this is not a problem because crypto_alloc_shash() uses request_module() internally, but if one needs reiser4, say, in initramfs, then the checksum module must be added manually.

---
 fs/reiser4/checksum.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/reiser4/checksum.c +3 -1
index 73d40f0..2a35f42 100644
@@ -7,8 +7,10 @@ int reiser4_init_csum_tfm(struct crypto_shash **tfm)
 	struct crypto_shash *new_tfm;
 
 	new_tfm = crypto_alloc_shash("crc32c", 0, 0);
-	if (IS_ERR(new_tfm))
+	if (IS_ERR(new_tfm)) {
+		warning("intelfx-81", "Could not load crc32c driver");
 		return PTR_ERR(new_tfm);
+	}
 
 	*tfm = new_tfm;
 	return 0;
Signature · 1 line
2.5.1
#4 lore raw

Re: [PATCH 3/3] reiser4: report an error on checksum engine load failure.

OK

Quoted 27 lines · Ivan Shapovalov

It is apparently not possible to specify explicit module dependencies. For well-formed setups this is not a problem because crypto_alloc_shash() uses request_module() internally, but if one needs reiser4, say, in initramfs, then the checksum module must be added manually.

---
  fs/reiser4/checksum.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
fs/reiser4/checksum.c +3 -1
index 73d40f0..2a35f42 100644
@@ -7,8 +7,10 @@ int reiser4_init_csum_tfm(struct crypto_shash **tfm)
  	struct crypto_shash *new_tfm;
 
  	new_tfm = crypto_alloc_shash("crc32c", 0, 0);
-	if (IS_ERR(new_tfm))
+	if (IS_ERR(new_tfm)) {
+		warning("intelfx-81", "Could not load crc32c driver");
  		return PTR_ERR(new_tfm);
+	}
 
  	*tfm = new_tfm;
  	return 0;
#5 lore raw
In reply to Ivan Shapovalov

OK

Quoted 20 lines · Ivan Shapovalov
---
  fs/reiser4/super_ops.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/reiser4/super_ops.c +1 -1
index 76c16af..2afaf3b 100644
@@ -623,9 +623,9 @@ static int fill_super(struct super_block *super, void *data, int silent)
  	reiser4_done_txnmgr(&sbinfo->tmgr);
   failed_init_read_super:
   failed_init_super_data:
+ failed_init_csum_tfm:
  	reiser4_done_fs_info(super);
   failed_init_sinfo:
- failed_init_csum_tfm:
  	reiser4_exit_context(&ctx);
  	return result;
  }