]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ceph: add additional size check in ceph_setattr()
authorChengguang Xu <cgxu519@gmx.com>
Sun, 5 Aug 2018 11:33:01 +0000 (19:33 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 13 Aug 2018 15:55:43 +0000 (17:55 +0200)
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>
fs/ceph/inode.c

index d62f65f2875d6fe5a96c41981d9bd4f4ba227b77..ebc7bdaed2d0d3674013b4800bf4e0265eada596 100644 (file)
@@ -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)
@@ -2166,6 +2167,10 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
        if (err != 0)
                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;