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: <175798064968.350149.12407637697198806921.stgit@frogsfrogsfrogs>
Date: Mon, 15 Sep 2025 17:04:01 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 2/5] fuse2fs: hook library error message printing

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

Hook the com_err library so that error messages coming from libext2fs
such as:
Illegal block number passed to ext2fs_test_block_bitmap #9462 for block bitmap for /dev/sda

are actually printed with the standard "FUSE2FS (sda):" prefix.
Libraries shouldn't be printing that kind of stuff, but it is what it
is, and what it is is against the normal conventions.

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


diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 1789fbf86c7578..5e8581438aa9d7 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -200,6 +200,8 @@ static inline uint64_t round_down(uint64_t b, unsigned int align)
 
 errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs);
 
+const char *err_shortdev;
+
 #ifdef CONFIG_JBD_DEBUG		/* Enabled by configure --enable-jbd-debug */
 int journal_enable_debug = -1;
 #endif
@@ -5168,6 +5170,18 @@ static inline bool fuse2fs_want_fuseblk(const struct fuse2fs *ff)
 	return fuse2fs_on_bdev(ff);
 }
 
+static void fuse2fs_com_err_proc(const char *whoami, errcode_t code,
+				 const char *fmt, va_list args)
+{
+	fprintf(stderr, "FUSE2FS (%s): ", err_shortdev ? err_shortdev : "?");
+	if (whoami)
+		fprintf(stderr, "%s: ", whoami);
+	fprintf(stderr, "%s ", error_message(code));
+        vfprintf(stderr, fmt, args);
+	fprintf(stderr, "\n");
+	fflush(stderr);
+}
+
 int main(int argc, char *argv[])
 {
 	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
@@ -5197,6 +5211,10 @@ int main(int argc, char *argv[])
 	else
 		fctx.shortdev = fctx.device;
 
+	/* capture library error messages */
+	err_shortdev = fctx.shortdev;
+	set_com_err_hook(fuse2fs_com_err_proc);
+
 #ifdef ENABLE_NLS
 	setlocale(LC_MESSAGES, "");
 	setlocale(LC_CTYPE, "");
@@ -5390,6 +5408,8 @@ int main(int argc, char *argv[])
 		fflush(orig_stderr);
 	}
 	fuse2fs_unmount(&fctx);
+	reset_com_err_hook();
+	err_shortdev = NULL;
 	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