Message ID | 20190526061100.21761-9-amir73il@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fixes for major copy_file_range() issues | expand |
On Sun, May 26, 2019 at 09:10:59AM +0300, Amir Goldstein wrote: > The access limit checks on input file range in generic_remap_checks() > are redundant because the input file size is guarantied to be within guaranteed ^^^^^^^^^^ > limits and pos+len are already checked to be within input file size. > > Beyond the fact that the check cannot fail, if it would have failed, > it could return -EFBIG for input file range error. There is no precedent > for that. -EFBIG is returned in syscalls that would change file length. > > Signed-off-by: Amir Goldstein <amir73il@gmail.com> > --- > mm/filemap.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/mm/filemap.c b/mm/filemap.c > index 1852fbf08eeb..7e1aa36d57a2 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -3000,10 +3000,6 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, > return -EINVAL; > count = min(count, size_in - (uint64_t)pos_in); > > - ret = generic_access_check_limits(file_in, pos_in, &count); I suspect you could fold generic_access_check_limits into its only caller, then... --D > - if (ret) > - return ret; > - > ret = generic_write_check_limits(file_out, pos_out, &count); > if (ret) > return ret; > -- > 2.17.1 >
diff --git a/mm/filemap.c b/mm/filemap.c index 1852fbf08eeb..7e1aa36d57a2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3000,10 +3000,6 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, return -EINVAL; count = min(count, size_in - (uint64_t)pos_in); - ret = generic_access_check_limits(file_in, pos_in, &count); - if (ret) - return ret; - ret = generic_write_check_limits(file_out, pos_out, &count); if (ret) return ret;
The access limit checks on input file range in generic_remap_checks() are redundant because the input file size is guarantied to be within limits and pos+len are already checked to be within input file size. Beyond the fact that the check cannot fail, if it would have failed, it could return -EFBIG for input file range error. There is no precedent for that. -EFBIG is returned in syscalls that would change file length. Signed-off-by: Amir Goldstein <amir73il@gmail.com> --- mm/filemap.c | 4 ---- 1 file changed, 4 deletions(-)