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

From: Kirill Smelkov
Date: Wed Apr 24 2019 - 09:01:19 EST


On Wed, Apr 24, 2019 at 02:17:27PM +0200, Miklos Szeredi wrote:
> 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.

Thanks. Does it mean that the patch is ok? Do I need to rework
something?


> > > 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.

I see. Probably it is not "quoted-printable" as

Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

suggests and it is maybe due to UTF-8 characters (I used "Â" several
times in patch description). Anyway if it helps you can pull the patch
from here

https://lab.nexedi.com/kirr/linux.git y/fuse-retrieve-cap-max_write

and then cherry-pick it (git cherry-pick fd482f96537a) to where needed.

Thanks again for feedback,

Kirill