Skip to contentSkip to conversation

fuse: reserve byteswapped init opcodes

PATCH In review Michael S. Tsirkin 3 participants 3 messages Sep 4, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 include/uapi/linux/fuse.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/linux/fuse.h +4 -0
index 2971d29a42e4..f042e63f4aa0 100644
@@ -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 {
Signature · 1 line
MST
#1 lore raw
Quoted 6 lines · * 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.

Quoted 12 lines

Same for CUSE_INIT.

---
 include/uapi/linux/fuse.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/linux/fuse.h +0 -0
index 2971d29a42e4..f042e63f4aa0 100644

include/uapi/linux/fuse.h enum fuse_opcode { · line 430

Quoted 6 lines
include/uapi/linux/fuse.h +3 -0
@@ -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?

include/uapi/linux/fuse.h enum fuse_opcode { · line 431

Quoted 1 line
include/uapi/linux/fuse.h +1 -0
+	CUSE_INIT_BSWAP_RESERVED	= 16 << 16,

Dave

Quoted 5 lines
include/uapi/linux/fuse.h +0 -0
 };
 
 enum fuse_notify_code {
Signature · 1 line
MST

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Reviewed-by on v1 1/1
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin

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.

Quoted 6 lines

Same for CUSE_INIT.

---
 include/uapi/linux/fuse.h | 4 ++++
 1 file changed, 4 insertions(+)