Skip to content

fix: drop ProtectClock= from the unit; it hides /dev/nvidia* from NVML - #6

Merged
richardkiene merged 1 commit into
mainfrom
fix/unit-protectclock-blocks-nvidia-devices
Sep 1, 2026
Merged

fix: drop ProtectClock= from the unit; it hides /dev/nvidia* from NVML#6
richardkiene merged 1 commit into
mainfrom
fix/unit-protectclock-blocks-nvidia-devices

Conversation

@richardkiene

@richardkiene richardkiene commented Sep 1, 2026

Copy link
Copy Markdown

Symptom

systemctl start nvfd fails with Failed to initialize NVML: Unknown Error on every attempt until the start limit parks the unit in failed, while sudo nvfd list / sudo nvfd status from 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 list on Ubuntu 22.04.5 (systemd 249, driver 595.84, RTX 6000 Ada): every directive passed except ProtectClock=yes.

Per systemd.exec(5), ProtectClock=yes implies DeviceAllow=char-rtc r, and adding any DeviceAllow= turns on DevicePolicy=closed. With a closed device policy the daemon cannot open /dev/nvidiactl or /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 explicit DeviceAllow= entries for the NVIDIA nodes would also work, but the node set varies with GPU count and driver (nvidia-uvm has 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 --pipe with 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) runs nvfd list successfully: Detected 1 GPU … GPU 0: NVIDIA RTX 6000 Ada Generation (1 fan). The same command with -p ProtectClock=yes alone fails with Failed to initialize NVML: Unknown Error.

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
richardkiene force-pushed the fix/unit-protectclock-blocks-nvidia-devices branch from 4cf6d87 to 27f3c0c Compare September 1, 2026 17:28
@richardkiene
richardkiene merged commit cf18544 into main Sep 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant