summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmx.com>2018-08-05 19:33:01 +0800
committerIlya Dryomov <idryomov@gmail.com>2018-08-13 17:55:43 +0200
commit36a4c72d1c6f5f50d4db14a38f296855ae82571b (patch)
tree0ba22abf9482dc9ad7abadd18f1b2b1ede2ff95a
parent8687a3e2c7a026c173ac2e0d65d869c98c154a3a (diff)
downloadlinux-stable-36a4c72d1c6f5f50d4db14a38f296855ae82571b.tar.gz
linux-stable-36a4c72d1c6f5f50d4db14a38f296855ae82571b.tar.bz2
linux-stable-36a4c72d1c6f5f50d4db14a38f296855ae82571b.zip
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>
-rw-r--r--fs/ceph/inode.c5
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)
int ceph_setattr(struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
+ struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
int err;
if (ceph_snap(inode) != CEPH_NOSNAP)
@@ -2167,6 +2168,10 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
return err;
if ((attr->ia_valid & ATTR_SIZE) &&
+ attr->ia_size > max(inode->i_size, fsc->max_file_size))
+ return -EFBIG;
+
+ if ((attr->ia_valid & ATTR_SIZE) &&
ceph_quota_is_max_bytes_exceeded(inode, attr->ia_size))
return -EDQUOT;