diff options
author | Chengguang Xu <cgxu519@gmx.com> | 2018-07-19 10:15:25 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-08-02 15:33:28 -0400 |
commit | 0671e9968dfb3f99a366df816c361b8e871dba1b (patch) | |
tree | 5abae989553cfe457b8da5d85af9af52ad969943 | |
parent | 719784ba706cdbb47ef87483950f0a4594d36e87 (diff) |
ceph: add additional range check in ceph_fallocate()
If the range is larger than both real file size and limit of
max file size, then return -EFBIG.
Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r-- | fs/ceph/file.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 2f3a30ca94bf..2c54d2674db6 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -1728,8 +1728,7 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1728 | struct ceph_file_info *fi = file->private_data; | 1728 | struct ceph_file_info *fi = file->private_data; |
1729 | struct inode *inode = file_inode(file); | 1729 | struct inode *inode = file_inode(file); |
1730 | struct ceph_inode_info *ci = ceph_inode(inode); | 1730 | struct ceph_inode_info *ci = ceph_inode(inode); |
1731 | struct ceph_osd_client *osdc = | 1731 | struct ceph_fs_client *fsc = ceph_inode_to_client(inode); |
1732 | &ceph_inode_to_client(inode)->client->osdc; | ||
1733 | struct ceph_cap_flush *prealloc_cf; | 1732 | struct ceph_cap_flush *prealloc_cf; |
1734 | int want, got = 0; | 1733 | int want, got = 0; |
1735 | int dirty; | 1734 | int dirty; |
@@ -1737,6 +1736,9 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1737 | loff_t endoff = 0; | 1736 | loff_t endoff = 0; |
1738 | loff_t size; | 1737 | loff_t size; |
1739 | 1738 | ||
1739 | if ((offset + length) > max(i_size_read(inode), fsc->max_file_size)) | ||
1740 | return -EFBIG; | ||
1741 | |||
1740 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) | 1742 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) |
1741 | return -EOPNOTSUPP; | 1743 | return -EOPNOTSUPP; |
1742 | 1744 | ||
@@ -1760,7 +1762,7 @@ static long ceph_fallocate(struct file *file, int mode, | |||
1760 | goto unlock; | 1762 | goto unlock; |
1761 | } | 1763 | } |
1762 | 1764 | ||
1763 | if (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) && | 1765 | if (ceph_osdmap_flag(&fsc->client->osdc, CEPH_OSDMAP_FULL) && |
1764 | !(mode & FALLOC_FL_PUNCH_HOLE)) { | 1766 | !(mode & FALLOC_FL_PUNCH_HOLE)) { |
1765 | ret = -ENOSPC; | 1767 | ret = -ENOSPC; |
1766 | goto unlock; | 1768 | goto unlock; |