ANDROID: fs/fuse: Use extended init flags for FUSE_PASSTHROUGH

Starting with FUSE 7.36, all the fields for the 32-bit FUSE init flags
have been allocated, so commit 53db28933e ("fuse: extend init flags")
introduces the new 32-bit flags2 field in fuse_init_in and
fuse_init_out. That change also adds the FUSE_INIT_RESERVED flag that
doesn't have any specific purpose yet, is just reserved and should not
be used, and (un)fortunately collides with FUSE_PASSTHROUGH.

This change fixes the conflict by simply setting the FUSE_PASSTHROUGH
value to the next, latest unused fuse2 bit.
Although this is not the best design choice, userspace will know what
FUSE_PASSTHROUGH bit to choose based on the FUSE major and minor version
for FUSE version:
- < 7.36:    FUSE_PASSTHROUGH is the 31st bit of flags;
- otherwise: FUSE_PASSTHROUGH is the 31st bit of flags2.

Test: launch_cvd (both android-mainline and android13-5.10) \
  `logcat FuseDaemon:V \*:S` shows no FUSE passthrough errors
Bug: 215310351
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I85d7582008b8c093b3172b3f41c6cdf09863dd45
This commit is contained in:
Alessio Balsini
2022-01-27 14:44:24 +00:00
parent cf74cca8a1
commit cffa61e7b4
2 changed files with 14 additions and 2 deletions

View File

@@ -1227,7 +1227,6 @@ void fuse_send_init(struct fuse_mount *fm)
FUSE_PARALLEL_DIROPS | FUSE_HANDLE_KILLPRIV | FUSE_POSIX_ACL |
FUSE_ABORT_ERROR | FUSE_MAX_PAGES | FUSE_CACHE_SYMLINKS |
FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA |
FUSE_PASSTHROUGH |
FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT;
#ifdef CONFIG_FUSE_DAX
if (fm->fc->dax)
@@ -1236,6 +1235,8 @@ void fuse_send_init(struct fuse_mount *fm)
if (fm->fc->auto_submounts)
ia->in.flags |= FUSE_SUBMOUNTS;
ia->in.flags |= FUSE_PASSTHROUGH;
ia->args.opcode = FUSE_INIT;
ia->args.in_numargs = 1;
ia->args.in_args[0].size = sizeof(ia->in);

View File

@@ -372,7 +372,18 @@ struct fuse_file_lock {
#define FUSE_SUBMOUNTS (1 << 27)
#define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
#define FUSE_SETXATTR_EXT (1 << 29)
#define FUSE_PASSTHROUGH (1 << 31)
/*
* For FUSE < 7.36 FUSE_PASSTHROUGH has value (1 << 31).
* This condition check is not really required, but would prevent having a
* broken commit in the tree.
*/
#if FUSE_KERNEL_VERSION > 7 || \
(FUSE_KERNEL_VERSION == 7 && FUSE_KERNEL_MINOR_VERSION >= 36)
#define FUSE_PASSTHROUGH (1ULL << 63)
#else
#define FUSE_PASSTHROUGH (1 << 31)
#endif
/**
* CUSE INIT request/reply flags