From: sashiko-bot@kernel.org
To: jianyungao89@gmail.com
Cc: nvdimm@lists.linux.dev
Subject: Re: [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare()
Date: Sat, 10 Oct 2026 02:24:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-166211@kernel.org> (raw)
In-Reply-To: <20261010021010.19575-1-jianyungao89@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] dax: dax_range_compare_iter() passes absolute offset instead of size
--
commit a30afa39f06e5d921895421d92a26f1823e65cbd
Author: Jianyun Gao <jianyungao89@gmail.com>
dax: fix wrong error code returned from dax_dedupe_file_range_compare()
This commit modifies dax_dedupe_file_range_compare() to return the actual
error status from dax_range_compare_iter() rather than leaking a positive
return value. This prevents vfs_dedupe_file_range() from misinterpreting
an error as a success.
> diff --git a/fs/dax.c b/fs/dax.c
> index 08adeaed2baf1..97b6212bfa898 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -2254,7 +2254,7 @@ int dax_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
> status = dax_range_compare_iter(&src_iter, &dst_iter,
> min(src_iter.len, dst_iter.len), same);
> if (status < 0)
> - return ret;
> + return status;
[Severity: High]
Does returning status here expose a bug in dax_range_compare_iter()
where it passes an absolute file offset as a relative size?
Looking at dax_range_compare_iter():
fs/dax.c:dax_range_compare_iter() {
...
ret = dax_iomap_direct_access(smap, pos1, ALIGN(pos1 + len, PAGE_SIZE),
&saddr, NULL);
...
ret = dax_iomap_direct_access(dmap, pos2, ALIGN(pos2 + len, PAGE_SIZE),
&daddr, NULL);
...
}
The third argument to dax_iomap_direct_access() is a size, but it is
passed ALIGN(pos1 + len, PAGE_SIZE) and ALIGN(pos2 + len, PAGE_SIZE),
which are absolute file offsets rounded up to the page size.
For large file offsets, this requests a massive access size. The underlying
dax_direct_access() call computes nr_pages = PHYS_PFN(size), translating
the absolute offset into a huge page count.
This will overflow a 32-bit unsigned int for offsets >= 2TB. Additionally,
driver-level bad block scans like __pmem_direct_access() will iterate over
this massively inflated range.
If any hardware poison exists anywhere in the remainder of the device,
it can spuriously return -EHWPOISON. By propagating this error status to
userspace, will this cause deduplication to spuriously fail?
> src_iter.status = dst_iter.status = status;
> }
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010021010.19575-1-jianyungao89@gmail.com?part=1
next prev parent reply other threads:[~2026-10-10 2:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 2:10 [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare() jianyungao89
2026-10-10 2:24 ` sashiko-bot [this message]
2026-10-10 6:28 ` Jianyun Gao
2026-10-12 9:47 ` Jan Kara
2026-10-12 13:40 ` Markus Elfring
2026-10-12 14:13 ` Jianyun Gao
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=sashiko-outbox-166211@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jianyungao89@gmail.com \
--cc=nvdimm@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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.