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)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 24 Apr 2019 15:05:06 +0000 (17:05 +0200)
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")
Cc: <stable@vger.kernel.org> # v3.5
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/file.c

index 5428c81879b2ed511dfd202d952c4e4f70b75fa6..f811af4f6507f34e33c8ec8461be1003afbe1c22 100644 (file)
@@ -3044,6 +3044,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);