From: Amit Prasad <amit@modal.com>
To: djbw@kernel.org, brauner@kernel.org, viro@zeniv.linux.org.uk
Cc: jack@suse.cz, willy@infradead.org, djwong@kernel.org,
alison.schofield@intel.com, nvdimm@lists.linux.dev,
linux-fsdevel@vger.kernel.org, Amit Prasad <amit@modal.com>
Subject: [PATCH 0/2] fsdax: handle short dax_direct_access() ranges
Date: Tue, 1 Dec 2026 17:43:22 +0000 [thread overview]
Message-ID: <20261201174324.5991-1-amit@modal.com> (raw)
dax_direct_access() can map fewer pages than asked for. Earlier changes
caused fsdax's copy-on-write, unshare, and dedupe paths to skip a check
of the returned length, which can result in reads and writes outside
the mapped range.
For example, dm-stripe ends each range at a chunk boundary, so
dax_direct_access() returns a shorter length than requested. On a
filesystem with both DAX and reflinks (e.g. XFS) mounted on the striped
device, fsdax doesn't respect the size of the mapped range, and can
read/write outside of it.
The first patch minimally fixes this and explicitly returns an error.
The second patch makes the above scenario work properly across such
short device boundaries.
Tested against v7.4-rc5 in a VM with two pmem devices, beneath a
dm-stripe target with 64 KiB chunks, XFS with reflink=1 and dax=always:
- unpatched: funshare of a reflinked file corrupts it, and a dedupe of
two identical files reports them as different.
- patch 1: funshare fails with EINVAL without corrupting the file.
- patches 1-2: funshare succeeds and dedupe returns a valid result.
Reproducer (needs a 1 GiB pmem device, e.g. memmap=1G!4G):
dmsetup create stripe \
--table "0 2097152 striped 2 128 /dev/pmem0 0 /dev/pmem0 1048576"
mkfs.xfs -f -m reflink=1 /dev/mapper/stripe
mount -o dax=always /dev/mapper/stripe /mnt
head -c 1M /dev/urandom > /mnt/a
cp --reflink=always /mnt/a /mnt/b
xfs_io -c "funshare 0 1m" /mnt/b
cmp /mnt/a /mnt/b
Creates a dm-stripe across two chunks of a pmem device. Unpatched, cmp
reports differences. With patch 1, funshare fails with EINVAL, and
with both patches cmp shows the files are identical.
The patch was reproduced and fixed with the help of an AI coding
assistant (Claude Opus 5.5).
Amit Prasad (2):
fsdax: check the mapped length for all dax_iomap_direct_access()
callers
fsdax: iterate over short dax_direct_access() ranges
fs/dax.c | 118 +++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 85 insertions(+), 33 deletions(-)
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.54.0
next reply other threads:[~2026-12-01 17:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:43 Amit Prasad [this message]
2026-12-01 17:43 ` [PATCH 1/2] fsdax: check the mapped length for all dax_iomap_direct_access() callers Amit Prasad
2026-12-01 17:43 ` [PATCH 2/2] fsdax: iterate over short dax_direct_access() ranges Amit Prasad
2026-12-01 18:00 ` sashiko-bot
2026-12-01 18:37 ` Amit Prasad
2026-12-01 18:33 ` [PATCH 0/2] fsdax: handle " Amit Prasad
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=20261201174324.5991-1-amit@modal.com \
--to=amit@modal.com \
--cc=alison.schofield@intel.com \
--cc=brauner@kernel.org \
--cc=djbw@kernel.org \
--cc=djwong@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.