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>] [day] [month] [year] [list]
Date:   Thu, 2 Feb 2023 22:20:55 +0800
From:   Baokun Li <libaokun1@...wei.com>
To:     <linux-ext4@...r.kernel.org>
CC:     <tytso@....edu>, <adilger.kernel@...ger.ca>, <jack@...e.cz>,
        <yi.zhang@...wei.com>, <yangerkun@...wei.com>,
        <yukuai3@...wei.com>, <libaokun1@...wei.com>
Subject: [PATCH] debugfs: check first journal block type when a tail-to-head reversal occurs in logdump

When logs are dumped, if the last description block in the journal area
contains the first journal block as the data block, logs may be repeatedly
printed or not completely printed. After the journal replay, we always
restart logging from the first journal block. In this case, there are the
following two cases:

1) If start == first, the first block is always skipped due to reversal.
Therefore, the condition (blocknr == first_transaction_blocknr) for
determining repeated printing does not take effect. As a result, logs are
repeatedly printed.

2) If start != first, we will traverse backwards from the first non-data
block after the last journal data block in the last description block, and
the logs from the first journal block to this block will not be printed.
That is, the dump log is incomplete.

To solve this problem, we only need to check the type of the first log
block when reversal occurs. If it is a non-log data block, we should
continue to dump directly from the first block.

Signed-off-by: Baokun Li <libaokun1@...wei.com>
---
 debugfs/logdump.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index b103cf1e..0019b6cf 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -740,6 +740,18 @@ static void dump_descriptor_block(FILE *out_file,
 
 	} while (!(tag_flags & JBD2_FLAG_LAST_TAG));
 
+	/* When a tail-to-head reversal occurs, we need to check whether
+	 * there is a log that starts from the beginning again.
+	 */
+	if (*blockp > blocknr) {
+		journal_header_t first_header = {0};
+
+		read_journal_block("logdump", source, blocksize,
+				   (char *)&first_header, sizeof(journal_header_t));
+		if ((be32_to_cpu(first_header.h_magic) == JBD2_MAGIC_NUMBER) &&
+		    (be32_to_cpu(first_header.h_blocktype) == JBD2_DESCRIPTOR_BLOCK))
+			blocknr = 1;
+	}
 	*blockp = blocknr;
 }
 
-- 
2.31.1

Powered by blists - more mailing lists