[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 02/11] 9pfs: require msize >= 4096
From: |
Christian Schoenebeck |
Subject: |
Re: [PATCH v3 02/11] 9pfs: require msize >= 4096 |
Date: |
Fri, 17 Jan 2020 17:41:25 +0100 |
On Freitag, 17. Januar 2020 16:15:37 CET Greg Kurz wrote:
> > > Hmm... this patch does a sanity check on 'count', not on 'msize'...
> >
> > Yes ... :)
> >
> > > I mean no matter what msize is, clipping count to msize - 11 gives a
> > > chance to stop processing the entries before overflowing the transport
> > > buffer.
> >
> > ... and no, this cannot happen if minimum msize of 4096 is forced already
> > by Tversion. Maybe you now get my point -> It is about avoiding exactly
> > such kind
> I'm not sure to see how setting a minimum msize of 4096 at Tversion would
> prevent the client to pass a higher 'count' argument and lure the server
> into generating a bigger than msize response since it does not check
> count < msize - 11 without patch 3.
That's correct, it requires patch 3 as well to prevent that. Without patch 3,
if a (i.e. bad) client sends a 'count' parameter >> msize then the Treaddir
request is processed by server to full extent according to 'count' and finally
aborted by a transport error since server's response would exceed msize.
> > of issues in the first place. Most file systems have a name limit of 255
> > bytes:
> >
> > https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits
> >
> > So by forcing a minimum 'msize' of 4096 you avoid having to deal with this
> > issue (and similar ones) on Treaddir request level (and other request type
> > handlers), including ReiserFS BTW because 4032+35 < 4096.
>
> Good to know for ReiserFS.
>
> > If you would allow smaller 'msize' values by Tversion, then you would need
> > to suffer some kind of death when handling Treaddir with certain high
> > file name length. Either a transport error (with an error message that a
> > normal user would not be able to understand at all) or by returning an
> > incomplete Treaddir response sequence with { Rreaddir count=0 }, or ...
> > any other kind of death.
> Ahh I now understand at last your argument about Rreaddir loosing data.
> We may end up sending { Rreaddir count=0 } because the next entry is too
> large... and thus end the readdir sequence.
Yep.
> Mentioning this explicitly
> from the start would have been more clear for me ;-)
Sorry for that. :) I thought I made it clear with the directory entries
example. I try to be more clear next time.
> This looks like yet another bug to me. It looks wrong to return this
> special response if we have more entries to go. Also this could be the
> client's _fault_ if it provides a ridiculously small value for count.
> The current code will return count=0 all the same.
>
> In any case, I think v9fs_do_readdir() should only return 0 if there
> are no more entries to read. It should error out otherwise, but I'm
> not sure how...
Patience please. I have to limit the scope of this patch series somewhere. I
am aware about these issues, but if I add fixes for more and more edge cases
(which already exist) as part of this patch series, it will become a never
ending story.
I just added those particular fixes to this series, because they were directly
related to things I've changed here for the actual purpose of this patch set,
which was and is: readdir latency optimization.
> > > My point is that we're not going to check msize in Tversion in
> > > order to to avoid multiple checks everywhere. We're going to do
> > > it there because it is the only place where it makes sense to
> > > do it.
> >
> > Also yes and no. Of course it just makes sense to handle it already at
> > Tversion. But no, you could theoretically also allow much smaller minimum
> > 'msize' value << 4096 (i.e. somewhere closely >7 as we discussed), then
> > you
> > would indeed still need to add msize checks at other places of the code
> > base as you just found out now. So forcing a minimum 'msize' which is
> > high enough, avoids having to add such individual checks and having to
> > deal with them in some kind of unpleasant way.
>
> We still don't understand each other I'm afraid... we actually have
> implicit 'msize' checks already for every single thing we write on
> the wire: v9fs_packunpack() which detects when we're trying to write
> passed the buffer. When this happens, it is propagated to the transport
> which then disconnects, which is the painful thing you've been
> experiencing with your readdir experiments. In the case of Rreaddir, it
> really does make sense to try to avoid the disconnection like you do in
> patch 3 because the readdir sequence allows _partial_ reads. Same goes
> for Rread. But that's it. No other message in the protocol allows that,
> so I've never thought of adding individual 'msize' checks anywhere else.
> What would they do better than v9fs_packunpack() already does ?
Right, but you realized that a min. msize of 4096 (in combination with
patch 3) prevents the readdir data loss issue we discussed here (provided we
have a "good" client sending count=msize-11), right?
If so, I suggest I "try" to address your concerns you came up with here in the
commit log message as far as I can, and would like to ask you to adjust the
message later on according to your personal preference if required.
Best regards,
Christian Schoenebeck
- [PATCH v3 08/11] 9pfs: readdir benchmark, (continued)
- [PATCH v3 08/11] 9pfs: readdir benchmark, Christian Schoenebeck, 2020/01/13
- [PATCH v3 01/11] tests/virtio-9p: add terminating null in v9fs_string_read(), Christian Schoenebeck, 2020/01/13
- [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/13
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/16
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/17
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Christian Schoenebeck, 2020/01/17
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096, Greg Kurz, 2020/01/17
- Re: [PATCH v3 02/11] 9pfs: require msize >= 4096,
Christian Schoenebeck <=
[PATCH v3 10/11] 9pfs: T_readdir latency optimization, Christian Schoenebeck, 2020/01/13
[PATCH v3 04/11] hw/9pfs/9p-synth: added directory for readdir test, Christian Schoenebeck, 2020/01/13
[PATCH v3 06/11] tests/virtio-9p: added splitted readdir test, Christian Schoenebeck, 2020/01/13