[PATCH v2 4/4] ubifs: prevent remounting rw when no hmac key was given

Torben Hohn torben.hohn at linutronix.de
Fri Jun 26 07:29:07 EDT 2020


After adding readonly hmac-less authentication support,
prevent remounting the filesystem in rw mode, when
the hmac is not available.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 fs/ubifs/super.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index b41ca9ee5763..62bdef8f1ddf 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1996,6 +1996,10 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
 			ubifs_msg(c, "cannot re-mount R/W - UBI volume is R/O");
 			return -EROFS;
 		}
+		if (ubifs_authenticated(c) && !c->hash_tfm) {
+			ubifs_msg(c, "cannot re-mount R/W due to missing hmac key, for authentication");
+			return -EROFS;
+		}
 		err = ubifs_remount_rw(c);
 		if (err)
 			return err;
-- 
2.20.1




More information about the linux-mtd mailing list