From: Jimmy Zuber <jamz@amazon.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: <fuse-devel@lists.linux.dev>, <linux-fsdevel@vger.kernel.org>,
<linux-api@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Shuah Khan <shuah@kernel.org>, <linux-kselftest@vger.kernel.org>
Subject: [PATCH v2 0/2] fuse: allow FUSE_SYNCFS for privileged userspace servers
Date: Fri, 19 Jun 2026 17:02:49 +0000 [thread overview]
Message-ID: <20260619170251.1154562-1-jamz@amazon.com> (raw)
In-Reply-To: <20260616151909.916667-1-jamz@amazon.com>
FUSE_SYNCFS (propagating syncfs()/sync() to the server) is currently
enabled only for virtiofs and fuseblk, since an untrusted server can stall
sync(). Any FUSE filesystem may buffer data in the server that ought to
reach storage on sync(); the only thing that should gate it is whether the
/dev/fuse opener is sufficiently privileged to be trusted to block sync.
This series lets a plain /dev/fuse server opt in via a new FUSE_HAS_SYNCFS
INIT flag, honored only when the server opened /dev/fuse with CAP_SYS_ADMIN
privilege in the initial user namespace -- checked with file_ns_capable() at
mount time.
Patch 1: the kernel change (UAPI flag + privilege gating).
Patch 2: a selftest that speaks the raw FUSE protocol over /dev/fuse, so
it can withhold the flag and directly observe whether the
FUSE_SYNCFS opcode is forwarded.
A matching libfuse change (FUSE_CAP_SYNCFS negotiation) will be sent to the
libfuse project once the UAPI flag here is settled.
Changes since v1 [1]:
- Gate on the privilege of the opener (CAP_SYS_ADMIN in init_user_ns at
/dev/fuse open time, via file_ns_capable()) rather than on the mount's
user namespace. Miklos pointed out that the v1 check
(fc->user_ns == &init_user_ns) tested a property of the mount, not of
the server that actually services -- and can stall -- the connection.
Being in the initial user namespace is not itself a privilege
(e.g. an ordinary sshfs mount qualifies). Checking the device opener's
capability closes that gap.
- Selftest: add a case covering exactly that distinction -- a server
in the initial user namespace that opened /dev/fuse without
CAP_SYS_ADMIN -- which v1 would have wrongly allowed.
Testing: built and booted under QEMU. The selftest passes all
four cases, including the new case above (verified that the kernel withholds
FUSE_SYNCFS while it would have been granted under the v1 check).
[1] https://lore.kernel.org/20260616151909.916667-1-jamz@amazon.com
Jimmy Zuber (2):
fuse: allow FUSE_SYNCFS for privileged userspace servers
selftests/fuse: add test for FUSE_HAS_SYNCFS privilege gating
fs/fuse/fuse_i.h | 9 +
fs/fuse/inode.c | 28 ++
include/uapi/linux/fuse.h | 12 +-
.../selftests/filesystems/fuse/.gitignore | 1 +
.../selftests/filesystems/fuse/Makefile | 2 +-
.../selftests/filesystems/fuse/test_syncfs.c | 370 ++++++++++++++++++
6 files changed, 420 insertions(+), 2 deletions(-)
create mode 100644 tools/testing/selftests/filesystems/fuse/test_syncfs.c
base-commit: 7d87a5a284bb34edb3f4e7e312ef403b3385a7b7
--
2.50.1
next prev parent reply other threads:[~2026-06-19 17:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 15:19 [PATCH 0/2] fuse: allow FUSE_SYNCFS for privileged userspace servers Jimmy Zuber
2026-06-16 15:19 ` [PATCH 1/2] " Jimmy Zuber
2026-06-17 8:22 ` Miklos Szeredi
2026-06-19 16:33 ` Jimmy Zuber
2026-06-16 15:19 ` [PATCH 2/2] selftests/fuse: add test for FUSE_HAS_SYNCFS privilege gating Jimmy Zuber
2026-06-19 17:02 ` Jimmy Zuber [this message]
2026-06-19 17:02 ` [PATCH v2 1/2] fuse: allow FUSE_SYNCFS for privileged userspace servers Jimmy Zuber
2026-06-19 17:02 ` [PATCH v2 2/2] selftests/fuse: add test for FUSE_HAS_SYNCFS privilege gating Jimmy Zuber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260619170251.1154562-1-jamz@amazon.com \
--to=jamz@amazon.com \
--cc=fuse-devel@lists.linux.dev \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox