diff options
author | Chengguang Xu <cgxu519@gmx.com> | 2018-08-05 07:33:01 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-08-13 11:55:43 -0400 |
commit | 36a4c72d1c6f5f50d4db14a38f296855ae82571b (patch) | |
tree | 0ba22abf9482dc9ad7abadd18f1b2b1ede2ff95a /fs/ceph | |
parent | 8687a3e2c7a026c173ac2e0d65d869c98c154a3a (diff) |
ceph: add additional size check in ceph_setattr()
ceph_setattr() finally calls vfs function inode_newsize_ok()
to do offset validation and that is based on sb->s_maxbytes.
Because we set sb->s_maxbytes to MAX_LFS_FILESIZE to through
VFS check and do proper offset validation in cephfs level,
we need adding proper offset validation before calling
inode_newsize_ok().
Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/inode.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index d62f65f2875d..ebc7bdaed2d0 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -2157,6 +2157,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) | |||
2157 | int ceph_setattr(struct dentry *dentry, struct iattr *attr) | 2157 | int ceph_setattr(struct dentry *dentry, struct iattr *attr) |
2158 | { | 2158 | { |
2159 | struct inode *inode = d_inode(dentry); | 2159 | struct inode *inode = d_inode(dentry); |
2160 | struct ceph_fs_client *fsc = ceph_inode_to_client(inode); | ||
2160 | int err; | 2161 | int err; |
2161 | 2162 | ||
2162 | if (ceph_snap(inode) != CEPH_NOSNAP) | 2163 | if (ceph_snap(inode) != CEPH_NOSNAP) |
@@ -2167,6 +2168,10 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr) | |||
2167 | return err; | 2168 | return err; |
2168 | 2169 | ||
2169 | if ((attr->ia_valid & ATTR_SIZE) && | 2170 | if ((attr->ia_valid & ATTR_SIZE) && |
2171 | attr->ia_size > max(inode->i_size, fsc->max_file_size)) | ||
2172 | return -EFBIG; | ||
2173 | |||
2174 | if ((attr->ia_valid & ATTR_SIZE) && | ||
2170 | ceph_quota_is_max_bytes_exceeded(inode, attr->ia_size)) | 2175 | ceph_quota_is_max_bytes_exceeded(inode, attr->ia_size)) |
2171 | return -EDQUOT; | 2176 | return -EDQUOT; |
2172 | 2177 | ||