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]
Date:   Thu, 15 Dec 2022 10:31:29 +0800
From:   "lihaoxiang (F)" <lihaoxiang9@...wei.com>
To:     <tytso@....edu>
CC:     <linux-ext4@...r.kernel.org>,
        Zhiqiang Liu <liuzhiqiang26@...wei.com>,
        <linfeilong@...wei.com>, <louhongxiang@...wei.com>
Subject: Re: [PATCH] debugfs:fix repeated output problem with logdump

Hi professor Tytso, we found that logdump has the problem to print circulately in the case which logs area are full of valid transactions. We propose the final solution as follow:
---------------------------------------------------------------------
Date: Thu, 10 Nov 2022 17:09:20 +0800
Subject: [PATCH] debugfs:fix repeated output problem with logdump

Currently, the module of logdump with parameter -O or -On might fall
into printing duplicate transactions circulately.

In fact, it would exit when it check the no magic number in transaction's
block head. But sometimes there hasn't no magic number block spanning
the whole log area so it cause the multi meaningless loop until a new no
magic block was founded.

We record the first blocknr of logs for comparing this value to that when
it meet the block again. If the comparison is equal then it exit immediately.

Signed-off-by: lihaoxiang <lihaoxiang9@...wei.com>
---
 debugfs/logdump.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index 614414e5..a6d03f5c 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -376,11 +376,14 @@ static void dump_journal(char *cmdname, FILE *out_file,
 	journal_header_t	*header;
 	tid_t			transaction;
 	unsigned int		blocknr = 0;
+	unsigned int		last_blocknr;
+	unsigned int		first_transaction_blocknr;
 	int			fc_done;
 	__u64			total_len;
 	__u32			maxlen;
 	int64_t			cur_counts = 0;
 	bool			exist_no_magic = false;
+	bool			reverse_flag = false;

 	/* First, check to see if there's an ext2 superblock header */
 	retval = read_journal_block(cmdname, source, 0, buf, 2048);
@@ -470,10 +473,22 @@ static void dump_journal(char *cmdname, FILE *out_file,
 			blocknr = 1;
 	}

+	first_transaction_blocknr = blocknr;
+	last_blocknr = blocknr - 1;
+
 	while (1) {
 		if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts))
 			break;

+		if (last_blocknr != (blocknr - 1))
+			reverse_flag = true;
+		last_blocknr = blocknr;
+
+		if ((blocknr == first_transaction_blocknr) && reverse_flag) {
+			fprintf(out_file, "Dump all %lld journal records.\n", cur_counts);
+			break;
+		}
+
 		retval = read_journal_block(cmdname, source,
 				((ext2_loff_t) blocknr) * blocksize,
 				buf, blocksize);
-- 
2.37.0.windows.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ