Find a file
Dave Chinner f2e812c152 xfs: don't use current->journal_info
syzbot reported an ext4 panic during a page fault where found a
journal handle when it didn't expect to find one. The structure
it tripped over had a value of 'TRAN' in the first entry in the
structure, and that indicates it tripped over a struct xfs_trans
instead of a jbd2 handle.

The reason for this is that the page fault was taken during a
copy-out to a user buffer from an xfs bulkstat operation. XFS uses
an "empty" transaction context for bulkstat to do automated metadata
buffer cleanup, and so the transaction context is valid across the
copyout of the bulkstat info into the user buffer.

We are using empty transaction contexts like this in XFS to reduce
the risk of failing to release objects we reference during the
operation, especially during error handling. Hence we really need to
ensure that we can take page faults from these contexts without
leaving landmines for the code processing the page fault to trip
over.

However, this same behaviour could happen from any other filesystem
that triggers a page fault or any other exception that is handled
on-stack from within a task context that has current->journal_info
set.  Having a page fault from some other filesystem bounce into XFS
where we have to run a transaction isn't a bug at all, but the usage
of current->journal_info means that this could result corruption of
the outer task's journal_info structure.

The problem is purely that we now have two different contexts that
now think they own current->journal_info. IOWs, no filesystem can
allow page faults or on-stack exceptions while current->journal_info
is set by the filesystem because the exception processing might use
current->journal_info itself.

If we end up with nested XFS transactions whilst holding an empty
transaction, then it isn't an issue as the outer transaction does
not hold a log reservation. If we ignore the current->journal_info
usage, then the only problem that might occur is a deadlock if the
exception tries to take the same locks the upper context holds.
That, however, is not a problem that setting current->journal_info
would solve, so it's largely an irrelevant concern here.

IOWs, we really only use current->journal_info for a warning check
in xfs_vm_writepages() to ensure we aren't doing writeback from a
transaction context. Writeback might need to do allocation, so it
can need to run transactions itself. Hence it's a debug check to
warn us that we've done something silly, and largely it is not all
that useful.

So let's just remove all the use of current->journal_info in XFS and
get rid of all the potential issues from nested contexts where
current->journal_info might get misused by another filesystem
context.

Reported-by: syzbot+cdee56dbcdf0096ef605@syzkaller.appspotmail.com
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Mark Tinguely <mark.tinguely@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
2024-03-25 10:21:01 +05:30
arch EFI fixes for v6.9 #2 2024-03-24 13:54:06 -07:00
block
certs
crypto RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
Documentation A set of x86 fixes: 2024-03-24 11:13:56 -07:00
drivers EFI fixes for v6.9 #2 2024-03-24 13:54:06 -07:00
fs xfs: don't use current->journal_info 2024-03-25 10:21:01 +05:30
include powerpc updates for 6.9 #2 2024-03-23 09:21:26 -07:00
init RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
io_uring
ipc
kernel dma-mapping fixes for Linux 6.9 2024-03-24 10:45:31 -07:00
lib hardening fixes for v6.9-rc1 2024-03-23 08:43:21 -07:00
LICENSES
mm RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
net Including fixes from CAN, netfilter, wireguard and IPsec. 2024-03-21 14:50:39 -07:00
rust Kbuild updates for v6.9 2024-03-21 14:41:00 -07:00
samples
scripts LoongArch changes for v6.9 2024-03-22 10:22:45 -07:00
security
sound sound fixes #2 for 6.9-rc2 2024-03-22 09:44:19 -07:00
tools RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
usr
virt
.clang-format
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS RISC-V Patches for the 6.9 Merge Window 2024-03-22 10:41:13 -07:00
Makefile Linux 6.9-rc1 2024-03-24 14:10:05 -07:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.