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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <174553064727.1160289.10466952108264302412.stgit@frogsfrogsfrogs>
Date: Thu, 24 Apr 2025 14:40:47 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 3/3] fuse2fs: make "ro" behavior consistent with the kernel

From: Darrick J. Wong <djwong@...nel.org>

Make the behavior of the "ro" mount option consistent with the kernel:
User programs cannot change the files in the filesystem, but the driver
itself is allowed to update the filesystem metadata.  This means that ro
mounts can recover the journal.

Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
 misc/fuse2fs.c |   27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)


diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 991a9f6733148d..f974171d3e726d 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -3739,6 +3739,7 @@ enum {
 
 static struct fuse_opt fuse2fs_opts[] = {
 	FUSE2FS_OPT("ro",		ro,			1),
+	FUSE2FS_OPT("rw",		ro,			0),
 	FUSE2FS_OPT("errors=panic",	panic_on_error,		1),
 	FUSE2FS_OPT("minixdf",		minixdf,		1),
 	FUSE2FS_OPT("fakeroot",		fakeroot,		1),
@@ -3784,13 +3785,12 @@ static int fuse2fs_opt_proc(void *data, const char *arg,
 	"    -V   --version   print version\n"
 	"\n"
 	"fuse2fs options:\n"
-	"    -o ro                  read-only mount\n"
 	"    -o errors=panic        dump core on error\n"
 	"    -o minixdf             minix-style df\n"
 	"    -o fakeroot            pretend to be root for permission checks\n"
 	"    -o no_default_opts     do not include default fuse options\n"
 	"    -o offset=<bytes>      similar to mount -o offset=<bytes>, mount the partition starting at <bytes>\n"
-	"    -o norecovery	    don't replay the journal (implies ro)\n"
+	"    -o norecovery          don't replay the journal\n"
 	"    -o fuse2fs_debug       enable fuse2fs debugging\n"
 	"\n",
 			outargs->argv[0]);
@@ -3838,7 +3838,8 @@ int main(int argc, char *argv[])
 	char *logfile;
 	char extra_args[BUFSIZ];
 	int ret = 0;
-	int flags = EXT2_FLAG_64BITS | EXT2_FLAG_THREADS | EXT2_FLAG_EXCLUSIVE;
+	int flags = EXT2_FLAG_64BITS | EXT2_FLAG_THREADS | EXT2_FLAG_EXCLUSIVE |
+		    EXT2_FLAG_RW;
 
 	memset(&fctx, 0, sizeof(fctx));
 	fctx.magic = FUSE2FS_MAGIC;
@@ -3857,11 +3858,6 @@ int main(int argc, char *argv[])
 	else
 		fctx.shortdev = fctx.device;
 
-	if (fctx.norecovery)
-		fctx.ro = 1;
-	if (fctx.ro)
-		log_printf(&fctx, "%s\n", _("Mounting read-only."));
-
 #ifdef ENABLE_NLS
 	setlocale(LC_MESSAGES, "");
 	setlocale(LC_CTYPE, "");
@@ -3892,8 +3888,6 @@ int main(int argc, char *argv[])
 
 	/* Start up the fs (while we still can use stdout) */
 	ret = 2;
-	if (!fctx.ro)
-		flags |= EXT2_FLAG_RW;
 	char options[50];
 	sprintf(options, "offset=%lu", fctx.offset);
 	err = ext2fs_open2(fctx.device, options, flags, 0, 0, unix_io_manager,
@@ -3912,7 +3906,9 @@ int main(int argc, char *argv[])
 		if (fctx.norecovery) {
 			log_printf(&fctx, "%s\n",
  _("Mounting read-only without recovering journal."));
-		} else if (!fctx.ro) {
+			fctx.ro = 1;
+			global_fs->flags &= ~EXT2_FLAG_RW;
+		} else {
 			log_printf(&fctx, "%s\n", _("Recovering journal."));
 			err = ext2fs_run_ext3_journal(&global_fs);
 			if (err) {
@@ -3923,14 +3919,10 @@ int main(int argc, char *argv[])
 			}
 			ext2fs_clear_feature_journal_needs_recovery(global_fs->super);
 			ext2fs_mark_super_dirty(global_fs);
-		} else {
-			err_printf(&fctx, "%s\n",
- _("Journal needs recovery; running `e2fsck -E journal_only' is required."));
-			goto out;
 		}
 	}
 
-	if (!fctx.ro) {
+	if (global_fs->flags & EXT2_FLAG_RW) {
 		if (ext2fs_has_feature_journal(global_fs->super))
 			log_printf(&fctx, "%s\n",
  _("Writing to the journal is not supported."));
@@ -3979,6 +3971,9 @@ int main(int argc, char *argv[])
 	if (fctx.no_default_opts == 0)
 		fuse_opt_add_arg(&args, extra_args);
 
+	if (fctx.ro)
+		fuse_opt_add_arg(&args, "-oro");
+
 	if (fctx.fakeroot) {
 #ifdef HAVE_MOUNT_NODEV
 		fuse_opt_add_arg(&args,"-onodev");


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ