[PATCH 10/13] mount_service: allow installation as a setuid program

Darrick J. Wong
2026-04-09T22:23:09Z

Allow installation of the mount service helper as a setuid program so
that regular users can access containerized filesystem drivers.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
README.md | 3 +++
test/ci-build.sh | 7 +++++++
util/install_helper.sh | 6 ++++++
util/meson.build | 3 ++-
4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index bcf1210e6a23fa..b692a6f6915635 100644
--- a/README.md
+++ b/README.md
@@ -98,6 +98,9 @@ Security implications

The *fusermount3* program is installed setuid root. This is done to
allow normal users to mount their own filesystem implementations.
+If built, the *fuservicemount3* program will also be installed setuid
+root so that normal users can access containerized filesystem
+implementations.

To limit the harm that malicious users can do this way, *fusermount3*
enforces the following limitations:
diff --git a/test/ci-build.sh b/test/ci-build.sh
index 8b019a0b5e52c1..6fddcb6bc42d72 100755
--- a/test/ci-build.sh
+++ b/test/ci-build.sh
@@ -60,11 +60,18 @@ non_sanitized_build()

# libfuse will first try the install path and then system defaults
sudo chmod 4755 ${PREFIX_DIR}/bin/fusermount3
+ test -x "${PREFIX_DIR}/sbin/fuservicemount3" && \
+ sudo chmod 4755 ${PREFIX_DIR}/sbin/fuservicemount3

# also needed for some of the tests
sudo chown root:root util/fusermount3
sudo chmod 4755 util/fusermount3

+ if [ -x util/fuservicemount3 ]; then
+ sudo chown root:root util/fuservicemount3
+ sudo chmod 4755 util/fuservicemount3
+ fi
+
${TEST_CMD}
popd
rm -fr build-${CC}
diff --git a/util/install_helper.sh b/util/install_helper.sh
index 76f2b47fe6c8f9..1c076739b8bfd8 100755
--- a/util/install_helper.sh
+++ b/util/install_helper.sh
@@ -11,6 +11,7 @@ bindir="$2"
udevrulesdir="$3"
useroot="$4"
initscriptdir="$5"
+sbindir="$6"

# Both sysconfdir and bindir are absolute paths (since they are joined
# with --prefix in meson.build), but need to be interpreted relative
@@ -31,6 +32,11 @@ if $useroot; then
chown root:root "${DESTDIR}${bindir}/fusermount3"
chmod u+s "${DESTDIR}${bindir}/fusermount3"

+ if [ -x "${DESTDIR}${sbindir}/fuservicemount3" ]; then
+ chown root:root "${DESTDIR}${sbindir}/fuservicemount3"
+ chmod u+s "${DESTDIR}${sbindir}/fuservicemount3"
+ fi
+
if test ! -e "${DESTDIR}/dev/fuse"; then
mkdir -p "${DESTDIR}/dev"
mknod "${DESTDIR}/dev/fuse" -m 0666 c 10 229
diff --git a/util/meson.build b/util/meson.build
index 85b54d5d322dcb..e15dd9bbb0c486 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -46,4 +46,5 @@ meson.add_install_script('install_helper.sh',
join_paths(get_option('prefix'), get_option('bindir')),
udevrulesdir,
'@0@'.format(get_option('useroot')),
- get_option('initscriptdir'))
+ get_option('initscriptdir'),
+ join_paths(get_option('prefix'), get_option('sbindir')))