Go to file
Darrick J. Wong 44c100ded1 fsdax: dax_unshare_iter needs to copy entire blocks
[ Upstream commit 50793801fc ]

The code that copies data from srcmap to iomap in dax_unshare_iter is
very very broken, which bfoster's recent fsx changes have exposed.

If the pos and len passed to dax_file_unshare are not aligned to an
fsblock boundary, the iter pos and length in the _iter function will
reflect this unalignment.

dax_iomap_direct_access always returns a pointer to the start of the
kmapped fsdax page, even if its pos argument is in the middle of that
page.  This is catastrophic for data integrity when iter->pos is not
aligned to a page, because daddr/saddr do not point to the same byte in
the file as iter->pos.  Hence we corrupt user data by copying it to the
wrong place.

If iter->pos + iomap_length() in the _iter function not aligned to a
page, then we fail to copy a full block, and only partially populate the
destination block.  This is catastrophic for data confidentiality
because we expose stale pmem contents.

Fix both of these issues by aligning copy_pos/copy_len to a page
boundary (remember, this is fsdax so 1 fsblock == 1 base page) so that
we always copy full blocks.

We're not done yet -- there's no call to invalidate_inode_pages2_range,
so programs that have the file range mmap'd will continue accessing the
old memory mapping after the file metadata updates have completed.

Be careful with the return value -- if the unshare succeeds, we still
need to return the number of bytes that the iomap iter thinks we're
operating on.

Cc: ruansy.fnst@fujitsu.com
Fixes: d984648e42 ("fsdax,xfs: port unshare to fsdax")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/172796813328.1131942.16777025316348797355.stgit@frogsfrogsfrogs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-12-10 20:43:30 +08:00
.github/workflows deepin: CI: package arm64/loong64 daily build kernel 2024-12-10 20:41:37 +08:00
Documentation crypto: iaa - Fix some errors in IAA documentation 2024-12-10 20:43:26 +08:00
LICENSES LICENSES: Add the copyleft-next-0.3.1 license 2022-11-08 15:44:01 +01:00
arch deepin_x86_desktop_defconfig: Set NETFILTER_XT_MATCH_CGROUP as module 2024-12-10 20:43:27 +08:00
block blk-rq-qos: fix crash on rq_qos_wait vs. rq_qos_wake_function race 2024-12-10 20:42:56 +08:00
certs certs: Reference revocation list for all keyrings 2023-08-17 20:12:41 +00:00
crypto crypto: iaa - Add support for deflate-iaa compression algorithm 2024-12-10 20:43:24 +08:00
deepin deepin: OWNERS: Add winnscode to reviewers 2024-12-10 20:42:15 +08:00
drivers mlxsw: spectrum_ipip: Fix memory leak when changing remote IPv6 address 2024-12-10 20:43:30 +08:00
fs fsdax: dax_unshare_iter needs to copy entire blocks 2024-12-10 20:43:30 +08:00
include iomap: share iomap_unshare_iter predicate code with fsdax 2024-12-10 20:43:30 +08:00
init deepin: kbuild: Reapply support for CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 2024-12-10 20:41:15 +08:00
io_uring io_uring/sqpoll: close race on waiting for sqring entries 2024-12-10 20:42:56 +08:00
ipc sysctl: treewide: drop unused argument ctl_table_root::set_ownership(table) 2024-12-10 20:40:09 +08:00
kernel bpf: Fix out-of-bounds write in trie_get_next_key() 2024-12-10 20:43:29 +08:00
lib lib/Kconfig.debug: fix grammar in RUST_BUILD_ASSERT_ALLOW 2024-12-10 20:43:01 +08:00
mm mm: khugepaged: fix the arguments order in khugepaged_collapse_file trace point 2024-12-10 20:43:07 +08:00
net bpf, test_run: Fix LIVE_FRAME frame update after a page has been recycled 2024-12-10 20:43:30 +08:00
rust rust: sync: require `T: Sync` for `LockedBy::access` 2024-12-10 20:42:28 +08:00
samples samples/bpf: Fix compilation errors with cf-protection option 2024-12-10 20:41:53 +08:00
scripts kconfig: qconf: fix buffer overflow in debug links 2024-12-10 20:42:34 +08:00
security selinux: improve error checking in sel_write_load() 2024-12-10 20:43:12 +08:00
sound ASoC: cs42l51: Fix some error handling paths in cs42l51_probe() 2024-12-10 20:43:29 +08:00
tools selftests/bpf: Add bpf_percpu_obj_{new,drop}() macro in bpf_experimental.h 2024-12-10 20:43:29 +08:00
usr initramfs: Encode dependency on KBUILD_BUILD_TIMESTAMP 2023-06-06 17:54:49 +09:00
virt KVM: Use dedicated mutex to protect kvm_usage_count to avoid deadlock 2024-12-10 20:42:04 +08:00
.clang-format iommu: Add for_each_group_device() 2023-05-23 08:15:51 +02:00
.cocciconfig
.get_maintainer.ignore get_maintainer: add Alan to .get_maintainer.ignore 2022-08-20 15:17:44 -07:00
.gitattributes .gitattributes: set diff driver for Rust source code files 2023-05-31 17:48:25 +02:00
.gitignore Remove *.orig pattern from .gitignore 2024-12-10 20:42:03 +08:00
.mailmap 20 hotfixes. 12 are cc:stable and the remainder address post-6.5 issues 2023-10-24 09:52:16 -10:00
.rustfmt.toml rust: add `.rustfmt.toml` 2022-09-28 09:02:20 +02:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS fs: Remove NTFS classic 2024-12-10 20:39:15 +08:00
Kbuild Kbuild updates for v6.1 2022-10-10 12:00:45 -07:00
Kconfig kbuild: ensure full rebuild when the compiler is updated 2020-05-12 13:28:33 +09:00
MAINTAINERS crypto: iaa - Add Intel IAA Compression Accelerator crypto driver core 2024-12-10 20:43:24 +08:00
Makefile Linux 6.6.59 2024-12-10 20:43:13 +08:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06: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.