# SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (c) 2024-2026 Oracle. All Rights Reserved. # Author: Darrick J. Wong [Unit] Description=Self Healing of XFS Metadata for %f # Explicitly require the capabilities that this program needs ConditionCapability=CAP_SYS_ADMIN ConditionCapability=CAP_DAC_OVERRIDE # Must be a mountpoint ConditionPathIsMountPoint=%f RequiresMountsFor=%f [Service] Type=exec Environment=SERVICE_MODE=1 ExecCondition=/usr/libexec/xfsprogs/xfs_healer --supported %f ExecStart=/usr/libexec/xfsprogs/xfs_healer %f SyslogIdentifier=%N # Create the service underneath the healer background service slice so that we # can control resource usage. Slice=system-xfs_healer.slice # No realtime CPU scheduling RestrictRealtime=true # xfs_healer avoids pinning mounted filesystems by recording the file handle # for the provided mountpoint (%f) before opening the health monitor, after # which it closes the fd for the mountpoint. If repairs are needed, it will # reopen the mountpoint, resample the file handle, and proceed only if the # handles match. If the filesystem is unmounted, the daemon exits. If the # mountpoint moves, repairs will not be attempted against the wrong filesystem. # # Due to this resampling behavior, xfs_healer must see the same filesystem # mount tree inside the service container as outside, with the same ro/rw # state. BindPaths doesn't work on the paths that are made readonly by # ProtectSystem and ProtectHome, so it is not possible to set either option. # DynamicUser sets ProtectSystem, so that also cannot be used. We cannot use # BindPaths to bind the desired mountpoint somewhere under /tmp like xfs_scrub # does because that pins the mount. # # Regrettably, this leaves xfs_healer less hardened than xfs_scrub. # Surprisingly, this doesn't affect xfs_healer's score dramatically. DynamicUser=false ProtectSystem=false ProtectHome=no PrivateTmp=true PrivateDevices=true # Don't let healer complain about paths in /etc/projects that have been hidden # by our sandboxing. healer doesn't care about project ids anyway. InaccessiblePaths=-/etc/projects # No network access except for systemd service bus for initiating full scans PrivateNetwork=true ProtectHostname=true RestrictAddressFamilies=AF_UNIX 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 # 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=~@mount # xfs_healer needs these privileges to open the rootdir and monitor CapabilityBoundingSet=CAP_SYS_ADMIN CAP_DAC_OVERRIDE AmbientCapabilities=CAP_SYS_ADMIN CAP_DAC_OVERRIDE NoNewPrivileges=true # xfs_healer doesn't create files UMask=7777 # No access to hardware /dev files except for block devices ProtectClock=true DevicePolicy=closed [Install] WantedBy=multi-user.target # If someone tries to enable the template itself, translate that into enabling # this service on the root directory at systemd startup time. In the # initramfs, the udev rules in xfs_healer.rules run before systemd starts. DefaultInstance=-