fix: drop ProtectClock= from the unit; it hides /dev/nvidia* from NVML - #6
Merged
Merged
Conversation
Under the systemd unit nvmlInit() failed with "Failed to initialize NVML: Unknown Error" while the same binary worked from a root shell. Bisecting the hardening directives with systemd-run --wait --pipe -p <directive> /usr/local/bin/nvfd list on Ubuntu 22.04.5 / systemd 249 / driver 595.84 (RTX 6000 Ada) passed every directive except ProtectClock=yes. systemd.exec(5): ProtectClock=yes implies DeviceAllow=char-rtc r, and "adding [DeviceAllow=] turns on DevicePolicy=closed by default". With a closed device policy the daemon cannot open /dev/nvidiactl or /dev/nvidia<N>, so NVML cannot reach the driver. Removing ProtectClock= costs nothing the daemon needs (it never touches the clock) and restores device access. Keeping ProtectClock= alongside explicit DeviceAllow= entries for the NVIDIA nodes would work too, but the set of nodes varies by GPU count and driver (nvidia-uvm has a dynamic major), so the simpler rule is preferred.
richardkiene
force-pushed
the
fix/unit-protectclock-blocks-nvidia-devices
branch
from
September 1, 2026 17:28
4cf6d87 to
27f3c0c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
systemctl start nvfdfails withFailed to initialize NVML: Unknown Erroron every attempt until the start limit parks the unit infailed, whilesudo nvfd list/sudo nvfd statusfrom a shell work.Cause
Bisecting the unit's hardening directives one at a time with
systemd-run --wait --pipe -p <directive> /usr/local/bin/nvfd liston Ubuntu 22.04.5 (systemd 249, driver 595.84, RTX 6000 Ada): every directive passed exceptProtectClock=yes.Per
systemd.exec(5),ProtectClock=yesimpliesDeviceAllow=char-rtc r, and adding anyDeviceAllow=turns onDevicePolicy=closed. With a closed device policy the daemon cannot open/dev/nvidiactlor/dev/nvidia<N>, so NVML cannot reach the driver.Fix
Remove
ProtectClock=(the daemon never touches the clock) and leave a comment in the unit explaining why it must not come back. Keeping it alongside explicitDeviceAllow=entries for the NVIDIA nodes would also work, but the node set varies with GPU count and driver (nvidia-uvmhas a dynamic major), so the simpler rule wins.Verified on host
ld-server01 (Ubuntu 22.04.5, systemd 249, driver 595.84):
systemd-run --wait --pipewith all 14 remaining hardening directives applied together (ProtectHome,ProtectSystem=strict+ReadWritePaths=/etc/nvfd,NoNewPrivileges,PrivateTmp,ProtectKernelTunables,ProtectKernelModules,ProtectControlGroups,MemoryDenyWriteExecute,RestrictRealtime,RestrictSUIDSGID,LockPersonality,RestrictNamespaces,RestrictAddressFamilies=AF_UNIX,ProtectHostname) runsnvfd listsuccessfully:Detected 1 GPU … GPU 0: NVIDIA RTX 6000 Ada Generation (1 fan). The same command with-p ProtectClock=yesalone fails withFailed to initialize NVML: Unknown Error.