Re: [RESEND4, PATCH 1/2] fuse: retrieve: cap requested size to negotiated max_write

From: Miklos Szeredi
Date: Wed Apr 24 2019 - 08:17:44 EST


On Wed, Apr 24, 2019 at 1:56 PM Kirill Smelkov <kirr@xxxxxxxxxx> wrote:

> I assume you are meaning this:
>
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -1745,15 +1745,15 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
> unsigned int offset;
> size_t total_len = 0;
> unsigned int num_pages;
>
> offset = outarg->offset & ~PAGE_MASK;
> file_size = i_size_read(inode);
>
> - num = outarg->size;
> + num = min(outarg->size, fc->max_write);
> if (outarg->offset > file_size)
> num = 0;
> else if (outarg->offset + num > file_size)
> num = file_size - outarg->offset; <-- THIS
>
> num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
> num_pages = min(num_pages, fc->max_pages);
>
> and then in this case (offset + num > file_size) num overwrite
>
> num = file_size - offset
>
> can make num only smaller, right? And then the patch is not wrong because there
> is no other num overwriting in this function except when num is being further
> decremented in loop that prepares pages to retrieve.

You're right, of course.


> > Also the patch is whitespace damaged.
>
> I've tried to do the following in my mutt on "RESEND4, PATCH 1/2"
> message:
>
> |(cd ~/src/linux/linux && git am -)
>
> and the patch applied successfully. So could you please clarify what
> "whitespace damaged" means?

Hmm, apparently this (and only this) message is "quoted-printable"
encoded. git-am seems to handle it fine, but my script doesn't.
Anyway, I'll do it manually.

Thanks,
Miklos