qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 02/11] 9pfs: require msize >= 4096


From: Greg Kurz
Subject: Re: [PATCH v3 02/11] 9pfs: require msize >= 4096
Date: Thu, 16 Jan 2020 14:15:03 +0100

On Mon, 13 Jan 2020 23:21:04 +0100
Christian Schoenebeck <address@hidden> 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.

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

Maybe just mention that and say we choose 4096 to be able to send
big Rreadlink messages.

> 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 <address@hidden>
> ---

LGTM

With an updated changelog,

Reviewed-by: Greg Kurz <address@hidden>

>  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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]