debugfs: add journal header checks in logdump

Addresses-Coverity-Bug: 1431466
Addresses-Coverity-Bug: 1432478
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2021-02-12 12:04:21 -05:00
parent 10f9b11b76
commit bd9ac48c92

View File

@ -406,7 +406,12 @@ static void dump_journal(char *cmdname, FILE *out_file,
"Journal superblock magic number invalid!\n");
return;
}
blocksize = be32_to_cpu(jsb->s_blocksize);
if (be32_to_cpu(jsb->s_blocksize) != blocksize) {
fprintf(out_file,
"Journal block size invalid: %u\n",
be32_to_cpu(jsb->s_blocksize));
return;
}
transaction = be32_to_cpu(jsb->s_sequence);
blocknr = be32_to_cpu(jsb->s_start);
@ -690,6 +695,11 @@ static void dump_revoke_block(FILE *out_file, char *buf,
header = (jbd2_journal_revoke_header_t *) buf;
offset = sizeof(jbd2_journal_revoke_header_t);
max = be32_to_cpu(header->r_count);
if (max > jsb->s_blocksize) {
fprintf(out_file, "Revoke block's r_count invalid: %u\b",
max);
max = jsb->s_blocksize;
}
while (offset < max) {
if (tag_size == sizeof(__u32)) {