Skip to contentSkip to conversation

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

PATCH Superseded Julian Sun 2 participants 4 messages Sep 6, 2024 – Sep 9, 2024 VFS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Julian Sun

author
#0 lore raw

PATCH 1/1 vfs: return -EOVERFLOW in generic_remap_checks() when overflow check fails

Keep it consistent with the handling of the same check within generic_copy_file_checks().
Also, returning -EOVERFLOW in this case is more appropriate.

---
 fs/remap_range.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/remap_range.c +1 -1
index 28246dfc8485..97171f2191aa 100644
@@ -46,7 +46,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in,
 
 	/* Ensure offsets don't wrap. */
 	if (pos_in + count < pos_in || pos_out + count < pos_out)
-		return -EINVAL;
+		return -EOVERFLOW;
 
 	size_in = i_size_read(inode_in);
 	size_out = i_size_read(inode_out);
Signature · 1 line
2.39.2
reviewer
#1 lore raw
Quoted 5 lines · Julian Sun

Keep it consistent with the handling of the same check within generic_copy_file_checks().
Also, returning -EOVERFLOW in this case is more appropriate.

Well, you were already changing this condition here [1] so maybe just update the errno in that patch as well? No need to generate unnecessary patch conflicts...

[1] https://lore.kernel.org/all/20240905121545.ma6zdnswn5s72byb@quack3

Honza

Quoted 20 lines
---
 fs/remap_range.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/remap_range.c +1 -1
index 28246dfc8485..97171f2191aa 100644
@@ -46,7 +46,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in,
 
 	/* Ensure offsets don't wrap. */
 	if (pos_in + count < pos_in || pos_out + count < pos_out)
-		return -EINVAL;
+		return -EOVERFLOW;
 
 	size_in = i_size_read(inode_in);
 	size_out = i_size_read(inode_out);
Signature · 1 line
2.39.2
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#2 lore raw

On Fri, 2024-09-06 at 12:29 +0200, Jan Kara wrote:

Sure, I will include this patch in the patch set for the next version. But I think it maybe deserves a separate patch, rather than being integrated into the original patch?

Quoted 19 lines · Julian Sun
Quoted 5 lines

Keep it consistent with the handling of the same check within generic_copy_file_checks().
Also, returning -EOVERFLOW in this case is more appropriate.

Well, you were already changing this condition here [1] so maybe just update the errno in that patch as well? No need to generate unnecessary patch conflicts...

[1] https://lore.kernel.org/all/20240905121545.ma6zdnswn5s72byb@quack3

                                                                Honza

Quoted 4 lines

---
 fs/remap_range.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 5 lines
fs/remap_range.c +0 -0
index 28246dfc8485..97171f2191aa 100644
@@ -46,7 +46,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in,
Quoted 11 lines


        /* Ensure offsets don't wrap. */
        if (pos_in + count < pos_in || pos_out + count < pos_out) -               return -EINVAL;
+               return -EOVERFLOW;

        size_in = i_size_read(inode_in);
        size_out = i_size_read(inode_out);

Signature · 1 line
2.39.2

Thanks,

Signature · 1 line
Julian Sun <[email protected]>
reviewer
#3 lore raw
Quoted 5 lines · Julian Sun

On Fri, 2024-09-06 at 12:29 +0200, Jan Kara wrote:

Sure, I will include this patch in the patch set for the next version. But I think it maybe deserves a separate patch, rather than being integrated into the original patch?

Yes, probably a separate patch makes sense.

Honza

Quoted 40 lines
Quoted 20 lines · Julian Sun
Quoted 5 lines

Keep it consistent with the handling of the same check within generic_copy_file_checks().
Also, returning -EOVERFLOW in this case is more appropriate.

Well, you were already changing this condition here [1] so maybe just update the errno in that patch as well? No need to generate unnecessary patch conflicts...

[1] https://lore.kernel.org/all/20240905121545.ma6zdnswn5s72byb@quack3

                                                                Honza

Quoted 4 lines

---
 fs/remap_range.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 5 lines
fs/remap_range.c +0 -0
index 28246dfc8485..97171f2191aa 100644
@@ -46,7 +46,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in,
Quoted 11 lines


        /* Ensure offsets don't wrap. */
        if (pos_in + count < pos_in || pos_out + count < pos_out) -               return -EINVAL;
+               return -EOVERFLOW;

        size_in = i_size_read(inode_in);
        size_out = i_size_read(inode_out);

Signature · 1 line
2.39.2

Thanks,

Signature · 1 line
Julian Sun <[email protected]>
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR