From: Vinicius Peixoto <vpeixoto@lkcamp.dev>
To: syzbot+8512f3dbd96253ffbe27@syzkaller.appspotmail.com
Cc: jack@suse.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
mark@fasheh.com, ocfs2-devel@lists.linux.dev,
syzkaller-bugs@googlegroups.com, tytso@mit.edu,
~lkcamp/discussion@lists.sr.ht
Subject: Re: [syzbot] [ext4?] [ocfs2?] kernel BUG in jbd2_cleanup_journal_tail
Date: Mon, 26 Aug 2024 01:22:54 -0300 [thread overview]
Message-ID: <d673f289-2385-4949-ac80-f3a502d4deb2@lkcamp.dev> (raw)
In-Reply-To: <00000000000070a66706204e7698@google.com>
Hi all,
I noticed this report from syzbot when going through the preliminary
tasks for the Linux Kernel Mentorship Program, and thought I'd take a
stab at solving it. I apologize in advance for any mistakes as I'm still
very new to kernel development. Either way, here's my analysis:
From what I can tell by looking at the reproducer from syzbot, it is
trying to mount a file filled with bogus data as an ocfs2 disk, and this
is triggering an assertion in jbd2_cleanup_journal_tail, which in turn
causes a panic.
The problematic call stack goes roughly like this:
mount_bdev
-> ofcs2_mount_volume
-> ofcs2_check_volume
-> ofcs2_journal_load
-> jbd2_journal_load
-> journal_reset (fails)
Since the disk data is bogus, journal_reset fails with -EINVAL ("JBD2:
Journal too short (blocks 2-1024)"); this leaves journal->j_head ==
NULL. However, jbd2_journal_load clears the JBD2_ABORT flag right before
calling journal_reset. This leads to a problem later when
ofcs2_mount_volume tries to flush the journal as part of the cleanup
when aborting the mount operation:
-> ofcs2_mount_volume (error; goto out_system_inodes)
-> ofcs2_journal_shutdown
-> jbd2_journal_flush
-> jbd2_cleanup_journal_tail (J_ASSERT fails)
This failure happens because of the following code:
if (is_journal_aborted(journal))
return -EIO;
if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr))
return 1;
J_ASSERT(blocknr != 0);
Since JBD2_ABORT was cleared in jbd2_journal_load earlier, we enter
jbd2_journal_get_log_tail, which will set *blocknr = journal->j_head
(which is NULL) and then trigger the assertion, causing a panic.
I confirmed that setting the JBD2_ABORT flag in journal_reset before
returning -EINVAL fixes the problem:
static int journal_reset(journal_t *journal)
journal_fail_superblock(journal);
+ journal->j_flags |= JBD2_ABORT;
return -EINVAL;
You can find a proper patch file + the syzbot re-test result in [1].
However, I'm not entirely sure whether this is the correct decision, and
I wanted to confirm that this is an appropriate solution before sending
a proper patch to the mailing list.
Thanks in advance,
Vinicius
[1] https://syzkaller.appspot.com/bug?extid=8512f3dbd96253ffbe27
next prev parent reply other threads:[~2024-08-26 4:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 0:00 syzbot
2024-08-26 3:10 ` [syzbot] jbd2: set JBD2_ABORT upon journal_reset failure syzbot
2024-08-26 4:22 ` Vinicius Peixoto [this message]
2024-08-26 13:32 ` [syzbot] [ext4?] [ocfs2?] kernel BUG in jbd2_cleanup_journal_tail Theodore Ts'o
2024-08-26 19:34 ` Joel Becker
2024-08-28 12:28 ` Julian Sun
2024-08-28 10:54 ` Jan Kara
2024-08-28 11:55 ` Julian Sun
[not found] <b0d4c21a-33f4-4e94-83e4-88c9e1f1c468@lkcamp.dev>
2024-08-26 3:32 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d673f289-2385-4949-ac80-f3a502d4deb2@lkcamp.dev \
--to=vpeixoto@lkcamp.dev \
--cc=jack@suse.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=syzbot+8512f3dbd96253ffbe27@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tytso@mit.edu \
--cc=~lkcamp/discussion@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®