]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fuse: honor RLIMIT_FSIZE in fuse_file_fallocate
authorLiu Bo <bo.liu@linux.alibaba.com>
Wed, 17 Apr 2019 20:04:41 +0000 (04:04 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 23 Sep 2019 20:11:48 +0000 (21:11 +0100)
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@linux.alibaba.com>
Fixes: 05ba1f082300 ("fuse: add FALLOCATE operation")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/fuse/file.c

index 9d92f83348d1a9c6c74431c0aa4bee4f7e3d978d..7bb97212439d41566a781299a040c82c988b1a6d 100644 (file)
@@ -3017,6 +3017,13 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
                }
        }
 
+       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);