diff mbox series

[v2] vfs: return -EOVERFLOW in generic_remap_checks() when overflow check fails

Message ID 20240927065325.2628648-1-sunjunchao2870@gmail.com (mailing list archive)
State New
Headers show
Series [v2] vfs: return -EOVERFLOW in generic_remap_checks() when overflow check fails | expand

Commit Message

Julian Sun Sept. 27, 2024, 6:53 a.m. UTC
Keep the errno value consistent with the equivalent check in
generic_copy_file_checks() that returns -EOVERFLOW, which feels like the
more appropriate value to return compared to the overly generic -EINVAL.

Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
 fs/remap_range.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Kara Sept. 27, 2024, 10:55 a.m. UTC | #1
On Fri 27-09-24 14:53:25, Julian Sun wrote:
> Keep the errno value consistent with the equivalent check in
> generic_copy_file_checks() that returns -EOVERFLOW, which feels like the
> more appropriate value to return compared to the overly generic -EINVAL.
> 
> Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>

Makes sense to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/remap_range.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/remap_range.c b/fs/remap_range.c
> index 6fdeb3c8cb70..1333f67530c0 100644
> --- a/fs/remap_range.c
> +++ b/fs/remap_range.c
> @@ -47,7 +47,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in,
>  	/* Ensure offsets don't wrap. */
>  	if (check_add_overflow(pos_in, count, &tmp) ||
>  	    check_add_overflow(pos_out, count, &tmp))
> -		return -EINVAL;
> +		return -EOVERFLOW;
>  
>  	size_in = i_size_read(inode_in);
>  	size_out = i_size_read(inode_out);
> -- 
> 2.39.2
>
Christian Brauner Sept. 27, 2024, 11:27 a.m. UTC | #2
On Fri, 27 Sep 2024 14:53:25 +0800, Julian Sun wrote:
> Keep the errno value consistent with the equivalent check in
> generic_copy_file_checks() that returns -EOVERFLOW, which feels like the
> more appropriate value to return compared to the overly generic -EINVAL.
> 
> 

Applied to the vfs.misc.v6.13 branch of the vfs/vfs.git tree.
Patches in the vfs.misc.v6.13 branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc.v6.13

[1/1] vfs: return -EOVERFLOW in generic_remap_checks() when overflow check fails
      https://git.kernel.org/vfs/vfs/c/53070eb468a2
Darrick J. Wong Sept. 27, 2024, 3:27 p.m. UTC | #3
On Fri, Sep 27, 2024 at 02:53:25PM +0800, Julian Sun wrote:
> Keep the errno value consistent with the equivalent check in
> generic_copy_file_checks() that returns -EOVERFLOW, which feels like the
> more appropriate value to return compared to the overly generic -EINVAL.
> 
> Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>

Looks better this time :)
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/remap_range.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/remap_range.c b/fs/remap_range.c
> index 6fdeb3c8cb70..1333f67530c0 100644
> --- a/fs/remap_range.c
> +++ b/fs/remap_range.c
> @@ -47,7 +47,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in,
>  	/* Ensure offsets don't wrap. */
>  	if (check_add_overflow(pos_in, count, &tmp) ||
>  	    check_add_overflow(pos_out, count, &tmp))
> -		return -EINVAL;
> +		return -EOVERFLOW;
>  
>  	size_in = i_size_read(inode_in);
>  	size_out = i_size_read(inode_out);
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/fs/remap_range.c b/fs/remap_range.c
index 6fdeb3c8cb70..1333f67530c0 100644
--- a/fs/remap_range.c
+++ b/fs/remap_range.c
@@ -47,7 +47,7 @@  static int generic_remap_checks(struct file *file_in, loff_t pos_in,
 	/* Ensure offsets don't wrap. */
 	if (check_add_overflow(pos_in, count, &tmp) ||
 	    check_add_overflow(pos_out, count, &tmp))
-		return -EINVAL;
+		return -EOVERFLOW;
 
 	size_in = i_size_read(inode_in);
 	size_out = i_size_read(inode_out);