diff options
author | Amir Goldstein <amir73il@gmail.com> | 2017-01-31 03:34:56 -0500 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-02-07 09:05:04 -0500 |
commit | 11cbfb10775aa2a01cee966d118049ede9d0bdf2 (patch) | |
tree | 582c22e5b6ab314682c0a21af365d67f28c56db3 /fs/read_write.c | |
parent | 9e79b1326302589a035fe20e8cce7c1a7d8333ed (diff) |
vfs: deny copy_file_range() for non regular files
There is no in-tree file system that implements copy_file_range()
for non regular files.
Deny an attempt to copy_file_range() a directory with EISDIR
and any other non regualr file with EINVAL to conform with
behavior of vfs_{clone,dedup}_file_range().
This change is needed prior to converting sb_start_write()
to file_start_write() in the vfs helper.
Cc: linux-api@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r-- | fs/read_write.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index 5816d4c4cab0..511178d7723b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -1518,6 +1518,11 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, | |||
1518 | if (flags != 0) | 1518 | if (flags != 0) |
1519 | return -EINVAL; | 1519 | return -EINVAL; |
1520 | 1520 | ||
1521 | if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) | ||
1522 | return -EISDIR; | ||
1523 | if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) | ||
1524 | return -EINVAL; | ||
1525 | |||
1521 | ret = rw_verify_area(READ, file_in, &pos_in, len); | 1526 | ret = rw_verify_area(READ, file_in, &pos_in, len); |
1522 | if (unlikely(ret)) | 1527 | if (unlikely(ret)) |
1523 | return ret; | 1528 | return ret; |