From: "Darrick J. Wong" <djwong@kernel.org>
To: bschubert@ddn.com
Cc: linux-fsdevel@vger.kernel.org, bernd@bsbernd.com,
miklos@szeredi.hu, neal@gompa.dev, joannelkoong@gmail.com
Subject: Re: [PATCH 17/17] nullfs: support fuse systemd service mode
Date: Tue, 7 Apr 2026 17:11:57 -0700 [thread overview]
Message-ID: <20260408001157.GT6202@frogsfrogsfrogs> (raw)
In-Reply-To: <177457463428.1008428.6991907403668845476.stgit@frogsfrogsfrogs>
On Thu, Mar 26, 2026 at 06:29:12PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> This is the only example fuse server that exports a regular file instead
> of a directory tree. Port it to be usable as a systemd fuse service so
> that we can test that capability.
>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
> example/meson.build | 6 +++
> example/null.c | 33 +++++++++++++-
> example/nullfile.socket.in | 15 ++++++
> example/nullfile@.service | 102 ++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 154 insertions(+), 2 deletions(-)
> create mode 100644 example/nullfile.socket.in
> create mode 100644 example/nullfile@.service
>
>
> diff --git a/example/meson.build b/example/meson.build
> index 0a7cc3dbf31da4..c08a81747e68ae 100644
> --- a/example/meson.build
> +++ b/example/meson.build
> @@ -10,6 +10,12 @@ if not platform.endswith('bsd') and platform != 'dragonfly'
> # support mounting files, This is enforced in vfs_domount_first()
> # with the v_type != VDIR check.
> examples += [ 'null' ]
> +
> + if platform.endswith('linux')
> + configure_file(input: 'nullfile.socket.in',
> + output: 'nullfile.socket',
> + configuration: private_cfg)
> + endif
> endif
>
> single_file_examples = [ 'hello_ll' ]
> diff --git a/example/null.c b/example/null.c
> index ec41def40ed5c5..3e7e43f722a432 100644
> --- a/example/null.c
> +++ b/example/null.c
> @@ -17,15 +17,24 @@
> *
> * gcc -Wall null.c `pkg-config fuse3 --cflags --libs` -o null
> *
> + * Change the ExecStart line in nullfile@.service:
> + *
> + * ExecStart=/path/to/nullfile
> + *
> + * to point to the actual path of the nullfile binary.
> + *
> + * Finally, install the nullfile@.service and nullfile.socket files to the
> + * systemd service directory, usually /run/systemd/system.
Ok last rAmblIng email for now -- I've fixed the socket and service
name to be consistent with the server name, like it is for the other two
examples. Apparently Codex is better at noticing those details than I
am.
I also dropped the hello_ll.c changes because the service stuff more or
less only works on Linux. Nobody's porting systemd to BSD and there are
no inetd clones that support AF_UNIX, so that's a huge barrier to any of
it working anywhere else.
(I wouldn't be opposed to someone contributing support, but I'm not a
BSD/Windows/Devuan user)
--D
> + *
> * ## Source code ##
> * \include passthrough_fh.c
> */
>
> -
> -#define FUSE_USE_VERSION 31
> +#define FUSE_USE_VERSION FUSE_MAKE_VERSION(3, 19)
>
> #include <fuse.h>
> #include <fuse_lowlevel.h>
> +#include <fuse_service.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> @@ -117,6 +126,26 @@ int main(int argc, char *argv[])
> struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
> struct fuse_cmdline_opts opts;
> struct stat stbuf;
> + struct fuse_service *service = NULL;
> + int ret;
> +
> + if (fuse_service_accept(&service) != 0)
> + return 1;
> +
> + if (fuse_service_accepted(service)) {
> + if (fuse_service_append_args(service, &args) != 0)
> + return 1;
> + if (fuse_service_finish_file_requests(service) != 0)
> + return 1;
> +
> + fuse_service_expect_mount_mode(service, S_IFREG);
> +
> + ret = fuse_service_main(service, args.argc, args.argv,
> + &null_oper, NULL);
> +
> + fuse_opt_free_args(&args);
> + return fuse_service_exit(ret);
> + }
>
> if (fuse_parse_cmdline(&args, &opts) != 0)
> return 1;
> diff --git a/example/nullfile.socket.in b/example/nullfile.socket.in
> new file mode 100644
> index 00000000000000..23e57a25f2eb93
> --- /dev/null
> +++ b/example/nullfile.socket.in
> @@ -0,0 +1,15 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +#
> +# Copyright (C) 2026 Oracle. All Rights Reserved.
> +# Author: Darrick J. Wong <djwong@kernel.org>
> +[Unit]
> +Description=Socket for nullfile Service
> +
> +[Socket]
> +ListenSequentialPacket=@FUSE_SERVICE_SOCKET_DIR_RAW@/nullfile
> +Accept=yes
> +SocketMode=0220
> +RemoveOnStop=yes
> +
> +[Install]
> +WantedBy=sockets.target
> diff --git a/example/nullfile@.service b/example/nullfile@.service
> new file mode 100644
> index 00000000000000..665f8d4226ff49
> --- /dev/null
> +++ b/example/nullfile@.service
> @@ -0,0 +1,102 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +#
> +# Copyright (C) 2026 Oracle. All Rights Reserved.
> +# Author: Darrick J. Wong <djwong@kernel.org>
> +[Unit]
> +Description=nullfile Sample Fuse Service
> +
> +# Don't leave failed units behind, systemd does not clean them up!
> +CollectMode=inactive-or-failed
> +
> +[Service]
> +Type=exec
> +ExecStart=/path/to/null
> +
> +# Try to capture core dumps
> +LimitCORE=infinity
> +
> +SyslogIdentifier=%N
> +
> +# No realtime CPU scheduling
> +RestrictRealtime=true
> +
> +# Don't let us see anything in the regular system, and don't run as root
> +DynamicUser=true
> +ProtectSystem=strict
> +ProtectHome=true
> +PrivateTmp=true
> +PrivateDevices=true
> +PrivateUsers=true
> +
> +# No network access
> +PrivateNetwork=true
> +ProtectHostname=true
> +RestrictAddressFamilies=none
> +IPAddressDeny=any
> +
> +# Don't let the program mess with the kernel configuration at all
> +ProtectKernelLogs=true
> +ProtectKernelModules=true
> +ProtectKernelTunables=true
> +ProtectControlGroups=true
> +ProtectProc=invisible
> +RestrictNamespaces=true
> +RestrictFileSystems=
> +
> +# Hide everything in /proc, even /proc/mounts
> +ProcSubset=pid
> +
> +# Only allow the default personality Linux
> +LockPersonality=true
> +
> +# No writable memory pages
> +MemoryDenyWriteExecute=true
> +
> +# Don't let our mounts leak out to the host
> +PrivateMounts=true
> +
> +# Restrict system calls to the native arch and only enough to get things going
> +SystemCallArchitectures=native
> +SystemCallFilter=@system-service
> +SystemCallFilter=~@privileged
> +SystemCallFilter=~@resources
> +
> +SystemCallFilter=~@clock
> +SystemCallFilter=~@cpu-emulation
> +SystemCallFilter=~@debug
> +SystemCallFilter=~@module
> +SystemCallFilter=~@reboot
> +SystemCallFilter=~@swap
> +
> +SystemCallFilter=~@mount
> +
> +# libfuse io_uring wants to pin cores and memory
> +SystemCallFilter=mbind
> +SystemCallFilter=sched_setaffinity
> +
> +# Leave a breadcrumb if we get whacked by the system call filter
> +SystemCallErrorNumber=EL3RST
> +
> +# Log to the kernel dmesg, just like an in-kernel filesystem driver
> +StandardOutput=append:/dev/ttyprintk
> +StandardError=append:/dev/ttyprintk
> +
> +# Run with no capabilities at all
> +CapabilityBoundingSet=
> +AmbientCapabilities=
> +NoNewPrivileges=true
> +
> +# We don't create files
> +UMask=7777
> +
> +# No access to hardware /dev files at all
> +ProtectClock=true
> +DevicePolicy=closed
> +
> +# Don't mess with set[ug]id anything.
> +RestrictSUIDSGID=true
> +
> +# Don't let OOM kills of processes in this containment group kill the whole
> +# service, because we don't want filesystem drivers to go down.
> +OOMPolicy=continue
> +OOMScoreAdjust=-1000
>
>
prev parent reply other threads:[~2026-04-08 0:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 1:24 [PATCHSET v3] libfuse: run fuse servers as a contained service Darrick J. Wong
2026-03-27 1:25 ` [PATCH 01/17] Refactor mount code / move common functions to mount_util.c Darrick J. Wong
2026-03-27 1:25 ` [PATCH 02/17] mount_service: add systemd/inetd socket service mounting helper Darrick J. Wong
2026-03-30 20:44 ` Bernd Schubert
2026-03-30 21:37 ` Darrick J. Wong
2026-04-07 23:39 ` Darrick J. Wong
2026-03-27 1:25 ` [PATCH 03/17] mount_service: create high level fuse helpers Darrick J. Wong
2026-03-30 19:37 ` Bernd Schubert
2026-03-30 20:30 ` Darrick J. Wong
2026-03-30 20:51 ` Bernd Schubert
2026-03-30 21:09 ` Darrick J. Wong
2026-03-27 1:25 ` [PATCH 04/17] mount_service: use the new mount api for the mount service Darrick J. Wong
2026-03-30 21:06 ` Bernd Schubert
2026-03-30 21:18 ` Darrick J. Wong
2026-03-30 21:40 ` Bernd Schubert
2026-03-30 21:47 ` Darrick J. Wong
2026-03-27 1:26 ` [PATCH 05/17] mount_service: update mtab after a successful mount Darrick J. Wong
2026-04-07 23:42 ` Darrick J. Wong
2026-03-27 1:26 ` [PATCH 06/17] util: hoist the fuse.conf parsing code Darrick J. Wong
2026-04-07 23:40 ` Darrick J. Wong
2026-03-27 1:26 ` [PATCH 07/17] util: fix checkpatch complaints in fuser_conf.[ch] Darrick J. Wong
2026-03-27 1:26 ` [PATCH 08/17] mount_service: read fuse.conf to enable allow_other for unprivileged mounts Darrick J. Wong
2026-03-27 1:27 ` [PATCH 09/17] util: hoist the other non-root user limits Darrick J. Wong
2026-03-27 1:27 ` [PATCH 10/17] util: fix more checkpatch complaints in fuser_conf.[ch] Darrick J. Wong
2026-03-27 1:27 ` [PATCH 11/17] mount_service: use over the other non-root user checks Darrick J. Wong
2026-04-07 23:47 ` Darrick J. Wong
2026-03-27 1:27 ` [PATCH 12/17] mount.fuse3: integrate systemd service startup Darrick J. Wong
2026-04-07 23:56 ` Darrick J. Wong
2026-03-27 1:28 ` [PATCH 13/17] mount_service: allow installation as a setuid program Darrick J. Wong
2026-03-27 1:28 ` [PATCH 14/17] example/service_ll: create a sample systemd service fuse server Darrick J. Wong
2026-04-08 0:09 ` Darrick J. Wong
2026-03-27 1:28 ` [PATCH 15/17] example/service: create a sample systemd service for a high-level " Darrick J. Wong
2026-03-27 1:28 ` [PATCH 16/17] example/hello_ll: port to single-file common code Darrick J. Wong
2026-03-27 1:29 ` [PATCH 17/17] nullfs: support fuse systemd service mode Darrick J. Wong
2026-04-08 0:11 ` Darrick J. Wong [this message]
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=20260408001157.GT6202@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=bernd@bsbernd.com \
--cc=bschubert@ddn.com \
--cc=joannelkoong@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=neal@gompa.dev \
/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