Skip to content

Commit

Permalink
vfs: verify source area in vfs_dedupe_file_range_one()
Browse files Browse the repository at this point in the history
Call remap_verify_area() on the source file as well as the destination.

When called from vfs_dedupe_file_range() the check as already been
performed, but not so if called from layered fs (overlayfs, etc...)

Could ommit the redundant check in vfs_dedupe_file_range(), but leave for
now to get error early (for fear of breaking backward compatibility).

This call shouldn't be performance sensitive.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Dec 14, 2020
1 parent 7c03e2c commit 3078d85
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/remap_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,16 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
if (ret)
return ret;

/*
* This is redundant if called from vfs_dedupe_file_range(), but other
* callers need it and it's not performance sesitive...
*/
ret = remap_verify_area(src_file, src_pos, len, false);
if (ret)
goto out_drop_write;

ret = remap_verify_area(dst_file, dst_pos, len, true);
if (ret < 0)
if (ret)
goto out_drop_write;

ret = -EPERM;
Expand Down

0 comments on commit 3078d85

Please sign in to comment.