From a6ca1a573e1fd9474c6226412fb743b4ef7e3472 Mon Sep 17 00:00:00 2001 From: Jimmy Zuber Date: Thu, 20 Aug 2026 13:01:58 +0000 Subject: [PATCH] selftests/fuse: add test for FUSE_HAS_SYNCFS privilege gating Add a selftest that talks the raw FUSE protocol over /dev/fuse (rather than via libfuse, which negotiates INIT internally) so it can both choose whether to advertise FUSE_HAS_SYNCFS and directly observe whether a FUSE_SYNCFS opcode is forwarded by the kernel. Three cases are covered: T1: host-root mount, server sets FUSE_HAS_SYNCFS -> FUSE_SYNCFS must reach the server. T2: host-root mount, server does not opt in -> FUSE_SYNCFS must not be sent (back-compat). T3: server opts in but opened /dev/fuse without CAP_SYS_ADMIN while still in the initial user namespace -> FUSE_SYNCFS must be withheld. This is the case that distinguishes gating on the server's privilege from gating on the mount's user namespace. Signed-off-by: Jimmy Zuber Assisted-by: Claude:claude-opus-4-8 [Claude-Code] Signed-off-by: Miklos Szeredi --- tools/testing/selftests/filesystems/fuse/.gitignore | 1 + tools/testing/selftests/filesystems/fuse/Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/filesystems/fuse/.gitignore b/tools/testing/selftests/filesystems/fuse/.gitignore index fb51603fe419..b5b03db1118c 100644 --- a/tools/testing/selftests/filesystems/fuse/.gitignore +++ b/tools/testing/selftests/filesystems/fuse/.gitignore @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only fuse_mnt fusectl_test +test_syncfs write_extend_eof_test diff --git a/tools/testing/selftests/filesystems/fuse/Makefile b/tools/testing/selftests/filesystems/fuse/Makefile index 95a1ee947ca7..c2de8d225447 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_PROGS += write_extend_eof_test TEST_GEN_FILES := fuse_mnt