From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>,
Christian Schoenebeck <qemu_oss@crudebyte.com>
Subject: Re: [PATCH v3 02/11] 9pfs: require msize >= 4096
Date: Thu, 16 Jan 2020 17:16:07 +0100 [thread overview]
Message-ID: <2705438.6bQikqVx44@silver> (raw)
In-Reply-To: <20200116141503.32e36561@bahia.lan>
On Donnerstag, 16. Januar 2020 14:15:03 CET Greg Kurz wrote:
> On Mon, 13 Jan 2020 23:21:04 +0100
>
> Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> > A client establishes a session by sending a Tversion request along with
> > a 'msize' parameter which client uses to suggest server a maximum
> > message size ever to be used for communication (for both requests and
> > replies) between client and server during that session. If client
> > suggests a 'msize' smaller than 4096 then deny session by server
> > immediately with an error response (Rlerror for "9P2000.L" clients or
> > Rerror for "9P2000.u" clients) instead of replying with Rversion.
> >
> > Introduction of a minimum msize is required to prevent issues in
> > responses to numerous individual request types. For instance with a
> > msize of < P9_IOHDRSZ no useful operations would be possible at all.
>
> P9_IOHDRSZ is really specific to write/read operations.
>
> /*
> * ample room for Twrite/Rread header
> * size[4] Tread/Twrite tag[2] fid[4] offset[8] count[4]
> */
> #define P9_IOHDRSZ 24
>
> As you see P9_IOHDRSZ is approximately the size of a Twrite header.
> Its primary use is to inform the client about the 'count' to use for
> Twrite/Tread messages (see get_iounit()).
>
> Not sure it helps to mention P9_IOHDRSZ since we're going to choose
> something much greater. I'd personally drop this sentence.
The point here was that there must be some kind of absolute minimum msize,
even though the protocol specs officially don't mandate one. And if a client
choses a msize < P9_IOHDRSZ, what useful actions shall it be able to do?
That's why I mentioned P9_IOHDRSZ just in case somebody might come up later
asking to lower that minimum msize value for whatever reason.
But np, IMO this sentence makes the fundamental requirement for this patch
more clear, but I have no problem dropping this sentence.
> > Furthermore there are some responses which are not allowed by the 9p
> > protocol to be truncated like e.g. Rreadlink which may yield up to
>
> No message may be truncated in any way actually. The spec just allows
> an exception with the string part of Rerror.
Rreaddir, Rread, Twrite, Rerror can be truncated. So I suggest I'll just
change that to s/some/most/ semantically.
> Maybe just mention that and say we choose 4096 to be able to send
> big Rreadlink messages.
That's not the point for this patch. The main purpose is to avoid having to
maintain individual error prone minimum msize checks all over the code base.
If we would allow very small msizes (much smaller than 4096), then we would
need to add numerous error handlers all over the code base, each one checking
for different values (depending on the specific message type).
> > a size of PATH_MAX which is usually 4096. Hence this size was chosen
> > as min. msize for server, which is already the minimum msize of the
> > Linux kernel's 9pfs client. By forcing a min. msize already at
> > session start (when handling Tversion) we don't have to check for a
> > minimum msize on a per request type basis later on during session,
> > which would be much harder and more error prone to maintain.
> >
> > This is a user visible change which should be documented as such
> > (i.e. in public QEMU release changelog).
>
> This last sentence isn't informative in the commit message. This
> kind of indication should be added after the --- below.
>
> > Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> > ---
np
>
> LGTM
>
> With an updated changelog,
>
> Reviewed-by: Greg Kurz <groug@kaod.org>
>
> > hw/9pfs/9p.c | 12 ++++++++++++
> > hw/9pfs/9p.h | 11 +++++++++++
> > 2 files changed, 23 insertions(+)
> >
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index 520177f40c..a5fbe821d4 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -1363,8 +1363,20 @@ static void coroutine_fn v9fs_version(void *opaque)
> >
> > s->proto_version = V9FS_PROTO_2000L;
> >
> > } else {
> >
> > v9fs_string_sprintf(&version, "unknown");
> >
> > + /* skip min. msize check, reporting invalid version has priority
> > */ + goto marshal;
> >
> > }
> >
> > + if (s->msize < P9_MIN_MSIZE) {
> > + err = -EMSGSIZE;
> > + error_report(
> > + "9pfs: Client requested msize < minimum msize ("
> > + stringify(P9_MIN_MSIZE) ") supported by this server."
> > + );
> > + goto out;
> > + }
> > +
> >
> > +marshal:
> > err = pdu_marshal(pdu, offset, "ds", s->msize, &version);
> > if (err < 0) {
> >
> > goto out;
> >
> > diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
> > index 3904f82901..6fffe44f5a 100644
> > --- a/hw/9pfs/9p.h
> > +++ b/hw/9pfs/9p.h
> > @@ -100,6 +100,17 @@ typedef enum P9ProtoVersion {
> >
> > V9FS_PROTO_2000L = 0x02,
> >
> > } P9ProtoVersion;
> >
> > +/**
> > + * @brief Minimum message size supported by this 9pfs server.
> > + *
> > + * A client establishes a session by sending a Tversion request along
> > with a + * 'msize' parameter which suggests the server a maximum message
> > size ever to be + * used for communication (for both requests and
> > replies) between client and + * server during that session. If client
> > suggests a 'msize' smaller than this + * value then session is denied by
> > server with an error response. + */
> > +#define P9_MIN_MSIZE 4096
> > +
> >
> > #define P9_NOTAG UINT16_MAX
> > #define P9_NOFID UINT32_MAX
> > #define P9_MAXWELEM 16
Best regards,
Christian Schoenebeck
next prev parent reply other threads:[~2020-01-16 16:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 23:18 [PATCH v3 00/11] 9pfs: readdir optimization Christian Schoenebeck
2020-01-13 22:20 ` [PATCH v3 01/11] tests/virtio-9p: add terminating null in v9fs_string_read() Christian Schoenebeck
2020-01-13 22:21 ` [PATCH v3 02/11] 9pfs: require msize >= 4096 Christian Schoenebeck
2020-01-16 13:15 ` Greg Kurz
2020-01-16 16:16 ` Christian Schoenebeck [this message]
2020-01-16 18:07 ` Greg Kurz
2020-01-16 21:39 ` Christian Schoenebeck
2020-01-17 10:24 ` Greg Kurz
2020-01-17 12:01 ` Christian Schoenebeck
2020-01-17 15:15 ` Greg Kurz
2020-01-17 16:41 ` Christian Schoenebeck
2020-01-13 22:22 ` [PATCH v3 03/11] 9pfs: validate count sent by client with T_readdir Christian Schoenebeck
2020-01-16 13:33 ` Greg Kurz
2020-01-16 16:51 ` Christian Schoenebeck
2020-01-17 15:50 ` Greg Kurz
2020-01-13 22:23 ` [PATCH v3 04/11] hw/9pfs/9p-synth: added directory for readdir test Christian Schoenebeck
2020-01-13 23:08 ` [PATCH v3 05/11] tests/virtio-9p: added " Christian Schoenebeck
2020-01-17 15:51 ` Greg Kurz
2020-01-17 16:44 ` Christian Schoenebeck
2020-01-13 23:11 ` [PATCH v3 06/11] tests/virtio-9p: added splitted " Christian Schoenebeck
2020-01-13 23:13 ` [PATCH v3 07/11] tests/virtio-9p: failing " Christian Schoenebeck
2020-01-13 23:16 ` [PATCH v3 08/11] 9pfs: readdir benchmark Christian Schoenebeck
2020-01-13 23:16 ` [PATCH v3 09/11] hw/9pfs/9p-synth: avoid n-square issue in synth_readdir() Christian Schoenebeck
2020-01-13 23:17 ` [PATCH v3 10/11] 9pfs: T_readdir latency optimization Christian Schoenebeck
2020-01-13 23:17 ` [PATCH v3 11/11] hw/9pfs/9p.c: benchmark time on T_readdir request Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2705438.6bQikqVx44@silver \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).