All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: jianyungao89@gmail.com
Cc: "open list:FILESYSTEM DIRECT ACCESS (DAX)" <nvdimm@lists.linux.dev>
Subject: Re: [PATCH v3] dax: fix wrong error code returned from dax_dedupe_file_range_compare()
Date: Thu, 15 Oct 2026 14:53:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-173003@kernel.org> (raw)
In-Reply-To: <20261015143426.17620-1-jianyungao89@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] fsdax: incorrect size parameter in dax_range_compare_iter causes massive direct access requests
--

commit 65ff21563702a9036c338f4961a061d5c576d038
Author: Jianyun Gao <jianyungao89@gmail.com>

dax: fix wrong error code returned from dax_dedupe_file_range_compare()

This commit fixes a bug in dax_dedupe_file_range_compare() where a positive
return value was incorrectly propagated on failure. It now correctly returns
the negative error code from dax_range_compare_iter().

Link: https://lore.kernel.org/lkml/20261012144925.6728-1-jianyungao89@gmail.com/

> 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]
By correctly propagating the error code here, does this patch now expose a
bug in dax_range_compare_iter() that will break dedupe for large offsets?

Looking at dax_range_compare_iter() in fs/dax.c, it appears to pass an
absolute end offset instead of a length as the size parameter to
dax_iomap_direct_access():

static int dax_range_compare_iter(...)
{
	...
	ret = dax_iomap_direct_access(smap, pos1, ALIGN(pos1 + len, PAGE_SIZE),
				      &saddr, NULL);
	...
}

When dax_iomap_direct_access() receives this size parameter, it converts it
via PHYS_PFN() and interprets the massive absolute offset as a relative
length:

fs/dax.c:dax_iomap_direct_access() {
	...
	length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size),
				   DAX_ACCESS, kaddr, pfnp);
	...
}

This requests an out-of-bounds mapping length from the underlying block
driver (up to pos1 + len instead of just len), which typically fails with
-EINVAL or -EIO for offsets that exceed device bounds.

Since this patch changes the behavior from a silent pseudo-success to an
explicit failure, will standard deduplication at non-zero offsets now
consistently fail when dax_range_compare_iter() erroneously asks for an
enormous number of pages?

>  		src_iter.status = dst_iter.status = status;
>  	}
>  	return ret;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015143426.17620-1-jianyungao89@gmail.com?part=1

  reply	other threads:[~2026-10-15 14:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 14:34 [PATCH v3] dax: fix wrong error code returned from dax_dedupe_file_range_compare() jianyungao89
2026-10-15 14:53 ` sashiko-bot [this message]
2026-10-16  1:23 ` Alison Schofield

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-173003@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.