From: "Theodore Ts'o" <tytso@mit.edu>
To: Dave Chinner <david@fromorbit.com>
Cc: syzbot <syzbot+cdee56dbcdf0096ef605@syzkaller.appspotmail.com>,
adilger.kernel@dilger.ca, chandan.babu@oracle.com, jack@suse.com,
linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: current->journal_info got nested! (was Re: [syzbot] [xfs?] [ext4?] general protection fault in jbd2__journal_start)
Date: Tue, 30 Jan 2024 23:58:22 -0500 [thread overview]
Message-ID: <20240131045822.GA2356784@mit.edu> (raw)
In-Reply-To: <ZbmILkfdGks57J4a@dread.disaster.area>
On Wed, Jan 31, 2024 at 10:37:18AM +1100, Dave Chinner wrote:
> It should be obvious what has happened now -
> current->journal_info is not null, so ext4 thinks it owns the
> structure attached there and panics when it finds that it isn't an
> ext4 journal handle being held there.
>
> I don't think there are any clear rules as to how filesystems can
> and can't use current->journal_info. In general, a task can't jump
> from one filesystem to another inside a transaction context like
> this, so there's never been a serious concern about nested
> current->journal_info assignments like this in the past.
>
> XFS is doing nothing wrong - we're allowed to define transaction
> contexts however we want and use current->journal_info in this way.
> However, we have to acknowledge that ext4 has also done nothing
> wrong by assuming current->journal_info should below to it if it is
> not null. Indeed, XFS does the same thing.
Nice analysis. Fundamentally the current usage of
current->journal_info assumes that a process would only be calling
into one file system at a time. But obviously that's not going to be
true in the case of one file system writing to memory which then
triggers a page fault.
As far as other potential avenues that could cause this kind of
nesting, the other one which comes to mind might be sendfile(2) --
although in general the reader side won't trigger a transaction since
the atime update tends to be done lazily.
> The question here is what to do about this? The obvious solution is
> to have save/restore semantics in the filesystem code that
> sets/clears current->journal_info, and then filesystems can also do
> the necessary "recursion into same filesystem" checks they need to
> ensure that they aren't nesting transactions in a way that can
> deadlock.
>
> Maybe there are other options - should filesystems even be allowed to
> trigger page faults when they have set current->journal_info?
Hmm, could XFS pre-fault target memory buffer for the bulkstat output
before starting its transaction? Alternatively, ext4 could do a save
of current->journal_info before starting to process the page fault,
and restore it when it is done. Both of these seem a bit hacky, and
the question is indeed, are there other avenues that might cause the
transaction context nesting, such that a more general solution is
called for?
- Ted
next prev parent reply other threads:[~2024-01-31 4:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 9:05 [syzbot] [ext4?] general protection fault in jbd2__journal_start syzbot
2024-01-30 14:52 ` [syzbot] [xfs?] " syzbot
2024-01-30 23:37 ` current->journal_info got nested! (was Re: [syzbot] [xfs?] [ext4?] general protection fault in jbd2__journal_start) Dave Chinner
2024-01-31 3:46 ` Darrick J. Wong
2024-01-31 4:58 ` Theodore Ts'o [this message]
2024-01-31 5:20 ` Matthew Wilcox
2024-01-31 5:47 ` Christoph Hellwig
2024-01-31 6:02 ` Dave Chinner
2024-01-31 6:17 ` Christoph Hellwig
2024-01-31 12:02 ` Jan Kara
2024-01-31 12:04 ` [PATCH] jbd2: user-memory-access in jbd2__journal_start Edward Adam Davis
2024-01-31 15:41 ` Jan Kara
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=20240131045822.GA2356784@mit.edu \
--to=tytso@mit.edu \
--cc=adilger.kernel@dilger.ca \
--cc=chandan.babu@oracle.com \
--cc=david@fromorbit.com \
--cc=jack@suse.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=syzbot+cdee56dbcdf0096ef605@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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;
as well as URLs for NNTP newsgroup(s).