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] [thread-next>] [day] [month] [year] [list]
Message-ID: <174786678745.1385354.4539253023336874014.stgit@frogsfrogsfrogs>
Date: Wed, 21 May 2025 15:45:54 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 03/10] fuse2fs: close filesystem from op_destroy

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

Close the filesystem from op_destroy so that we know the block device
has been closed before the umount call completes.

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


diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 25d32a69729362..ec3d684085d975 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -675,6 +675,20 @@ static int check_inum_access(struct fuse2fs *ff, ext2_ino_t ino, int mask)
 	return -EACCES;
 }
 
+static void close_fs(struct fuse2fs *ff)
+{
+	errcode_t err;
+
+	if (!ff->fs)
+		return;
+
+	err = ext2fs_close(ff->fs);
+	if (err)
+		err_printf(ff, "%s\n", error_message(err));
+
+	ff->fs = NULL;
+}
+
 static void op_destroy(void *p EXT2FS_ATTR((unused)))
 {
 	struct fuse_context *ctxt = fuse_get_context();
@@ -717,7 +731,10 @@ static void op_destroy(void *p EXT2FS_ATTR((unused)))
 		char uuid[UUID_STR_SIZE];
 
 		uuid_unparse(fs->super->s_uuid, uuid);
+		close_fs(ff);
 		log_printf(ff, "%s %s.\n", _("unmounting filesystem"), uuid);
+	} else {
+		close_fs(ff);
 	}
 }
 
@@ -4723,12 +4740,7 @@ int main(int argc, char *argv[])
  _("Mount failed while opening filesystem.  Check dmesg(1) for details."));
 		fflush(orig_stderr);
 	}
-	if (fctx.fs) {
-		err = ext2fs_close(fctx.fs);
-		if (err)
-			com_err(argv[0], err, "while closing fs");
-		fctx.fs = NULL;
-	}
+	close_fs(&fctx);
 	if (fctx.device)
 		free(fctx.device);
 	fuse_opt_free_args(&args);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ