[PATCH] ceph: add proper offset validation check to ceph_setattr()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 fs/ceph/inode.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 7a7b76ad876a..bea5f5e9e0f9 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2165,11 +2165,16 @@ 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)
 		return -EROFS;
 
+	if ((attr->ia_valid & ATTR_SIZE) &&
+		(attr->ia_size > max(inode->i_size, fsc->max_file_size)))
+		return -EFBIG;
+
 	err = setattr_prepare(dentry, attr);
 	if (err != 0)
 		return err;
-- 
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux