lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 3 Dec 2022 07:11:07 +0000
From:   Aditya Garg <gargaditya08@...e.com>
To:     "willy@...radead.org" <willy@...radead.org>,
        "ira.weiny@...el.com" <ira.weiny@...el.com>,
        "axboe@...nel.dk" <axboe@...nel.dk>,
        "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
        "bvanassche@....org" <bvanassche@....org>,
        "keescook@...omium.org" <keescook@...omium.org>,
        "songmuchun@...edance.com" <songmuchun@...edance.com>,
        "slava@...eyko.com" <slava@...eyko.com>,
        "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v2] hfsplus: Add module parameter to enable force writes

From: Aditya Garg <gargaditya08@...e.com>

This patch enables users to permanently enable writes of HFS+ locked
and/or journaled volumes using a module parameter.

Why module parameter?
Reason being, its not convenient to manually mount the volume with force
everytime. There are use cases which are fine with force enabling writes
on journaled volumes. I've seen many on various online forums and I am one
of them as well.

Isn't it risky?
Yes obviously it is, as the driver itself warns users for the same. But
any user using the parameter obviously shall be well aware of the risks
involved. To be honest, I've been writing on a 100Gb journaled volume for
a few days, including both large and small files, and haven't faced any
corruption yet.

Signed-off-by: Aditya Garg <gargaditya08@...e.com>
---
v2 :- Add Documentation and split long lines across multiple lines.
 Documentation/filesystems/hfsplus.rst | 15 +++++++-
 fs/hfsplus/super.c                    | 49 +++++++++++++++++++++------
 2 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/Documentation/filesystems/hfsplus.rst b/Documentation/filesystems/hfsplus.rst
index f02f4f5fc..85feca0b0 100644
--- a/Documentation/filesystems/hfsplus.rst
+++ b/Documentation/filesystems/hfsplus.rst
@@ -46,13 +46,26 @@ When mounting an HFSPlus filesystem, the following options are accepted:
 	Do not decompose file name characters.
 
   force
-	Used to force write access to volumes that are marked as journalled
+	Used to force write access to volumes that are marked as journaled
 	or locked.  Use at your own risk.
 
   nls=cccc
 	Encoding to use when presenting file names.
 
 
+Module Parameters
+=================
+
+The HFSPlus module supports the following module parameters:
+
+  force_journaled_rw=n, force_locked_rw=n
+	Used to force enable writes on volumes marked as journaled/locked.
+	Its risky to use them as they may cause data corruption.
+	Accepted values:
+		0 (default): Disables writes
+		1: Enables writes
+
+
 References
 ==========
 
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 122ed89eb..91812c4c3 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -24,6 +24,16 @@ static void hfsplus_free_inode(struct inode *inode);
 #include "hfsplus_fs.h"
 #include "xattr.h"
 
+static unsigned int force_journaled_rw;
+module_param(force_journaled_rw, uint, 0644);
+MODULE_PARM_DESC(force_journaled_rw, "Force enable writes on Journaled HFS+ volumes. "
+		"([0] = disabled, 1 = enabled)");
+
+static unsigned int force_locked_rw;
+module_param(force_locked_rw, uint, 0644);
+MODULE_PARM_DESC(force_locked_rw, "Force enable writes on locked HFS+ volumes. "
+		"([0] = disabled, 1 = enabled)");
+
 static int hfsplus_system_read_inode(struct inode *inode)
 {
 	struct hfsplus_vh *vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
@@ -346,14 +356,22 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
 			/* nothing */
 		} else if (vhdr->attributes &
 				cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
-			pr_warn("filesystem is marked locked, leaving read-only.\n");
-			sb->s_flags |= SB_RDONLY;
-			*flags |= SB_RDONLY;
+			if (force_locked_rw) {
+				pr_warn("filesystem is marked locked, but writes have been force enabled.\n");
+			} else {
+				pr_warn("filesystem is marked locked, leaving read-only.\n");
+				sb->s_flags |= SB_RDONLY;
+				*flags |= SB_RDONLY;
+			}
 		} else if (vhdr->attributes &
 				cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
-			pr_warn("filesystem is marked journaled, leaving read-only.\n");
-			sb->s_flags |= SB_RDONLY;
-			*flags |= SB_RDONLY;
+			if (force_journaled_rw) {
+				pr_warn("filesystem is marked journaled, but writes have been force enabled.\n");
+			} else {
+				pr_warn("filesystem is marked journaled, leaving read-only.\n");
+				sb->s_flags |= SB_RDONLY;
+				*flags |= SB_RDONLY;
+			}
 		}
 	}
 	return 0;
@@ -459,12 +477,23 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
 	} else if (test_and_clear_bit(HFSPLUS_SB_FORCE, &sbi->flags)) {
 		/* nothing */
 	} else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
-		pr_warn("Filesystem is marked locked, mounting read-only.\n");
-		sb->s_flags |= SB_RDONLY;
+		if (force_locked_rw) {
+			pr_warn("Filesystem is marked locked, but writes have been force enabled.\n");
+		} else {
+			pr_warn("Filesystem is marked locked, mounting read-only.\n");
+			sb->s_flags |= SB_RDONLY;
+		}
 	} else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) &&
 			!sb_rdonly(sb)) {
-		pr_warn("write access to a journaled filesystem is not supported, use the force option at your own risk, mounting read-only.\n");
-		sb->s_flags |= SB_RDONLY;
+		if (force_journaled_rw) {
+			pr_warn("write access to a journaled filesystem is "
+				"not supported, but has been force enabled.\n");
+		} else {
+			pr_warn("write access to a journaled filesystem is "
+				"not supported, use the force option at your "
+				"own risk, mounting read-only.\n");
+			sb->s_flags |= SB_RDONLY;
+		}
 	}
 
 	err = -EINVAL;
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ