2019-06-01 13:31:03

by Sasha Levin

[permalink] [raw]
Subject: [PATCH AUTOSEL 4.4 23/56] fuse: honor RLIMIT_FSIZE in fuse_file_fallocate

From: Liu Bo <[email protected]>

[ Upstream commit 0cbade024ba501313da3b7e5dd2a188a6bc491b5 ]

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 <[email protected]>
Fixes: 05ba1f082300 ("fuse: add FALLOCATE operation")
Cc: <[email protected]> # v3.5
Signed-off-by: Miklos Szeredi <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
fs/fuse/file.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index d40c2451487cb..3ba45758e0938 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2947,6 +2947,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);

--
2.20.1


2019-06-05 20:28:49

by Liu Bo

[permalink] [raw]
Subject: Re: [PATCH AUTOSEL 4.4 23/56] fuse: honor RLIMIT_FSIZE in fuse_file_fallocate

On Sat, Jun 01, 2019 at 09:25:27AM -0400, Sasha Levin wrote:
> From: Liu Bo <[email protected]>
>
> [ Upstream commit 0cbade024ba501313da3b7e5dd2a188a6bc491b5 ]
>
> 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 <[email protected]>
> Fixes: 05ba1f082300 ("fuse: add FALLOCATE operation")
> Cc: <[email protected]> # v3.5
> Signed-off-by: Miklos Szeredi <[email protected]>
> Signed-off-by: Sasha Levin <[email protected]>
> ---
> fs/fuse/file.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index d40c2451487cb..3ba45758e0938 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -2947,6 +2947,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;

A later commit [1] was proposed to fix a problem of returning without unlock.

[1]: https://kernel.googlesource.com/pub/scm/linux/kernel/git/mszeredi/fuse/+/35d6fcbb7c3e296a52136347346a698a35af3fda

thanks,
-liubo

> + }
> +
> if (!(mode & FALLOC_FL_KEEP_SIZE))
> set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
>
> --
> 2.20.1