[PATCH 4.14 29/77] fuse: honor RLIMIT_FSIZE in fuse_file_fallocate
From: Greg Kroah-Hartman
Date: Thu May 23 2019 - 15:51:51 EST
From: Liu Bo <bo.liu@xxxxxxxxxxxxxxxxx>
commit 0cbade024ba501313da3b7e5dd2a188a6bc491b5 upstream.
fstests generic/228 reported this failure that fuse fallocate does not
honor what 'ulimit -f' has set.
This adds the necessary inode_newsize_ok() check.
Signed-off-by: Liu Bo <bo.liu@xxxxxxxxxxxxxxxxx>
Fixes: 05ba1f082300 ("fuse: add FALLOCATE operation")
Cc: <stable@xxxxxxxxxxxxxxx> # v3.5
Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
fs/fuse/file.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2974,6 +2974,13 @@ static long fuse_file_fallocate(struct f
}
}
+ if (!(mode & FALLOC_FL_KEEP_SIZE) &&
+ offset + length > i_size_read(inode)) {
+ err = inode_newsize_ok(inode, offset + length);
+ if (err)
+ return err;
+ }
+
if (!(mode & FALLOC_FL_KEEP_SIZE))
set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);