2019-09-04 12:37:48

by Michael S. Tsirkin

[permalink] [raw]
Subject: [PATCH] fuse: reserve byteswapped init opcodes

virtio fs tunnels fuse over a virtio channel. One issue is two sides
might be speaking different endian-ness. To detects this,
host side looks at the opcode value in the FUSE_INIT command.
Works fine at the moment but might fail if a future version
of fuse will use such an opcode for initialization.
Let's reserve this opcode so we remember and don't do this.

Same for CUSE_INIT.

Signed-off-by: Michael S. Tsirkin <[email protected]>
---
include/uapi/linux/fuse.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 2971d29a42e4..f042e63f4aa0 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -425,6 +425,10 @@ enum fuse_opcode {

/* CUSE specific operations */
CUSE_INIT = 4096,
+
+ /* Reserved opcodes: helpful to detect structure endian-ness */
+ FUSE_INIT_BSWAP_RESERVED = 26 << 24,
+ CUSE_INIT_BSWAP_RESERVED = 16 << 16,
};

enum fuse_notify_code {
--
MST


2019-09-04 14:24:16

by Dr. David Alan Gilbert

[permalink] [raw]
Subject: Re: [PATCH] fuse: reserve byteswapped init opcodes

* Michael S. Tsirkin ([email protected]) wrote:
> virtio fs tunnels fuse over a virtio channel. One issue is two sides
> might be speaking different endian-ness. To detects this,
> host side looks at the opcode value in the FUSE_INIT command.
> Works fine at the moment but might fail if a future version
> of fuse will use such an opcode for initialization.
> Let's reserve this opcode so we remember and don't do this.

I think in theory that works even for normal fuse.

> Same for CUSE_INIT.
>
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> ---
> include/uapi/linux/fuse.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
> index 2971d29a42e4..f042e63f4aa0 100644
> --- a/include/uapi/linux/fuse.h
> +++ b/include/uapi/linux/fuse.h
> @@ -425,6 +425,10 @@ enum fuse_opcode {
>
> /* CUSE specific operations */
> CUSE_INIT = 4096,
> +
> + /* Reserved opcodes: helpful to detect structure endian-ness */
> + FUSE_INIT_BSWAP_RESERVED = 26 << 24,

FUSE_INIT << 24 probably works?

> + CUSE_INIT_BSWAP_RESERVED = 16 << 16,

Dave

> };
>
> enum fuse_notify_code {
> --
> MST
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

2019-09-04 18:54:42

by Stefan Hajnoczi

[permalink] [raw]
Subject: Re: [PATCH] fuse: reserve byteswapped init opcodes

On Wed, Sep 04, 2019 at 08:36:33AM -0400, Michael S. Tsirkin wrote:
> virtio fs tunnels fuse over a virtio channel. One issue is two sides
> might be speaking different endian-ness. To detects this,
> host side looks at the opcode value in the FUSE_INIT command.
> Works fine at the moment but might fail if a future version
> of fuse will use such an opcode for initialization.
> Let's reserve this opcode so we remember and don't do this.
>
> Same for CUSE_INIT.
>
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> ---
> include/uapi/linux/fuse.h | 4 ++++
> 1 file changed, 4 insertions(+)

Reviewed-by: Stefan Hajnoczi <[email protected]>


Attachments:
(No filename) (670.00 B)
signature.asc (499.00 B)
Download all attachments