AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/06/19 17:33 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": [
    "FUSE_FS"
  ],
  "FocusSymbols": [
    "fuse_opt_fd",
    "fuse_syncfs_enable",
    "process_init_reply",
    "fuse_new_init",
    "fuse_fill_super_common"
  ],
  "Reasoning": "The patch introduces a new feature to the FUSE filesystem, allowing privileged userspace servers to opt-in to receiving FUSE_SYNCFS requests. It modifies mount parameter parsing and connection initialization logic, which are reachable from userspace and should be fuzzed.",
  "WorthFuzzing": true
}

1/1 2026/06/19 17:33 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 762e23e9cfa84559926d2afa06b9f706f77dd55a\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Fri Jun 19 17:33:05 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h\nindex 85f738c531225a..3fbe4957e839b4 100644\n--- a/fs/fuse/fuse_i.h\n+++ b/fs/fuse/fuse_i.h\n@@ -391,6 +391,7 @@ struct fuse_fs_context {\n \tbool no_control:1;\n \tbool no_force_umount:1;\n \tbool legacy_opts_show:1;\n+\tbool syncfs_capable:1;\n \tenum fuse_dax_mode dax_mode;\n \tunsigned int max_read;\n \tunsigned int blksize;\n@@ -675,6 +676,14 @@ struct fuse_conn {\n \t/** @sync_fs: Propagate syncfs() to server */\n \tunsigned int sync_fs:1;\n \n+\t/**\n+\t * @syncfs_capable: the privilege required to honor FUSE_HAS_SYNCFS was\n+\t * present when /dev/fuse was opened (CAP_SYS_ADMIN in the initial user\n+\t * namespace), i.e. the same privilege that mounting virtiofs/fuseblk\n+\t * requires.\n+\t */\n+\tunsigned int syncfs_capable:1;\n+\n \t/** @init_security: Initialize security xattrs when creating a new inode */\n \tunsigned int init_security:1;\n \ndiff --git a/fs/fuse/inode.c b/fs/fuse/inode.c\nindex d975073c602963..ba7506b539ae03 100644\n--- a/fs/fuse/inode.c\n+++ b/fs/fuse/inode.c\n@@ -800,6 +800,15 @@ static int fuse_opt_fd(struct fs_context *fsc, struct file *file)\n \tif (file-\u003ef_cred-\u003euser_ns != fsc-\u003euser_ns)\n \t\treturn invalfc(fsc, \"wrong user namespace for fuse device\");\n \n+\t/*\n+\t * Record whether the server opened /dev/fuse with CAP_SYS_ADMIN in the\n+\t * initial user namespace -- the same privilege that mounting virtiofs\n+\t * or fuseblk requires.  Only such servers are trusted to receive\n+\t * FUSE_SYNCFS (see fuse_syncfs_enable()).\n+\t */\n+\tctx-\u003esyncfs_capable = file_ns_capable(file, \u0026init_user_ns,\n+\t\t\t\t\t      CAP_SYS_ADMIN);\n+\n \tctx-\u003efud = fuse_dev_grab(file);\n \n \treturn 0;\n@@ -1266,6 +1275,16 @@ struct fuse_init_args {\n \tstruct fuse_mount *fm;\n };\n \n+/*\n+ * A server can stall syncfs()/sync(), so only honor FUSE_HAS_SYNCFS for\n+ * servers that opened /dev/fuse with CAP_SYS_ADMIN in the initial user\n+ * namespace -- the same privilege required to mount virtiofs or fuseblk.\n+ */\n+static bool fuse_syncfs_enable(struct fuse_conn *fc, u64 flags)\n+{\n+\treturn (flags \u0026 FUSE_HAS_SYNCFS) \u0026\u0026 fc-\u003esyncfs_capable;\n+}\n+\n static void process_init_reply(struct fuse_args *args, int error)\n {\n \tstruct fuse_init_args *ia = container_of(args, typeof(*ia), args);\n@@ -1406,6 +1425,9 @@ static void process_init_reply(struct fuse_args *args, int error)\n \n \t\t\tif (flags \u0026 FUSE_REQUEST_TIMEOUT)\n \t\t\t\ttimeout = arg-\u003erequest_timeout;\n+\n+\t\t\tif (fuse_syncfs_enable(fc, flags))\n+\t\t\t\tfc-\u003esync_fs = 1;\n \t\t} else {\n \t\t\tra_pages = fc-\u003emax_read / PAGE_SIZE;\n \t\t\tfc-\u003eno_lock = 1;\n@@ -1473,6 +1495,11 @@ static struct fuse_init_args *fuse_new_init(struct fuse_mount *fm)\n \t\tflags |= FUSE_SUBMOUNTS;\n \tif (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\n \t\tflags |= FUSE_PASSTHROUGH;\n+\t/* Only offered to sufficiently privileged servers; see\n+\t * fuse_syncfs_enable().\n+\t */\n+\tif (fm-\u003efc-\u003esyncfs_capable)\n+\t\tflags |= FUSE_HAS_SYNCFS;\n \n \t/*\n \t * This is just an information flag for fuse server. No need to check\n@@ -1766,6 +1793,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)\n \n \tfc-\u003edefault_permissions = ctx-\u003edefault_permissions;\n \tfc-\u003eallow_other = ctx-\u003eallow_other;\n+\tfc-\u003esyncfs_capable = ctx-\u003esyncfs_capable;\n \tfc-\u003euser_id = ctx-\u003euser_id;\n \tfc-\u003egroup_id = ctx-\u003egroup_id;\n \tfc-\u003elegacy_opts_show = ctx-\u003elegacy_opts_show;\ndiff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h\nindex c13e1f9a2f12bd..c078c5f0f94ec9 100644\n--- a/include/uapi/linux/fuse.h\n+++ b/include/uapi/linux/fuse.h\n@@ -240,6 +240,9 @@\n  *  - add FUSE_COPY_FILE_RANGE_64\n  *  - add struct fuse_copy_file_range_out\n  *  - add FUSE_NOTIFY_PRUNE\n+ *\n+ *  7.46\n+ *  - add FUSE_HAS_SYNCFS opt-in flag for privileged userspace servers\n  */\n \n #ifndef _LINUX_FUSE_H\n@@ -275,7 +278,7 @@\n #define FUSE_KERNEL_VERSION 7\n \n /** Minor version number of this interface */\n-#define FUSE_KERNEL_MINOR_VERSION 45\n+#define FUSE_KERNEL_MINOR_VERSION 46\n \n /** The node ID of the root inode */\n #define FUSE_ROOT_ID 1\n@@ -448,6 +451,12 @@ struct fuse_file_lock {\n  * FUSE_OVER_IO_URING: Indicate that client supports io-uring\n  * FUSE_REQUEST_TIMEOUT: kernel supports timing out requests.\n  *\t\t\t init_out.request_timeout contains the timeout (in secs)\n+ * FUSE_HAS_SYNCFS: server requests that syncfs()/sync() be propagated as\n+ *\t\tFUSE_SYNCFS requests.  Since an untrusted server can use this\n+ *\t\tto stall sync(), it is only honored when /dev/fuse was opened\n+ *\t\twith CAP_SYS_ADMIN in the initial user namespace (the same\n+ *\t\tprivilege that mounting virtiofs or fuseblk requires).\n+ *\t\tInsufficiently privileged servers ignore it.\n  */\n #define FUSE_ASYNC_READ\t\t(1 \u003c\u003c 0)\n #define FUSE_POSIX_LOCKS\t(1 \u003c\u003c 1)\n@@ -495,6 +504,7 @@ struct fuse_file_lock {\n #define FUSE_ALLOW_IDMAP\t(1ULL \u003c\u003c 40)\n #define FUSE_OVER_IO_URING\t(1ULL \u003c\u003c 41)\n #define FUSE_REQUEST_TIMEOUT\t(1ULL \u003c\u003c 42)\n+#define FUSE_HAS_SYNCFS\t\t(1ULL \u003c\u003c 43)\n \n /**\n  * CUSE INIT request/reply flags\ndiff --git a/tools/testing/selftests/filesystems/fuse/.gitignore b/tools/testing/selftests/filesystems/fuse/.gitignore\nindex 3e72e742d08e8c..4e92f363c74ab3 100644\n--- a/tools/testing/selftests/filesystems/fuse/.gitignore\n+++ b/tools/testing/selftests/filesystems/fuse/.gitignore\n@@ -1,3 +1,4 @@\n # SPDX-License-Identifier: GPL-2.0-only\n fuse_mnt\n fusectl_test\n+test_syncfs\ndiff --git a/tools/testing/selftests/filesystems/fuse/Makefile b/tools/testing/selftests/filesystems/fuse/Makefile\nindex 612aad69a93aa4..cbba01635226dc 100644\n--- a/tools/testing/selftests/filesystems/fuse/Makefile\n+++ b/tools/testing/selftests/filesystems/fuse/Makefile\n@@ -2,7 +2,7 @@\n \n CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES)\n \n-TEST_GEN_PROGS := fusectl_test\n+TEST_GEN_PROGS := fusectl_test test_syncfs\n TEST_GEN_FILES := fuse_mnt\n \n include ../../lib.mk\ndiff --git a/tools/testing/selftests/filesystems/fuse/test_syncfs.c b/tools/testing/selftests/filesystems/fuse/test_syncfs.c\nnew file mode 100644\nindex 00000000000000..90fb3478554af5\n--- /dev/null\n+++ b/tools/testing/selftests/filesystems/fuse/test_syncfs.c\n@@ -0,0 +1,370 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/*\n+ * Test that FUSE_SYNCFS is propagated to a userspace server only when the\n+ * server opts in with FUSE_HAS_SYNCFS *and* opened /dev/fuse with\n+ * CAP_SYS_ADMIN in the initial user namespace.\n+ *\n+ * Unlike the libfuse-based selftests, this talks the raw FUSE wire protocol\n+ * over /dev/fuse so it can (a) choose whether to advertise FUSE_HAS_SYNCFS in\n+ * the INIT reply and (b) observe directly whether a FUSE_SYNCFS opcode arrives.\n+ */\n+#define _GNU_SOURCE\n+#include \u003cerrno.h\u003e\n+#include \u003cfcntl.h\u003e\n+#include \u003cpoll.h\u003e\n+#include \u003csched.h\u003e\n+#include \u003csignal.h\u003e\n+#include \u003cstdio.h\u003e\n+#include \u003cstdlib.h\u003e\n+#include \u003cstring.h\u003e\n+#include \u003cunistd.h\u003e\n+#include \u003csys/eventfd.h\u003e\n+#include \u003csys/mount.h\u003e\n+#include \u003csys/stat.h\u003e\n+#include \u003csys/syscall.h\u003e\n+#include \u003csys/types.h\u003e\n+#include \u003csys/uio.h\u003e\n+#include \u003csys/wait.h\u003e\n+#include \u003clinux/capability.h\u003e\n+#include \u003clinux/fuse.h\u003e\n+\n+#include \"../../kselftest.h\"\n+\n+#define FUSE_ROOT_ID 1\n+\n+/*\n+ * Add or drop CAP_SYS_ADMIN in the effective set via raw capget/capset\n+ * (avoids a libcap dependency).  Used to construct a server that opens\n+ * /dev/fuse without the privilege FUSE_HAS_SYNCFS requires.\n+ */\n+static int set_sysadmin(int on)\n+{\n+\tstruct __user_cap_header_struct hdr = {\n+\t\t.version = _LINUX_CAPABILITY_VERSION_3,\n+\t\t.pid = 0,\n+\t};\n+\tstruct __user_cap_data_struct data[_LINUX_CAPABILITY_U32S_3] = {};\n+\tunsigned int idx = CAP_SYS_ADMIN \u003e\u003e 5;\n+\t__u32 bit = 1U \u003c\u003c (CAP_SYS_ADMIN \u0026 31);\n+\n+\tif (syscall(SYS_capget, \u0026hdr, data))\n+\t\treturn -1;\n+\tif (on)\n+\t\tdata[idx].effective |= bit;\n+\telse\n+\t\tdata[idx].effective \u0026= ~bit;\n+\treturn syscall(SYS_capset, \u0026hdr, data);\n+}\n+\n+/*\n+ * eventfd the server child writes once when it receives FUSE_SYNCFS; the\n+ * parent poll()s it to observe (or rule out) propagation.\n+ */\n+static int syncfs_evfd;\n+\n+static void reply(int fd, uint64_t unique, int error, void *data, size_t len)\n+{\n+\tstruct fuse_out_header oh = {\n+\t\t.len = sizeof(oh) + len,\n+\t\t.error = error,\n+\t\t.unique = unique,\n+\t};\n+\tstruct iovec iov[2] = {\n+\t\t{ \u0026oh, sizeof(oh) },\n+\t\t{ data, len },\n+\t};\n+\n+\tif (writev(fd, iov, data ? 2 : 1) \u003c 0)\n+\t\tksft_print_msg(\"server writev failed: %s\\n\", strerror(errno));\n+}\n+\n+static void fill_attr(struct fuse_attr *a, uint64_t ino, uint32_t mode,\n+\t\t      uint32_t nlink)\n+{\n+\tmemset(a, 0, sizeof(*a));\n+\ta-\u003eino = ino;\n+\ta-\u003emode = mode;\n+\ta-\u003enlink = nlink;\n+\ta-\u003eblksize = 4096;\n+}\n+\n+/*\n+ * Minimal FUSE server.  Advertises FUSE_HAS_SYNCFS in its INIT reply iff\n+ * @advertise is set.  Signals syncfs_evfd when a FUSE_SYNCFS opcode arrives.\n+ */\n+#define SERVER_MAX_WRITE 65536\n+static void run_server(int fd, int advertise)\n+{\n+\t/*\n+\t * The kernel rejects reads (EINVAL) whose buffer is smaller than\n+\t * max_write + header, so size generously for the max_write we\n+\t * advertise in the INIT reply below.\n+\t */\n+\tstatic char buf[SERVER_MAX_WRITE + 4096];\n+\n+\tfor (;;) {\n+\t\tssize_t n = read(fd, buf, sizeof(buf));\n+\t\tstruct fuse_in_header *ih = (void *)buf;\n+\n+\t\tif (n \u003c 0) {\n+\t\t\tif (errno == EINTR || errno == EAGAIN)\n+\t\t\t\tcontinue;\n+\t\t\treturn;\t\t/* device closed on unmount/abort */\n+\t\t}\n+\t\tif (n \u003c (ssize_t)sizeof(*ih))\n+\t\t\tcontinue;\n+\n+\t\tswitch (ih-\u003eopcode) {\n+\t\tcase FUSE_INIT: {\n+\t\t\tstruct fuse_init_in *in = (void *)(ih + 1);\n+\t\t\tstruct fuse_init_out out = {0};\n+\t\t\tuint64_t flags = FUSE_INIT_EXT;\n+\n+\t\t\tout.major = FUSE_KERNEL_VERSION;\n+\t\t\tout.minor = FUSE_KERNEL_MINOR_VERSION;\n+\t\t\tout.max_readahead = in-\u003emax_readahead;\n+\t\t\tout.max_write = SERVER_MAX_WRITE;\n+\t\t\tout.max_background = 16;\n+\t\t\tout.congestion_threshold = 12;\n+\t\t\tif (advertise)\n+\t\t\t\tflags |= FUSE_HAS_SYNCFS;\n+\t\t\tout.flags = flags;\n+\t\t\tout.flags2 = flags \u003e\u003e 32;\n+\t\t\treply(fd, ih-\u003eunique, 0, \u0026out, sizeof(out));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase FUSE_GETATTR: {\n+\t\t\tstruct fuse_attr_out out = {0};\n+\n+\t\t\tfill_attr(\u0026out.attr, FUSE_ROOT_ID, S_IFDIR | 0755, 2);\n+\t\t\treply(fd, ih-\u003eunique, 0, \u0026out, sizeof(out));\n+\t\t\tbreak;\n+\t\t}\n+\t\tcase FUSE_SYNCFS: {\n+\t\t\tuint64_t one = 1;\n+\n+\t\t\tif (write(syncfs_evfd, \u0026one, sizeof(one)) \u003c 0)\n+\t\t\t\tksft_print_msg(\"server eventfd write failed: %s\\n\",\n+\t\t\t\t\t       strerror(errno));\n+\t\t\treply(fd, ih-\u003eunique, 0, NULL, 0);\n+\t\t\tbreak;\n+\t\t}\n+\t\tdefault:\n+\t\t\t/*\n+\t\t\t * Anything else (e.g. OPENDIR from opening the mount\n+\t\t\t * root) is not needed to drive this test; -ENOSYS lets\n+\t\t\t * the kernel proceed.\n+\t\t\t */\n+\t\t\treply(fd, ih-\u003eunique, -ENOSYS, NULL, 0);\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n+/*\n+ * Mount a fuse fs backed by a forked server, issue syncfs(), and report\n+ * whether the server observed FUSE_SYNCFS.  Returns 0 on success, -1 if the\n+ * environment could not support the test (caller should skip).\n+ *\n+ * If @unpriv_open is set, /dev/fuse is opened with CAP_SYS_ADMIN dropped\n+ * (regained only for the mount() syscall), so the device opener -- the\n+ * server principal FUSE_HAS_SYNCFS is gated on -- lacks the privilege even\n+ * though it remains in the initial user namespace.\n+ */\n+static int do_mount_and_syncfs(const char *mnt, int advertise, int unpriv_open,\n+\t\t\t       int *seen)\n+{\n+\tstruct pollfd pfd = { .events = POLLIN };\n+\tchar opts[256];\n+\tint fd, mfd = -1, i;\n+\tpid_t pid;\n+\n+\tsyncfs_evfd = eventfd(0, EFD_CLOEXEC);\n+\tif (syncfs_evfd \u003c 0)\n+\t\treturn -1;\n+\n+\tif (unpriv_open \u0026\u0026 set_sysadmin(0))\n+\t\tgoto out_evfd;\n+\tfd = open(\"/dev/fuse\", O_RDWR);\n+\tif (unpriv_open \u0026\u0026 set_sysadmin(1)) {\n+\t\tif (fd \u003e= 0)\n+\t\t\tclose(fd);\n+\t\tgoto out_evfd;\n+\t}\n+\tif (fd \u003c 0)\n+\t\tgoto out_evfd;\n+\n+\tmkdir(mnt, 0755);\n+\tsnprintf(opts, sizeof(opts),\n+\t\t \"fd=%d,rootmode=40000,user_id=%d,group_id=%d\",\n+\t\t fd, getuid(), getgid());\n+\n+\tif (mount(\"fuse\", mnt, \"fuse\", 0, opts) \u003c 0)\n+\t\tgoto out_fd;\n+\n+\tpid = fork();\n+\tif (pid \u003c 0)\n+\t\tgoto out_umount;\n+\tif (pid == 0) {\n+\t\trun_server(fd, advertise);\n+\t\t_exit(0);\n+\t}\n+\n+\t/*\n+\t * The parent does not service the fuse fd; the child does.  Close our\n+\t * copy so the kernel sees a single server, and so that if the child\n+\t * dies the connection aborts instead of hanging us forever.\n+\t */\n+\tclose(fd);\n+\n+\t/*\n+\t * mount() returns before the server has answered FUSE_INIT, so the\n+\t * first open() can race and fail with ENOTCONN; retry until the\n+\t * handshake settles.\n+\t */\n+\tfor (i = 0; i \u003c 1000; i++) {\n+\t\tmfd = open(mnt, O_RDONLY | O_DIRECTORY);\n+\t\tif (mfd \u003e= 0)\n+\t\t\tbreak;\n+\t\tusleep(1000);\n+\t}\n+\tif (mfd \u003e= 0) {\n+\t\tsyncfs(mfd);\n+\t\tclose(mfd);\n+\t}\n+\n+\t/*\n+\t * No waiting is needed: the server writes syncfs_evfd before it replies\n+\t * to FUSE_SYNCFS, and that reply is what unblocks the synchronous\n+\t * syncfs() above.  So once syncfs() has returned, the eventfd is already\n+\t * signalled if the opcode was propagated, and will never be otherwise.\n+\t * poll() with a zero timeout therefore decides both cases immediately.\n+\t */\n+\tpfd.fd = syncfs_evfd;\n+\t*seen = poll(\u0026pfd, 1, 0) \u003e 0 \u0026\u0026 (pfd.revents \u0026 POLLIN);\n+\n+\tkill(pid, SIGKILL);\n+\twaitpid(pid, NULL, 0);\n+\tumount2(mnt, MNT_DETACH);\n+\tclose(syncfs_evfd);\n+\treturn 0;\n+\n+out_umount:\n+\tumount2(mnt, MNT_DETACH);\n+out_fd:\n+\tclose(fd);\n+out_evfd:\n+\tclose(syncfs_evfd);\n+\treturn -1;\n+}\n+\n+/* T4: same as above but the mount is created inside a new user namespace. */\n+static int run_in_userns(const char *mnt, int advertise, int *seen)\n+{\n+\tuid_t uid = getuid();\n+\tgid_t gid = getgid();\n+\tchar map[64];\n+\tint f;\n+\n+\tif (unshare(CLONE_NEWUSER | CLONE_NEWNS) \u003c 0)\n+\t\treturn -1;\t/* unprivileged userns mounts unavailable */\n+\n+\tf = open(\"/proc/self/setgroups\", O_WRONLY);\n+\tif (f \u003e= 0) {\n+\t\tdprintf(f, \"deny\");\n+\t\tclose(f);\n+\t}\n+\tsnprintf(map, sizeof(map), \"0 %d 1\", uid);\n+\tf = open(\"/proc/self/uid_map\", O_WRONLY);\n+\tif (f \u003c 0 || dprintf(f, \"%s\", map) \u003c 0)\n+\t\treturn -1;\n+\tclose(f);\n+\tsnprintf(map, sizeof(map), \"0 %d 1\", gid);\n+\tf = open(\"/proc/self/gid_map\", O_WRONLY);\n+\tif (f \u003c 0 || dprintf(f, \"%s\", map) \u003c 0)\n+\t\treturn -1;\n+\tclose(f);\n+\n+\t/* Need a mount namespace where we can mount fuse unprivileged. */\n+\tif (mount(NULL, \"/\", NULL, MS_REC | MS_PRIVATE, NULL) \u003c 0)\n+\t\treturn -1;\n+\n+\treturn do_mount_and_syncfs(mnt, advertise, 0, seen);\n+}\n+\n+int main(void)\n+{\n+\tchar mnt[] = \"/tmp/fuse_syncfs_XXXXXX\";\n+\tint seen, ret;\n+\n+\tksft_print_header();\n+\tksft_set_plan(4);\n+\n+\t/* Hard watchdog: never let a stuck syncfs hang the test runner. */\n+\tsignal(SIGALRM, SIG_DFL);\n+\talarm(60);\n+\n+\tif (geteuid() != 0)\n+\t\tksft_exit_skip(\"test requires root to mount fuse\\n\");\n+\n+\tif (!mkdtemp(mnt))\n+\t\tksft_exit_fail_msg(\"mkdtemp failed\\n\");\n+\n+\t/* T1: host-root mount, server opts in -\u003e syncfs must reach server. */\n+\tret = do_mount_and_syncfs(mnt, 1, 0, \u0026seen);\n+\tif (ret \u003c 0)\n+\t\tksft_test_result_skip(\"T1: could not mount fuse\\n\");\n+\telse\n+\t\tksft_test_result(seen,\n+\t\t\t\t \"T1 host-root + FUSE_HAS_SYNCFS: server receives FUSE_SYNCFS\\n\");\n+\n+\t/* T2: host-root mount, server does NOT opt in -\u003e no FUSE_SYNCFS. */\n+\tret = do_mount_and_syncfs(mnt, 0, 0, \u0026seen);\n+\tif (ret \u003c 0)\n+\t\tksft_test_result_skip(\"T2: could not mount fuse\\n\");\n+\telse\n+\t\tksft_test_result(!seen,\n+\t\t\t\t \"T2 host-root, no opt-in: server does NOT receive FUSE_SYNCFS\\n\");\n+\n+\t/*\n+\t * T3: server opts in but opened /dev/fuse without CAP_SYS_ADMIN while\n+\t * still in the initial user namespace -\u003e kernel must withhold\n+\t * FUSE_SYNCFS.  This is the case that distinguishes gating on the\n+\t * server's privilege from gating on the mount's user namespace.\n+\t */\n+\tret = do_mount_and_syncfs(mnt, 1, 1, \u0026seen);\n+\tif (ret \u003c 0)\n+\t\tksft_test_result_skip(\"T3: could not mount fuse unprivileged\\n\");\n+\telse\n+\t\tksft_test_result(!seen,\n+\t\t\t\t \"T3 init_userns, opener lacks CAP_SYS_ADMIN: FUSE_SYNCFS withheld\\n\");\n+\n+\t/*\n+\t * T4: unprivileged userns mount, server opts in -\u003e kernel must still\n+\t * withhold FUSE_SYNCFS.  Run in a child since it unshares namespaces.\n+\t */\n+\t{\n+\t\tpid_t p = fork();\n+\n+\t\tif (p == 0) {\n+\t\t\tint s = 0;\n+\t\t\tint r = run_in_userns(mnt, 1, \u0026s);\n+\n+\t\t\t_exit(r \u003c 0 ? 2 : (s ? 1 : 0));\n+\t\t} else {\n+\t\t\tint status;\n+\n+\t\t\twaitpid(p, \u0026status, 0);\n+\t\t\tif (!WIFEXITED(status))\n+\t\t\t\tksft_test_result_error(\"T4: child crashed\\n\");\n+\t\t\telse if (WEXITSTATUS(status) == 2)\n+\t\t\t\tksft_test_result_skip(\"T4: userns fuse mount unavailable\\n\");\n+\t\t\telse\n+\t\t\t\tksft_test_result(WEXITSTATUS(status) == 0,\n+\t\t\t\t\t\t \"T4 unpriv userns + opt-in: FUSE_SYNCFS withheld\\n\");\n+\t\t}\n+\t}\n+\n+\trmdir(mnt);\n+\tksft_finished();\n+}\n"
}

2/1 2026/06/19 17:33 agent patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
{
  "EnableConfigs": [
    "FUSE_FS"
  ],
  "FocusSymbols": [
    "fuse_opt_fd",
    "fuse_syncfs_enable",
    "process_init_reply",
    "fuse_new_init",
    "fuse_fill_super_common"
  ],
  "Reasoning": "The patch introduces a new feature to the FUSE filesystem, allowing privileged userspace servers to opt-in to receiving FUSE_SYNCFS requests. It modifies mount parameter parsing and connection initialization logic, which are reachable from userspace and should be fuzzed.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Do not list too generic configs (we already have them enabled). Only list those that
   specifically cover the modified code. List them in the EnableConfigs output array,
   and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit 762e23e9cfa84559926d2afa06b9f706f77dd55a
Author: syz-cluster <triage@syzkaller.com>
Date:   Fri Jun 19 17:33:05 2026 +0000

    syz-cluster: applied patch under review

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 85f738c531225a..3fbe4957e839b4 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -391,6 +391,7 @@ struct fuse_fs_context {
 	bool no_control:1;
 	bool no_force_umount:1;
 	bool legacy_opts_show:1;
+	bool syncfs_capable:1;
 	enum fuse_dax_mode dax_mode;
 	unsigned int max_read;
 	unsigned int blksize;
@@ -675,6 +676,14 @@ struct fuse_conn {
 	/** @sync_fs: Propagate syncfs() to server */
 	unsigned int sync_fs:1;
 
+	/**
+	 * @syncfs_capable: the privilege required to honor FUSE_HAS_SYNCFS was
+	 * present when /dev/fuse was opened (CAP_SYS_ADMIN in the initial user
+	 * namespace), i.e. the same privilege that mounting virtiofs/fuseblk
+	 * requires.
+	 */
+	unsigned int syncfs_capable:1;
+
 	/** @init_security: Initialize security xattrs when creating a new inode */
 	unsigned int init_security:1;
 
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d975073c602963..ba7506b539ae03 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -800,6 +800,15 @@ static int fuse_opt_fd(struct fs_context *fsc, struct file *file)
 	if (file->f_cred->user_ns != fsc->user_ns)
 		return invalfc(fsc, "wrong user namespace for fuse device");
 
+	/*
+	 * Record whether the server opened /dev/fuse with CAP_SYS_ADMIN in the
+	 * initial user namespace -- the same privilege that mounting virtiofs
+	 * or fuseblk requires.  Only such servers are trusted to receive
+	 * FUSE_SYNCFS (see fuse_syncfs_enable()).
+	 */
+	ctx->syncfs_capable = file_ns_capable(file, &init_user_ns,
+					      CAP_SYS_ADMIN);
+
 	ctx->fud = fuse_dev_grab(file);
 
 	return 0;
@@ -1266,6 +1275,16 @@ struct fuse_init_args {
 	struct fuse_mount *fm;
 };
 
+/*
+ * A server can stall syncfs()/sync(), so only honor FUSE_HAS_SYNCFS for
+ * servers that opened /dev/fuse with CAP_SYS_ADMIN in the initial user
+ * namespace -- the same privilege required to mount virtiofs or fuseblk.
+ */
+static bool fuse_syncfs_enable(struct fuse_conn *fc, u64 flags)
+{
+	return (flags & FUSE_HAS_SYNCFS) && fc->syncfs_capable;
+}
+
 static void process_init_reply(struct fuse_args *args, int error)
 {
 	struct fuse_init_args *ia = container_of(args, typeof(*ia), args);
@@ -1406,6 +1425,9 @@ static void process_init_reply(struct fuse_args *args, int error)
 
 			if (flags & FUSE_REQUEST_TIMEOUT)
 				timeout = arg->request_timeout;
+
+			if (fuse_syncfs_enable(fc, flags))
+				fc->sync_fs = 1;
 		} else {
 			ra_pages = fc->max_read / PAGE_SIZE;
 			fc->no_lock = 1;
@@ -1473,6 +1495,11 @@ static struct fuse_init_args *fuse_new_init(struct fuse_mount *fm)
 		flags |= FUSE_SUBMOUNTS;
 	if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))
 		flags |= FUSE_PASSTHROUGH;
+	/* Only offered to sufficiently privileged servers; see
+	 * fuse_syncfs_enable().
+	 */
+	if (fm->fc->syncfs_capable)
+		flags |= FUSE_HAS_SYNCFS;
 
 	/*
 	 * This is just an information flag for fuse server. No need to check
@@ -1766,6 +1793,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
 
 	fc->default_permissions = ctx->default_permissions;
 	fc->allow_other = ctx->allow_other;
+	fc->syncfs_capable = ctx->syncfs_capable;
 	fc->user_id = ctx->user_id;
 	fc->group_id = ctx->group_id;
 	fc->legacy_opts_show = ctx->legacy_opts_show;
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index c13e1f9a2f12bd..c078c5f0f94ec9 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -240,6 +240,9 @@
  *  - add FUSE_COPY_FILE_RANGE_64
  *  - add struct fuse_copy_file_range_out
  *  - add FUSE_NOTIFY_PRUNE
+ *
+ *  7.46
+ *  - add FUSE_HAS_SYNCFS opt-in flag for privileged userspace servers
  */
 
 #ifndef _LINUX_FUSE_H
@@ -275,7 +278,7 @@
 #define FUSE_KERNEL_VERSION 7
 
 /** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 45
+#define FUSE_KERNEL_MINOR_VERSION 46
 
 /** The node ID of the root inode */
 #define FUSE_ROOT_ID 1
@@ -448,6 +451,12 @@ struct fuse_file_lock {
  * FUSE_OVER_IO_URING: Indicate that client supports io-uring
  * FUSE_REQUEST_TIMEOUT: kernel supports timing out requests.
  *			 init_out.request_timeout contains the timeout (in secs)
+ * FUSE_HAS_SYNCFS: server requests that syncfs()/sync() be propagated as
+ *		FUSE_SYNCFS requests.  Since an untrusted server can use this
+ *		to stall sync(), it is only honored when /dev/fuse was opened
+ *		with CAP_SYS_ADMIN in the initial user namespace (the same
+ *		privilege that mounting virtiofs or fuseblk requires).
+ *		Insufficiently privileged servers ignore it.
  */
 #define FUSE_ASYNC_READ		(1 << 0)
 #define FUSE_POSIX_LOCKS	(1 << 1)
@@ -495,6 +504,7 @@ struct fuse_file_lock {
 #define FUSE_ALLOW_IDMAP	(1ULL << 40)
 #define FUSE_OVER_IO_URING	(1ULL << 41)
 #define FUSE_REQUEST_TIMEOUT	(1ULL << 42)
+#define FUSE_HAS_SYNCFS		(1ULL << 43)
 
 /**
  * CUSE INIT request/reply flags
diff --git a/tools/testing/selftests/filesystems/fuse/.gitignore b/tools/testing/selftests/filesystems/fuse/.gitignore
index 3e72e742d08e8c..4e92f363c74ab3 100644
--- a/tools/testing/selftests/filesystems/fuse/.gitignore
+++ b/tools/testing/selftests/filesystems/fuse/.gitignore
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 fuse_mnt
 fusectl_test
+test_syncfs
diff --git a/tools/testing/selftests/filesystems/fuse/Makefile b/tools/testing/selftests/filesystems/fuse/Makefile
index 612aad69a93aa4..cbba01635226dc 100644
--- a/tools/testing/selftests/filesystems/fuse/Makefile
+++ b/tools/testing/selftests/filesystems/fuse/Makefile
@@ -2,7 +2,7 @@
 
 CFLAGS += -Wall -O2 -g $(KHDR_INCLUDES)
 
-TEST_GEN_PROGS := fusectl_test
+TEST_GEN_PROGS := fusectl_test test_syncfs
 TEST_GEN_FILES := fuse_mnt
 
 include ../../lib.mk
diff --git a/tools/testing/selftests/filesystems/fuse/test_syncfs.c b/tools/testing/selftests/filesystems/fuse/test_syncfs.c
new file mode 100644
index 00000000000000..90fb3478554af5
--- /dev/null
+++ b/tools/testing/selftests/filesystems/fuse/test_syncfs.c
@@ -0,0 +1,370 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Test that FUSE_SYNCFS is propagated to a userspace server only when the
+ * server opts in with FUSE_HAS_SYNCFS *and* opened /dev/fuse with
+ * CAP_SYS_ADMIN in the initial user namespace.
+ *
+ * Unlike the libfuse-based selftests, this talks the raw FUSE wire protocol
+ * over /dev/fuse so it can (a) choose whether to advertise FUSE_HAS_SYNCFS in
+ * the INIT reply and (b) observe directly whether a FUSE_SYNCFS opcode arrives.
+ */
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/eventfd.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <linux/capability.h>
+#include <linux/fuse.h>
+
+#include "../../kselftest.h"
+
+#define FUSE_ROOT_ID 1
+
+/*
+ * Add or drop CAP_SYS_ADMIN in the effective set via raw capget/capset
+ * (avoids a libcap dependency).  Used to construct a server that opens
+ * /dev/fuse without the privilege FUSE_HAS_SYNCFS requires.
+ */
+static int set_sysadmin(int on)
+{
+	struct __user_cap_header_struct hdr = {
+		.version = _LINUX_CAPABILITY_VERSION_3,
+		.pid = 0,
+	};
+	struct __user_cap_data_struct data[_LINUX_CAPABILITY_U32S_3] = {};
+	unsigned int idx = CAP_SYS_ADMIN >> 5;
+	__u32 bit = 1U << (CAP_SYS_ADMIN & 31);
+
+	if (syscall(SYS_capget, &hdr, data))
+		return -1;
+	if (on)
+		data[idx].effective |= bit;
+	else
+		data[idx].effective &= ~bit;
+	return syscall(SYS_capset, &hdr, data);
+}
+
+/*
+ * eventfd the server child writes once when it receives FUSE_SYNCFS; the
+ * parent poll()s it to observe (or rule out) propagation.
+ */
+static int syncfs_evfd;
+
+static void reply(int fd, uint64_t unique, int error, void *data, size_t len)
+{
+	struct fuse_out_header oh = {
+		.len = sizeof(oh) + len,
+		.error = error,
+		.unique = unique,
+	};
+	struct iovec iov[2] = {
+		{ &oh, sizeof(oh) },
+		{ data, len },
+	};
+
+	if (writev(fd, iov, data ? 2 : 1) < 0)
+		ksft_print_msg("server writev failed: %s\n", strerror(errno));
+}
+
+static void fill_attr(struct fuse_attr *a, uint64_t ino, uint32_t mode,
+		      uint32_t nlink)
+{
+	memset(a, 0, sizeof(*a));
+	a->ino = ino;
+	a->mode = mode;
+	a->nlink = nlink;
+	a->blksize = 4096;
+}
+
+/*
+ * Minimal FUSE server.  Advertises FUSE_HAS_SYNCFS in its INIT reply iff
+ * @advertise is set.  Signals syncfs_evfd when a FUSE_SYNCFS opcode arrives.
+ */
+#define SERVER_MAX_WRITE 65536
+static void run_server(int fd, int advertise)
+{
+	/*
+	 * The kernel rejects reads (EINVAL) whose buffer is smaller than
+	 * max_write + header, so size generously for the max_write we
+	 * advertise in the INIT reply below.
+	 */
+	static char buf[SERVER_MAX_WRITE + 4096];
+
+	for (;;) {
+		ssize_t n = read(fd, buf, sizeof(buf));
+		struct fuse_in_header *ih = (void *)buf;
+
+		if (n < 0) {
+			if (errno == EINTR || errno == EAGAIN)
+				continue;
+			return;		/* device closed on unmount/abort */
+		}
+		if (n < (ssize_t)sizeof(*ih))
+			continue;
+
+		switch (ih->opcode) {
+		case FUSE_INIT: {
+			struct fuse_init_in *in = (void *)(ih + 1);
+			struct fuse_init_out out = {0};
+			uint64_t flags = FUSE_INIT_EXT;
+
+			out.major = FUSE_KERNEL_VERSION;
+			out.minor = FUSE_KERNEL_MINOR_VERSION;
+			out.max_readahead = in->max_readahead;
+			out.max_write = SERVER_MAX_WRITE;
+			out.max_background = 16;
+			out.congestion_threshold = 12;
+			if (advertise)
+				flags |= FUSE_HAS_SYNCFS;
+			out.flags = flags;
+			out.flags2 = flags >> 32;
+			reply(fd, ih->unique, 0, &out, sizeof(out));
+			break;
+		}
+		case FUSE_GETATTR: {
+			struct fuse_attr_out out = {0};
+
+			fill_attr(&out.attr, FUSE_ROOT_ID, S_IFDIR | 0755, 2);
+			reply(fd, ih->unique, 0, &out, sizeof(out));
+			break;
+		}
+		case FUSE_SYNCFS: {
+			uint64_t one = 1;
+
+			if (write(syncfs_evfd, &one, sizeof(one)) < 0)
+				ksft_print_msg("server eventfd write failed: %s\n",
+					       strerror(errno));
+			reply(fd, ih->unique, 0, NULL, 0);
+			break;
+		}
+		default:
+			/*
+			 * Anything else (e.g. OPENDIR from opening the mount
+			 * root) is not needed to drive this test; -ENOSYS lets
+			 * the kernel proceed.
+			 */
+			reply(fd, ih->unique, -ENOSYS, NULL, 0);
+			break;
+		}
+	}
+}
+
+/*
+ * Mount a fuse fs backed by a forked server, issue syncfs(), and report
+ * whether the server observed FUSE_SYNCFS.  Returns 0 on success, -1 if the
+ * environment could not support the test (caller should skip).
+ *
+ * If @unpriv_open is set, /dev/fuse is opened with CAP_SYS_ADMIN dropped
+ * (regained only for the mount() syscall), so the device opener -- the
+ * server principal FUSE_HAS_SYNCFS is gated on -- lacks the privilege even
+ * though it remains in the initial user namespace.
+ */
+static int do_mount_and_syncfs(const char *mnt, int advertise, int unpriv_open,
+			       int *seen)
+{
+	struct pollfd pfd = { .events = POLLIN };
+	char opts[256];
+	int fd, mfd = -1, i;
+	pid_t pid;
+
+	syncfs_evfd = eventfd(0, EFD_CLOEXEC);
+	if (syncfs_evfd < 0)
+		return -1;
+
+	if (unpriv_open && set_sysadmin(0))
+		goto out_evfd;
+	fd = open("/dev/fuse", O_RDWR);
+	if (unpriv_open && set_sysadmin(1)) {
+		if (fd >= 0)
+			close(fd);
+		goto out_evfd;
+	}
+	if (fd < 0)
+		goto out_evfd;
+
+	mkdir(mnt, 0755);
+	snprintf(opts, sizeof(opts),
+		 "fd=%d,rootmode=40000,user_id=%d,group_id=%d",
+		 fd, getuid(), getgid());
+
+	if (mount("fuse", mnt, "fuse", 0, opts) < 0)
+		goto out_fd;
+
+	pid = fork();
+	if (pid < 0)
+		goto out_umount;
+	if (pid == 0) {
+		run_server(fd, advertise);
+		_exit(0);
+	}
+
+	/*
+	 * The parent does not service the fuse fd; the child does.  Close our
+	 * copy so the kernel sees a single server, and so that if the child
+	 * dies the connection aborts instead of hanging us forever.
+	 */
+	close(fd);
+
+	/*
+	 * mount() returns before the server has answered FUSE_INIT, so the
+	 * first open() can race and fail with ENOTCONN; retry until the
+	 * handshake settles.
+	 */
+	for (i = 0; i < 1000; i++) {
+		mfd = open(mnt, O_RDONLY | O_DIRECTORY);
+		if (mfd >= 0)
+			break;
+		usleep(1000);
+	}
+	if (mfd >= 0) {
+		syncfs(mfd);
+		close(mfd);
+	}
+
+	/*
+	 * No waiting is needed: the server writes syncfs_evfd before it replies
+	 * to FUSE_SYNCFS, and that reply is what unblocks the synchronous
+	 * syncfs() above.  So once syncfs() has returned, the eventfd is already
+	 * signalled if the opcode was propagated, and will never be otherwise.
+	 * poll() with a zero timeout therefore decides both cases immediately.
+	 */
+	pfd.fd = syncfs_evfd;
+	*seen = poll(&pfd, 1, 0) > 0 && (pfd.revents & POLLIN);
+
+	kill(pid, SIGKILL);
+	waitpid(pid, NULL, 0);
+	umount2(mnt, MNT_DETACH);
+	close(syncfs_evfd);
+	return 0;
+
+out_umount:
+	umount2(mnt, MNT_DETACH);
+out_fd:
+	close(fd);
+out_evfd:
+	close(syncfs_evfd);
+	return -1;
+}
+
+/* T4: same as above but the mount is created inside a new user namespace. */
+static int run_in_userns(const char *mnt, int advertise, int *seen)
+{
+	uid_t uid = getuid();
+	gid_t gid = getgid();
+	char map[64];
+	int f;
+
+	if (unshare(CLONE_NEWUSER | CLONE_NEWNS) < 0)
+		return -1;	/* unprivileged userns mounts unavailable */
+
+	f = open("/proc/self/setgroups", O_WRONLY);
+	if (f >= 0) {
+		dprintf(f, "deny");
+		close(f);
+	}
+	snprintf(map, sizeof(map), "0 %d 1", uid);
+	f = open("/proc/self/uid_map", O_WRONLY);
+	if (f < 0 || dprintf(f, "%s", map) < 0)
+		return -1;
+	close(f);
+	snprintf(map, sizeof(map), "0 %d 1", gid);
+	f = open("/proc/self/gid_map", O_WRONLY);
+	if (f < 0 || dprintf(f, "%s", map) < 0)
+		return -1;
+	close(f);
+
+	/* Need a mount namespace where we can mount fuse unprivileged. */
+	if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL) < 0)
+		return -1;
+
+	return do_mount_and_syncfs(mnt, advertise, 0, seen);
+}
+
+int main(void)
+{
+	char mnt[] = "/tmp/fuse_syncfs_XXXXXX";
+	int seen, ret;
+
+	ksft_print_header();
+	ksft_set_plan(4);
+
+	/* Hard watchdog: never let a stuck syncfs hang the test runner. */
+	signal(SIGALRM, SIG_DFL);
+	alarm(60);
+
+	if (geteuid() != 0)
+		ksft_exit_skip("test requires root to mount fuse\n");
+
+	if (!mkdtemp(mnt))
+		ksft_exit_fail_msg("mkdtemp failed\n");
+
+	/* T1: host-root mount, server opts in -> syncfs must reach server. */
+	ret = do_mount_and_syncfs(mnt, 1, 0, &seen);
+	if (ret < 0)
+		ksft_test_result_skip("T1: could not mount fuse\n");
+	else
+		ksft_test_result(seen,
+				 "T1 host-root + FUSE_HAS_SYNCFS: server receives FUSE_SYNCFS\n");
+
+	/* T2: host-root mount, server does NOT opt in -> no FUSE_SYNCFS. */
+	ret = do_mount_and_syncfs(mnt, 0, 0, &seen);
+	if (ret < 0)
+		ksft_test_result_skip("T2: could not mount fuse\n");
+	else
+		ksft_test_result(!seen,
+				 "T2 host-root, no opt-in: server does NOT receive FUSE_SYNCFS\n");
+
+	/*
+	 * T3: server opts in but opened /dev/fuse without CAP_SYS_ADMIN while
+	 * still in the initial user namespace -> kernel must withhold
+	 * FUSE_SYNCFS.  This is the case that distinguishes gating on the
+	 * server's privilege from gating on the mount's user namespace.
+	 */
+	ret = do_mount_and_syncfs(mnt, 1, 1, &seen);
+	if (ret < 0)
+		ksft_test_result_skip("T3: could not mount fuse unprivileged\n");
+	else
+		ksft_test_result(!seen,
+				 "T3 init_userns, opener lacks CAP_SYS_ADMIN: FUSE_SYNCFS withheld\n");
+
+	/*
+	 * T4: unprivileged userns mount, server opts in -> kernel must still
+	 * withhold FUSE_SYNCFS.  Run in a child since it unshares namespaces.
+	 */
+	{
+		pid_t p = fork();
+
+		if (p == 0) {
+			int s = 0;
+			int r = run_in_userns(mnt, 1, &s);
+
+			_exit(r < 0 ? 2 : (s ? 1 : 0));
+		} else {
+			int status;
+
+			waitpid(p, &status, 0);
+			if (!WIFEXITED(status))
+				ksft_test_result_error("T4: child crashed\n");
+			else if (WEXITSTATUS(status) == 2)
+				ksft_test_result_skip("T4: userns fuse mount unavailable\n");
+			else
+				ksft_test_result(WEXITSTATUS(status) == 0,
+						 "T4 unpriv userns + opt-in: FUSE_SYNCFS withheld\n");
+		}
+	}
+
+	rmdir(mnt);
+	ksft_finished();
+}

3/2 2026/06/19 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 8150
							output: 19
							thoughts: 392
						

Thoughts:
**My Analysis of the FUSE Filesystem Patch**

Okay, so I'm looking at this patch that introduces support for the `FUSE_HAS_SYNCFS` flag within the FUSE filesystem. It seems pretty straightforward on the surface, modifying a few key files: `fs/fuse/fuse_i.h`, `fs/fuse/inode.c`, `include/uapi/linux/fuse.h`, and, importantly, adding a new selftest. That's a good sign – we need robust testing for this kind of change.

The patch's core seems to revolve around adding a `syncfs_capable` bit to the `fuse_fs_context` and `fuse_conn` structures. This capability check is done in `fuse_opt_fd`, where it verifies if the server has opened `/dev/fuse` with the `CAP_SYS_ADMIN` capability within the initial user namespace. That makes sense, controlling sync operations requires a level of privilege. `fuse_syncfs_enable` then checks the `FUSE_HAS_SYNCFS` flag along with the `syncfs_capable` flag before enabling the sync operation. Furthermore, the `FUSE_HAS_SYNCFS` flag is set during the `fuse_new_init` function.

Essentially, this adds functional logic for `syncfs` propagation, which is accessible from userspace through FUSE mounts. Since it's user-facing, fuzzing will be *crucial* to ensure its stability and security.

Now, let's get into the details. I need to nail down the relevant configurations and, most importantly, the key symbols this patch affects. I've noted that `FUSE_FS` is the relevant config. The focus symbols are `fuse_opt_fd`, `fuse_syncfs_enable`, `process_init_reply`, `fuse_new_init`, and `fuse_fill_super_common`. These are the functions where the new logic is introduced, and therefore where potential vulnerabilities might reside. I'll need to scrutinize these carefully.

I should also double-check `fs/fuse/inode.c` just in case there are other configurations or dependencies I haven't spotted yet. And finally, I'll leverage the tools at my disposal to verify this implementation's correctness and potential areas for concern.



4/2 2026/06/19 17:33 tool grepper
0m Args:
{
  "Expression": "config FUSE_FS"
}

Results:
{
  "Output": "fs/fuse/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nfs/fuse/Kconfig:2:config FUSE_FS\nfs/fuse/Kconfig-3-\ttristate \"FUSE (Filesystem in Userspace) support\"\n"
}

5/2 2026/06/19 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 9132
							output: 19
							thoughts: 30
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert's internal monologue:

**Checking fuse/inode.c for Configuration Options**

Alright, let's dive into `fs/fuse/inode.c`. I need to refresh my memory on how FUSE handles its configuration options, specifically looking for `fuse_opt_fd` and `fuse_syncfs_enable`. My understanding is that `fuse_opt_fd` is critical; it defines the file descriptor used for communication between the userspace FUSE process and the kernel. I need to make sure I understand the nuances of how it's handled, particularly in relation to how it's passed, verified, and used, given the complexities of inter-process communication within the FUSE framework. A potential vulnerability or performance bottleneck could be here.

Then, there's `fuse_syncfs_enable`. This relates to synchronous file system operations, and understanding its implications is critical for correctly working with FUSE. I need to see how it's integrated with the main inode operations and if it interacts with other features. Synchronous operations are crucial for the integrity of many file systems, but they can be a performance killer if not implemented correctly. This part might give me insight into performance issues or data integrity guarantees. I wonder if there are any subtle race conditions or deadlocks that could arise when combining this feature with other asynchronous operations. It's time to dig in and remind myself of the details. Let's see what the code tells us.



6/2 2026/06/19 17:33 tool grepper
0m Args:
{
  "Expression": "fuse_opt_fd"
}

Results:
{
  "Output": "fs/fuse/inode.c=776=static const struct fs_parameter_spec fuse_fs_parameters[] = {\n--\nfs/fuse/inode.c-789-\nfs/fuse/inode.c:790:static int fuse_opt_fd(struct fs_context *fsc, struct file *file)\nfs/fuse/inode.c-791-{\n--\nfs/fuse/inode.c=817=static int fuse_parse_param(struct fs_context *fsc, struct fs_parameter *param)\n--\nfs/fuse/inode.c-856-\t\tif (param-\u003etype == fs_value_is_file) {\nfs/fuse/inode.c:857:\t\t\treturn fuse_opt_fd(fsc, param-\u003efile);\nfs/fuse/inode.c-858-\t\t} else {\n--\nfs/fuse/inode.c-862-\nfs/fuse/inode.c:863:\t\t\treturn fuse_opt_fd(fsc, file);\nfs/fuse/inode.c-864-\t\t}\n"
}

7/2 2026/06/19 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 9770
							output: 20
							thoughts: 12
						

Thoughts:
Okay, here's my summarized thought process, presented as if I'm thinking it:

**Checking `fuse_syncfs_enable`**

Alright, time to get to it. Let's see... the first thing I need to do is confirm the state of `fuse_syncfs_enable`. That's the baseline, the foundation of this whole line of thinking. It's crucial for understanding how we're dealing with the FUSE sync file system functionality, or rather, if we even *are* dealing with it. Understanding the state of this variable is the starting point for any deeper analysis here. It'll shape the context for everything that follows.



8/2 2026/06/19 17:33 tool grepper
0m Args:
{
  "Expression": "fuse_syncfs_enable"
}

Results:
{
  "Output": "fs/fuse/inode.c=790=static int fuse_opt_fd(struct fs_context *fsc, struct file *file)\n--\nfs/fuse/inode.c-806-\t * or fuseblk requires.  Only such servers are trusted to receive\nfs/fuse/inode.c:807:\t * FUSE_SYNCFS (see fuse_syncfs_enable()).\nfs/fuse/inode.c-808-\t */\n--\nfs/fuse/inode.c=1271=struct fuse_init_args {\n--\nfs/fuse/inode.c-1282- */\nfs/fuse/inode.c:1283:static bool fuse_syncfs_enable(struct fuse_conn *fc, u64 flags)\nfs/fuse/inode.c-1284-{\n--\nfs/fuse/inode.c=1288=static void process_init_reply(struct fuse_args *args, int error)\n--\nfs/fuse/inode.c-1428-\nfs/fuse/inode.c:1429:\t\t\tif (fuse_syncfs_enable(fc, flags))\nfs/fuse/inode.c-1430-\t\t\t\tfc-\u003esync_fs = 1;\n--\nfs/fuse/inode.c=1462=static struct fuse_init_args *fuse_new_init(struct fuse_mount *fm)\n--\nfs/fuse/inode.c-1498-\t/* Only offered to sufficiently privileged servers; see\nfs/fuse/inode.c:1499:\t * fuse_syncfs_enable().\nfs/fuse/inode.c-1500-\t */\n"
}

9/2 2026/06/19 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 10356
							output: 22
							thoughts: 128
						

Thoughts:
**My Initial Assessment of the FUSE Patch**

Alright, let's break this down. This patch is zeroing in on some critical areas of the FUSE framework: the initialization phase and the parsing of parameters. I see new functions added, namely `fuse_syncfs_enable`, which immediately piques my interest, and modifications to some of the core initialization routines: `fuse_opt_fd`, `process_init_reply`, `fuse_new_init`, and `fuse_fill_super_common`. Given these changes, and knowing the potential for subtle issues in initialization and option handling, the thought immediately occurs: this is screaming for fuzzing. We need to throw everything we can at this.

My mental checklist starts: first, I want to confirm the primary configuration option associated is `FUSE_FS`. I know where that sits in the architecture, but confirming it's a good place to start. Beyond that, I need to make a note to myself and hone in on those specific symbols. `fuse_opt_fd`, `fuse_syncfs_enable`, `process_init_reply`, `fuse_new_init`, and `fuse_fill_super_common` are my primary targets, and I'll need to understand their updated logic very precisely.

Before I commit to deep diving into the code, I need to make sure I'm not missing anything. I'll take a quick scan for other configuration options that may be relevant, especially those that interact with `FUSE_FS`. Could be crucial for edge case testing. It's time to dig in.



10/2 2026/06/19 17:33 tool grepper
0m Args:
{
  "Expression": "FUSE_PASSTHROUGH"
}

Results:
{
  "Output": "Documentation/filesystems/fuse/fuse-passthrough.rst=31=To use FUSE passthrough:\nDocumentation/filesystems/fuse/fuse-passthrough.rst-32-\nDocumentation/filesystems/fuse/fuse-passthrough.rst:33:  1. The FUSE filesystem must be compiled with ``CONFIG_FUSE_PASSTHROUGH``\nDocumentation/filesystems/fuse/fuse-passthrough.rst-34-     enabled.\nDocumentation/filesystems/fuse/fuse-passthrough.rst-35-  2. The FUSE daemon, during the ``FUSE_INIT`` handshake, must negotiate the\nDocumentation/filesystems/fuse/fuse-passthrough.rst:36:     ``FUSE_PASSTHROUGH`` capability and specify its desired\nDocumentation/filesystems/fuse/fuse-passthrough.rst-37-     ``max_stack_depth``.\n--\nfs/fuse/Kconfig=43=config FUSE_DAX\n--\nfs/fuse/Kconfig-56-\nfs/fuse/Kconfig:57:config FUSE_PASSTHROUGH\nfs/fuse/Kconfig-58-\tbool \"FUSE passthrough operations support\"\n--\nfs/fuse/Makefile=17=fuse-$(CONFIG_FUSE_DAX) += dax.o\nfs/fuse/Makefile:18:fuse-$(CONFIG_FUSE_PASSTHROUGH) += passthrough.o backing.o\nfs/fuse/Makefile-19-fuse-$(CONFIG_SYSCTL) += sysctl.o\n--\nfs/fuse/dev.c=2298=static long fuse_dev_ioctl_backing_open(struct file *file,\n--\nfs/fuse/dev.c-2306-\nfs/fuse/dev.c:2307:\tif (!IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\nfs/fuse/dev.c-2308-\t\treturn -EOPNOTSUPP;\n--\nfs/fuse/dev.c=2316=static long fuse_dev_ioctl_backing_close(struct file *file, __u32 __user *argp)\n--\nfs/fuse/dev.c-2323-\nfs/fuse/dev.c:2324:\tif (!IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\nfs/fuse/dev.c-2325-\t\treturn -EOPNOTSUPP;\n--\nfs/fuse/fuse_i.h=102=struct fuse_inode {\n--\nfs/fuse/fuse_i.h-228-\tstruct fuse_submount_lookup *submount_lookup;\nfs/fuse/fuse_i.h:229:#ifdef CONFIG_FUSE_PASSTHROUGH\nfs/fuse/fuse_i.h-230-\t/** @fb: Reference to backing file in passthrough mode */\n--\nfs/fuse/fuse_i.h=269=struct fuse_file {\n--\nfs/fuse/fuse_i.h-315-\nfs/fuse/fuse_i.h:316:#ifdef CONFIG_FUSE_PASSTHROUGH\nfs/fuse/fuse_i.h-317-\t/** @passthrough: Reference to backing file in passthrough mode */\n--\nfs/fuse/fuse_i.h=418=struct fuse_conn {\n--\nfs/fuse/fuse_i.h-769-\nfs/fuse/fuse_i.h:770:#ifdef CONFIG_FUSE_PASSTHROUGH\nfs/fuse/fuse_i.h-771-\t/** @backing_files_map: IDR for backing files ids */\n--\nfs/fuse/fuse_i.h=1263=void fuse_file_release(struct inode *inode, struct fuse_file *ff,\n--\nfs/fuse/fuse_i.h-1266-/* backing.c */\nfs/fuse/fuse_i.h:1267:#ifdef CONFIG_FUSE_PASSTHROUGH\nfs/fuse/fuse_i.h-1268-struct fuse_backing *fuse_backing_get(struct fuse_backing *fb);\n--\nfs/fuse/fuse_i.h=1292=static inline struct fuse_backing *fuse_inode_backing(struct fuse_inode *fi)\nfs/fuse/fuse_i.h-1293-{\nfs/fuse/fuse_i.h:1294:#ifdef CONFIG_FUSE_PASSTHROUGH\nfs/fuse/fuse_i.h-1295-\treturn READ_ONCE(fi-\u003efb);\n--\nfs/fuse/fuse_i.h=1301=static inline struct fuse_backing *fuse_inode_backing_set(struct fuse_inode *fi,\n--\nfs/fuse/fuse_i.h-1303-{\nfs/fuse/fuse_i.h:1304:#ifdef CONFIG_FUSE_PASSTHROUGH\nfs/fuse/fuse_i.h-1305-\treturn xchg(\u0026fi-\u003efb, fb);\n--\nfs/fuse/fuse_i.h=1314=static inline struct file *fuse_file_passthrough(struct fuse_file *ff)\nfs/fuse/fuse_i.h-1315-{\nfs/fuse/fuse_i.h:1316:#ifdef CONFIG_FUSE_PASSTHROUGH\nfs/fuse/fuse_i.h-1317-\treturn ff-\u003epassthrough;\n--\nfs/fuse/inode.c=84=static struct inode *fuse_alloc_inode(struct super_block *sb)\n--\nfs/fuse/inode.c-105-\nfs/fuse/inode.c:106:\tif (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\nfs/fuse/inode.c-107-\t\tfuse_inode_backing_set(fi, NULL);\n--\nfs/fuse/inode.c=118=static void fuse_free_inode(struct inode *inode)\n--\nfs/fuse/inode.c-126-#endif\nfs/fuse/inode.c:127:\tif (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\nfs/fuse/inode.c-128-\t\tfuse_backing_put(fuse_inode_backing(fi));\n--\nfs/fuse/inode.c=965=void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm,\n--\nfs/fuse/inode.c-986-\nfs/fuse/inode.c:987:\tif (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\nfs/fuse/inode.c-988-\t\tfuse_backing_files_init(fc);\n--\nfs/fuse/inode.c=1009=void fuse_conn_put(struct fuse_conn *fc)\n--\nfs/fuse/inode.c-1025-\t}\nfs/fuse/inode.c:1026:\tif (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\nfs/fuse/inode.c-1027-\t\tfuse_backing_files_free(fc);\n--\nfs/fuse/inode.c=1288=static void process_init_reply(struct fuse_args *args, int error)\n--\nfs/fuse/inode.c-1401-\t\t\t *\nfs/fuse/inode.c:1402:\t\t\t * Also don't allow the combination of FUSE_PASSTHROUGH\nfs/fuse/inode.c-1403-\t\t\t * and FUSE_WRITEBACK_CACHE, current design doesn't handle\n--\nfs/fuse/inode.c-1405-\t\t\t */\nfs/fuse/inode.c:1406:\t\t\tif (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH) \u0026\u0026\nfs/fuse/inode.c:1407:\t\t\t    (flags \u0026 FUSE_PASSTHROUGH) \u0026\u0026\nfs/fuse/inode.c-1408-\t\t\t    arg-\u003emax_stack_depth \u003e 0 \u0026\u0026\n--\nfs/fuse/inode.c=1462=static struct fuse_init_args *fuse_new_init(struct fuse_mount *fm)\n--\nfs/fuse/inode.c-1495-\t\tflags |= FUSE_SUBMOUNTS;\nfs/fuse/inode.c:1496:\tif (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))\nfs/fuse/inode.c:1497:\t\tflags |= FUSE_PASSTHROUGH;\nfs/fuse/inode.c-1498-\t/* Only offered to sufficiently privileged servers; see\n--\nfs/fuse/iomode.c=168=static int fuse_file_passthrough_open(struct inode *inode, struct file *file)\n--\nfs/fuse/iomode.c-175-\t/* Check allowed conditions for file open in passthrough mode */\nfs/fuse/iomode.c:176:\tif (!IS_ENABLED(CONFIG_FUSE_PASSTHROUGH) || !fc-\u003epassthrough ||\nfs/fuse/iomode.c-177-\t    (ff-\u003eopen_flags \u0026 ~FOPEN_PASSTHROUGH_MASK))\n--\ninclude/uapi/linux/fuse.h-215- *  7.40\ninclude/uapi/linux/fuse.h:216: *  - add max_stack_depth to fuse_init_out, add FUSE_PASSTHROUGH init flag\ninclude/uapi/linux/fuse.h-217- *  - add backing_id to fuse_open_out, add FOPEN_PASSTHROUGH open flag\n--\ninclude/uapi/linux/fuse.h=355=struct fuse_file_lock {\n--\ninclude/uapi/linux/fuse.h-498-#define FUSE_DIRECT_IO_ALLOW_MMAP (1ULL \u003c\u003c 36)\ninclude/uapi/linux/fuse.h:499:#define FUSE_PASSTHROUGH\t(1ULL \u003c\u003c 37)\ninclude/uapi/linux/fuse.h-500-#define FUSE_NO_EXPORT_SUPPORT\t(1ULL \u003c\u003c 38)\n--\ntools/testing/selftests/bpf/config.vm=5=CONFIG_FUSE_FS=y\ntools/testing/selftests/bpf/config.vm:6:CONFIG_FUSE_PASSTHROUGH=y\ntools/testing/selftests/bpf/config.vm-7-CONFIG_NET_9P_VIRTIO=y\n"
}

11/2 2026/06/19 17:33 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 13429
							output: 132
							thoughts: 292
						

Thoughts:
**Analyzing the FUSE Patch**

Okay, so this patch seems straightforward enough, thankfully. My initial impression is that it doesn't *rely* on `CONFIG_FUSE_PASSTHROUGH`, though it's placed in the same file. All it seems to do is introduce `FUSE_HAS_SYNCFS`. The key configuration option to enable is `FUSE_FS`, which makes sense. I'll just double-check to be absolutely certain there aren't any other config dependencies lurking.

Alright, a quick scan of the touched files, `fs/fuse/fuse_i.h`, `fs/fuse/inode.c`, and `include/uapi/linux/fuse.h`, confirms that `FUSE_FS` is indeed the *only* required config. That's a relief; simpler is always better.

Now, let's turn our attention to the key symbols this patch introduces or modifies. I've got my focus narrowed down to: `fuse_opt_fd`, `fuse_syncfs_enable`, `process_init_reply`, `fuse_new_init`, and `fuse_fill_super_common`. Let's quickly determine if any of these are potential performance bottlenecks.

`fuse_opt_fd` is used for mount parameter parsing – not a hot path. Good. `fuse_syncfs_enable` gets called within `process_init_reply`, which itself is only called once per FUSE mount. That's not likely to be a performance concern either. Then there's `fuse_new_init` and `fuse_fill_super_common`, both executed only once per mount, similar to the above.

Looks like all those focus symbols are in the clear in terms of being hot paths. That's good news; the patch seems relatively low-impact in terms of performance.

Alright, based on this analysis, I'm ready to mark the results as set.



12/2 2026/06/19 17:33 tool set-results
0m Args:
{
  "EnableConfigs": [
    "FUSE_FS"
  ],
  "FocusSymbols": [
    "fuse_opt_fd",
    "fuse_syncfs_enable",
    "process_init_reply",
    "fuse_new_init",
    "fuse_fill_super_common"
  ],
  "Reasoning": "The patch introduces a new feature to the FUSE filesystem, allowing privileged userspace servers to opt-in to receiving FUSE_SYNCFS requests. It modifies mount parameter parsing and connection initialization logic, which are reachable from userspace and should be fuzzed.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "FUSE_FS"
  ],
  "FocusSymbols": [
    "fuse_opt_fd",
    "fuse_syncfs_enable",
    "process_init_reply",
    "fuse_new_init",
    "fuse_fill_super_common"
  ],
  "Reasoning": "The patch introduces a new feature to the FUSE filesystem, allowing privileged userspace servers to opt-in to receiving FUSE_SYNCFS requests. It modifies mount parameter parsing and connection initialization logic, which are reachable from userspace and should be fuzzed.",
  "WorthFuzzing": true
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)