No description
Find a file
Dave Chinner 54a37e5d07 iomap: write iomap validity checks
[ Upstream commit d7b6404116 ]

A recent multithreaded write data corruption has been uncovered in
the iomap write code. The core of the problem is partial folio
writes can be flushed to disk while a new racing write can map it
and fill the rest of the page:

writeback			new write

allocate blocks
  blocks are unwritten
submit IO
.....
				map blocks
				iomap indicates UNWRITTEN range
				loop {
				  lock folio
				  copyin data
.....
IO completes
  runs unwritten extent conv
    blocks are marked written
				  <iomap now stale>
				  get next folio
				}

Now add memory pressure such that memory reclaim evicts the
partially written folio that has already been written to disk.

When the new write finally gets to the last partial page of the new
write, it does not find it in cache, so it instantiates a new page,
sees the iomap is unwritten, and zeros the part of the page that
it does not have data from. This overwrites the data on disk that
was originally written.

The full description of the corruption mechanism can be found here:

https://lore.kernel.org/linux-xfs/20220817093627.GZ3600936@dread.disaster.area/

To solve this problem, we need to check whether the iomap is still
valid after we lock each folio during the write. We have to do it
after we lock the page so that we don't end up with state changes
occurring while we wait for the folio to be locked.

Hence we need a mechanism to be able to check that the cached iomap
is still valid (similar to what we already do in buffered
writeback), and we need a way for ->begin_write to back out and
tell the high level iomap iterator that we need to remap the
remaining write range.

The iomap needs to grow some storage for the validity cookie that
the filesystem provides to travel with the iomap. XFS, in
particular, also needs to know some more information about what the
iomap maps (attribute extents rather than file data extents) to for
the validity cookie to cover all the types of iomaps we might need
to validate.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-25 16:21:31 +02:00
arch ARM: 9381/1: kasan: clear stale stack poison 2024-05-17 11:56:10 +02:00
block blk-iocost: avoid out of bounds shift 2024-05-17 11:56:07 +02:00
certs
crypto Revert "crypto: api - Disallow identical driver names" 2024-05-02 16:29:27 +02:00
Documentation dt-bindings: iio: health: maxim,max30102: fix compatible check 2024-05-17 11:56:19 +02:00
drivers mmc: core: Add HS400 tuning in HS400es initialization 2024-05-25 16:21:30 +02:00
fs iomap: write iomap validity checks 2024-05-25 16:21:31 +02:00
include iomap: write iomap validity checks 2024-05-25 16:21:31 +02:00
init rust: make mutually exclusive with CFI_CLANG 2024-05-02 16:29:27 +02:00
io_uring io_uring: Fix io_cqring_wait() not restoring sigmask on get_timespec64() failure 2024-04-27 17:07:04 +02:00
ipc
kernel timers: Rename del_timer() to timer_delete() 2024-05-17 11:56:13 +02:00
lib dyndbg: fix old BUG_ON in >control parser 2024-05-17 11:56:20 +02:00
LICENSES
mm mm/hugetlb: fix DEBUG_LOCKS_WARN_ON(1) when dissolve_free_hugetlb_folio() 2024-05-17 11:56:24 +02:00
net nfsd: don't allow nfsd threads to be signalled. 2024-05-25 16:21:30 +02:00
rust rust: macros: fix soundness issue in module! macro 2024-05-17 11:56:17 +02:00
samples work around gcc bugs with 'asm goto' with outputs 2024-02-23 09:12:28 +01:00
scripts btf, scripts: rust: drop is_rust_module.sh 2024-05-17 11:56:17 +02:00
security KEYS: trusted: Fix memory leak in tpm2_key_encode() 2024-05-25 16:21:30 +02:00
sound ASoC: ti: davinci-mcasp: Fix race condition during probe 2024-05-17 11:56:20 +02:00
tools perf unwind-libdw: Handle JIT-generated DSOs properly 2024-05-17 11:56:10 +02:00
usr
virt KVM: Always flush async #PF workqueue when vCPU is being destroyed 2024-04-03 15:19:25 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: add leah to 6.1 MAINTAINERS file 2024-05-17 11:56:16 +02:00
Makefile Linux 6.1.91 2024-05-17 11:56:25 +02: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 Restructured Text 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.