Repository navigation
Harden ownership of installed sleep hooks - #10425
Merged
ryanrhughes merged 2 commits intoSep 6, 2026
Merged
Conversation
acrogenesis
force-pushed
the
security/root-owned-sleep-hooks
branch
6 times, most recently
from
September 6, 2026 20:06
3c8de3f to
34b6fbc
Compare
Publish privileged sleep-hook and hybrid-GPU files through root-owned replacement inodes, repair unsafe existing copies while preserving administrator customizations, and keep partial hibernation setup retryable. Reported-by: Roger Piñol <rogerpicar@gmail.com>
acrogenesis
force-pushed
the
security/root-owned-sleep-hooks
branch
from
September 6, 2026 20:36
34b6fbc to
feb0557
Compare
acrogenesis
marked this pull request as ready for review
September 6, 2026 20:50
Member
Author
|
Duplicate and supersession audit This PR supersedes the sleep-hook installation and executable-mode work in:
It also incorporates the system-sleep packaging documentation correction proposed in #7720. #4793 partially overlaps the force-igpu behavior, but its separate NVIDIA service changes are outside this PR and should be evaluated independently. The caller-controlled source-root work in #9317 and #9471, and the cardwire redesign in #9332, are related but distinct and are not claimed as superseded here. |
ryanrhughes
added a commit
that referenced
this pull request
Sep 8, 2026
…hooks Harden ownership of installed sleep hooks (cherry picked from commit c82a083) (cherry picked from commit 3b5f4446f6022ad056fc06d320d157075841cde7)
ryanrhughes
added a commit
that referenced
this pull request
Sep 8, 2026
…hooks Harden ownership of installed sleep hooks (cherry picked from commit c82a083) (cherry picked from commit 3b5f4446f6022ad056fc06d320d157075841cde7)
This was referenced Sep 10, 2026
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.
Summary
Why
The setup commands used
cp -pfrom$OMARCHY_PATHinto privileged systemd locations. When run from a user-owned source tree, that preserved the desktop user's ownership on files later consumed as root. Merely changing ownership in place would still trust potentially modified contents and would not invalidate a writer's already-open file descriptor, so the repair publishes a new root-owned inode instead.The migration leaves an entry unchanged when its complete path and symlink resolution chain are root-controlled and neither group nor other users can write it. Ordinary absent targets beneath a searchable root-controlled parent need no elevation; metadata hidden beneath a root-only hierarchy is inspected with privilege. If the privileged probe can search the protected parent and the target is absent, the dangling administrator symlink is preserved rather than mistaken for unsafe content. Encountering a missing component does not end validation: the remaining lexical suffix is normalized, and real metadata checks resume if
..escapes the missing subtree. Exact current and fingerprinted legacy installer artifacts are replaced directly. Unknown unsafe files and symlinks are first copied under root-only/var/lib/omarchy/migrations/1788662350-system-sleep/, outside systemd's active paths, and their active locations are then repaired.The released keyboard hook was normally copied from the root-owned package tree as mode 0644. Because the current hook also gains compound-sleep phase handling here, its contents no longer match that released copy. The migration fingerprints the exact released bytes and replaces them with the current executable hook, even if the old copy is otherwise root-controlled or was manually made executable. Safe noncanonical administrator hooks remain untouched.
Replacing the supergfxd drop-in and reloading systemd are treated as one repair. A fixed root-owned marker is created before replacement and removed only after
daemon-reloadsucceeds, so a failed or interrupted run cannot later complete while systemd retains stale configuration in memory.The executable
force-igpuhook records a root-controlled runtime marker during pre-sleep only when the cycle begins in configured Integrated mode. Post-sleep consumes that marker instead of consulting the mutable supergfxd mode. This keeps Hybrid and unconfigured machines inert while allowing hibernate to switch temporarily to persisted Vfio mode and still restore Integrated afterward.supergfxctl 5.2.7 completes staged mode changes asynchronously after accepting a request. The hook therefore polls
supergfxctl -gwith a bounded timeout after each request and advances only after observing the requested committed mode. Integrated restore intent is removed only after that confirmation; a failed or timed-out transition retains the marker for a later retry.For suspend-then-hibernate, systemd keeps the overall operation in the hook argument while exposing each
suspendorhibernatephase throughSYSTEMD_SLEEP_ACTION. Both hooks now use that phase-specific value, with the argument as a compatibility fallback, so the dGPU detaches and the keyboard backlight turns off before the compound operation enters hibernation.This intent model lets the migration install a trusted executable hook without depending on a transient
supergfxctlquery, and lets the toggle publish both supporting files before switching both configuration values in one rewrite. Failed setup therefore leaves the previous GPU mode intact and is safe to retry.The keyboard hook is published before the resume configuration marker. If publication fails, a normal rerun reaches the failed step instead of exiting as already configured.
Testing
bash test/shell.d/system-sleep-ownership-migration-test.shTMPDIRinvocation of the focused migration testbash test/shell.d/unowned-system-paths-test.shbash test/shell.d/hybrid-gpu-test.sh./test/cli./test/shellreaches and passes every changed-area test; eight unrelated baseline/environment test files still fail.Coverage includes retained-writer inode replacement, exact current and released 0644 artifact activation, refresh of recognized legacy bytes already at the final mode, unknown-content quarantine, idempotency, persisted daemon-reload failure and interruption recovery, non-root-group administrator files, protected and dangling symlink chains, full dangling-link suffix normalization, protected dangling targets, direct and indirect user-controlled symlinks, daemon-unavailable GPU repair, Hybrid and missing-config inert behavior, delayed asynchronous GPU transitions, failed Integrated restoration with retained intent and successful retry, direct suspend and hibernate behavior, both suspend-then-hibernate phases, realistic Vfio persistence followed by confirmed Integrated restoration, keyboard-backlight handling during compound hibernation, failure-safe setup ordering, and non-default
TMPDIRportability.