Re: [PATCH v2] dax: fix wrong error code returned from dax_dedupe_file_range_compare()
From: Darrick J. Wong
Date: Mon Oct 12 2026 - 12:53:23 EST
On Mon, Oct 12, 2026 at 10:49:24PM +0800, jianyungao89@xxxxxxxxx wrote:
> From: Jianyun Gao <jianyungao89@xxxxxxxxx>
>
> When dax_range_compare_iter() returns a negative error code (e.g. -EIO),
> dax_dedupe_file_range_compare() incorrectly returns 'ret' which holds the
> positive return value from iomap_iter() indicating more iterations remain.
> This positive value leaks to the caller, where vfs_dedupe_file_range()
> interprets it as success (bytes_deduped = len), causing userspace to
> incorrectly believe deduplication completed.
>
> Return 'status' instead to propagate the actual error code.
>
> Fixes: 39eb05112987 ("dax: advance the iomap_iter on dedupe range")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Jianyun Gao <jianyungao89@xxxxxxxxx>
> Reviewed-by: Jan Kara <jack@xxxxxxx>
Seems fine to me,
Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
--D
> ---
>
> Changes in v2:
> - Add Fixes tag and Cc stable
> - Add Reviewed-by tag from Jan Kara
>
> v1: Link: https://lore.kernel.org/lkml/20261010021010.19575-1-jianyungao89@xxxxxxxxx/
>
> fs/dax.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/dax.c b/fs/dax.c
> index 6ba50142eeb2..1f6a4fbb97bd 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -2261,7 +2261,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;
> src_iter.status = dst_iter.status = status;
> }
> return ret;
> --
> 2.34.1
>