Skip to contentSkip to conversation

ceph: Check that the new inode size is within limits in ceph_fallocate()

PATCH Applied Luis Henriques 2 participants 2 messages May 5, 2017 – May 8, 2017 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: Check that the new inode size is within limits in ceph_fallocate()

Currently the ceph client doesn't respect the rlimit in fallocate. This means that a user can allocate a file with size > RLIMIT_FSIZE. This patch adds the call to inode_newsize_ok() to verify filesystem limits and ulimits. This should make ceph successfully run xfstest generic/228.

---
 fs/ceph/file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ceph/file.c +5 -1
index 26cc95421cca..bc5809d4d2d4 100644
@@ -1636,8 +1636,12 @@ static long ceph_fallocate(struct file *file, int mode,
 	}
 
 	size = i_size_read(inode);
-	if (!(mode & FALLOC_FL_KEEP_SIZE))
+	if (!(mode & FALLOC_FL_KEEP_SIZE)) {
 		endoff = offset + length;
+		ret = inode_newsize_ok(inode, endoff);
+		if (ret)
+			goto unlock;
+	}
 
 	if (fi->fmode & CEPH_FILE_MODE_LAZY)
 		want = CEPH_CAP_FILE_BUFFER | CEPH_CAP_FILE_LAZYIO;
Applied
#1 lore raw
Quoted 19 lines · Luis Henriques

Currently the ceph client doesn't respect the rlimit in fallocate. This means that a user can allocate a file with size > RLIMIT_FSIZE. This patch adds the call to inode_newsize_ok() to verify filesystem limits and ulimits. This should make ceph successfully run xfstest generic/228.

---
 fs/ceph/file.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ceph/file.c +0 -1
index 26cc95421cca..bc5809d4d2d4 100644
@@ -1636,8 +1636,12 @@ static long ceph_fallocate(struct file *file, int mode,
        }
 
        size = i_size_read(inode);
-       if (!(mode & FALLOC_FL_KEEP_SIZE))

fs/ceph/file.c static long ceph_fallocate(struct file *file, int mode,

Quoted 10 lines
fs/ceph/file.c +5 -1
+       if (!(mode & FALLOC_FL_KEEP_SIZE)) {
                endoff = offset + length;
+               ret = inode_newsize_ok(inode, endoff);
+               if (ret)
+                       goto unlock;
+       }
 
        if (fi->fmode & CEPH_FILE_MODE_LAZY)
                want = CEPH_CAP_FILE_BUFFER | CEPH_CAP_FILE_LAZYIO;
--

Applied, thanks

Yan, Zheng

Quoted 3 lines

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