Skip to content

Restore early Thunderbolt authorization for LUKS unlock - #7258

Open
chriopter wants to merge 4 commits into
omacom:quattrofrom
chriopter:fix/thunderbolt-autoauth-luks
Open

chriopter wants to merge 4 commits into
omacom:quattrofrom
chriopter:fix/thunderbolt-autoauth-luks

Conversation

@chriopter

@chriopter chriopter commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Restore early authorization for Thunderbolt devices already connected at boot, allowing keyboards behind Thunderbolt/USB-C displays and docks to work at the LUKS prompt.

Omarchy already includes the Thunderbolt module in its UKI. The missing piece is authorizing the attached endpoint before encrypt asks for the disk password. Quattro's packaged omarchy_hooks.conf replaces HOOKS, so the machine-local hook previously used for this is no longer included.

Changes

  • Ship the small thunderbolt_autoauth mkinitcpio install and runtime hooks.
  • Run the hook immediately before encrypt.
  • Authorize only endpoints present during early boot; skip domains and host routers.
  • Add no delay on systems without an endpoint awaiting authorization.
  • Rebuild existing UKIs once through an idempotent migration.

Security

This treats every Thunderbolt endpoint already connected during early boot as trusted. It does not authorize devices connected after the hook has run. This is the same trust model discussed in #934: entering the LUKS passphrase is considered implicit trust in the hardware attached at boot.

Relation to #934

This is the focused early-boot part of #934 and supersedes that proposal.

#934 also changed userspace hotplug authorization, installed bolt, and added Hyprland ghost-display handling. None of those changes are included here. Omarchy now already ships the Thunderbolt module, so this PR only restores the missing authorization required for USB keyboards behind a Thunderbolt dock at LUKS unlock.

The hook has also been updated for Quattro: it is part of the packaged hook order instead of editing /etc/mkinitcpio.conf, which omarchy_hooks.conf now overrides. Related: #6876.

Testing

  • Verifies the hook occurs exactly once immediately before encrypt.
  • Verifies only attached, unauthorized endpoints are authorized.
  • Verifies existing systems rebuild their UKI exactly once.
  • Confirmed on hardware with a NuPhy keyboard connected through an Apple Thunderbolt/USB hub: lsinitcpio reports udev plymouth keymap thunderbolt_autoauth encrypt, and the keyboard works at the LUKS prompt.

Fixes #10453

Copilot AI balanced review requested due to automatic review settings August 17, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an initramfs hook to auto-authorize Thunderbolt devices early in boot (before encrypt) so attached USB peripherals work at the encrypted root prompt, plus a migration to rebuild the initramfs/UKI and a shell test to validate behavior.

Changes:

  • Insert thunderbolt_autoauth into the mkinitcpio HOOKS sequence immediately before encrypt.
  • Add mkinitcpio install + runtime hook to authorize connected Thunderbolt endpoints early in initramfs.
  • Add a migration + shell test to validate hook ordering, hook behavior, and one-time rebuild behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/shell.d/thunderbolt-autoauth-test.sh Adds an integration-style shell test covering hooks ordering, runtime authorization behavior, and migration one-time rebuild behavior.
migrations/1786961462.sh Adds a migration that triggers a rebuild when the hook is present/configured and records a marker to avoid repeated rebuilds.
etc/mkinitcpio.conf.d/omarchy_hooks.conf Updates mkinitcpio hook ordering to run Thunderbolt authorization before encrypt.
etc/initcpio/install/thunderbolt_autoauth Adds mkinitcpio install hook to include the runtime hook in initramfs.
etc/initcpio/hooks/thunderbolt_autoauth Adds initramfs runtime hook that authorizes attached Thunderbolt endpoints (and conditionally delays to let topology settle).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread migrations/1786961462.sh Resolved
Comment thread migrations/1786961462.sh Resolved
Comment thread etc/initcpio/hooks/thunderbolt_autoauth Resolved
Comment thread etc/initcpio/hooks/thunderbolt_autoauth Resolved
@chriopter

Copy link
Copy Markdown
Contributor Author

In my case, a NuPhy keyboard is connected to my Studio Display, which is connected to my Beelink SER8 via Thunderbolt. Without early authorization, I can’t enter the LUKS passphrase.

Copilot AI review requested due to automatic review settings August 17, 2026 11:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (5)

migrations/1786961462.sh:14

  • This script has no shebang and doesn’t enable strict mode, which makes its runtime behavior dependent on how the migration runner executes it and can mask failures. Add an explicit interpreter line (e.g., bash) and enable set -euo pipefail (or the project’s standard for migrations) near the top so failures in rebuild/marker creation are reliably surfaced.
echo "Rebuild the initramfs with early Thunderbolt authorization"

hooks_conf="${OMARCHY_THUNDERBOLT_HOOKS_CONF:-/etc/mkinitcpio.conf.d/omarchy_hooks.conf}"
install_hook="${OMARCHY_THUNDERBOLT_INSTALL_HOOK:-/etc/initcpio/install/thunderbolt_autoauth}"
runtime_hook="${OMARCHY_THUNDERBOLT_RUNTIME_HOOK:-/etc/initcpio/hooks/thunderbolt_autoauth}"
rebuild_marker="${OMARCHY_THUNDERBOLT_REBUILD_MARKER:-/var/lib/omarchy/migrations/1786961462}"

omarchy-cmd-present limine-mkinitcpio || exit 0
[[ -f $hooks_conf && -f $install_hook && -f $runtime_hook ]] || exit 0
grep -q ' thunderbolt_autoauth encrypt' "$hooks_conf" || exit 0
[[ ! -e $rebuild_marker ]] || exit 0

sudo limine-mkinitcpio
sudo install -Dm644 /dev/null "$rebuild_marker"

migrations/1786961462.sh:1

  • The script prints a rebuild message even when it immediately exits due to unmet prerequisites (command missing, hook files missing, marker present, etc.). To avoid misleading/noisy logs, move the echo to after the exit-guards (right before sudo limine-mkinitcpio), or make the message conditional on actually performing the rebuild.
echo "Rebuild the initramfs with early Thunderbolt authorization"

migrations/1786961462.sh:11

  • The script prints a rebuild message even when it immediately exits due to unmet prerequisites (command missing, hook files missing, marker present, etc.). To avoid misleading/noisy logs, move the echo to after the exit-guards (right before sudo limine-mkinitcpio), or make the message conditional on actually performing the rebuild.
omarchy-cmd-present limine-mkinitcpio || exit 0
[[ -f $hooks_conf && -f $install_hook && -f $runtime_hook ]] || exit 0
grep -q ' thunderbolt_autoauth encrypt' "$hooks_conf" || exit 0
[[ ! -e $rebuild_marker ]] || exit 0

etc/initcpio/hooks/thunderbolt_autoauth:36

  • The 2>/dev/null here may not suppress errors from the redirection itself (opening/writing $authorized), depending on shell redirection evaluation order. If the goal is to keep early-boot output clean, redirect stderr in a way that also covers redirection failures (e.g., place 2>/dev/null before the output redirection, or group the write and redirect the group).
    echo 1 > "$authorized" 2>/dev/null

migrations/1786961462.sh:11

  • These [[ ... ]] checks use unquoted variables. While [[ avoids word-splitting in many cases, quoting is still the safer and more consistent approach (especially for paths) and prevents surprising behavior if any value contains whitespace or glob characters.
[[ -f $hooks_conf && -f $install_hook && -f $runtime_hook ]] || exit 0
grep -q ' thunderbolt_autoauth encrypt' "$hooks_conf" || exit 0
[[ ! -e $rebuild_marker ]] || exit 0

@omarchybot omarchybot added bug Something isn't working compatibility Make Omarchy work better on everything! labels Sep 27, 2026
dhh and others added 2 commits September 28, 2026 06:34
omacom#934's installer copied its hook to /etc/initcpio/{hooks,install}/thunderbolt_autoauth, unowned by any package. omarchy-settings ships etc/ wholesale, so owning those same paths makes pacman refuse the whole upgrade with "exists in filesystem" on every machine that ran it — exactly the machines this change is for. Under an omarchy- name the old files stay inert, since omarchy_hooks.conf no longer lists them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arent

The kernel refuses to authorize a device until its parent is authorized, and route names are hex, so the glob visits 0-103 before its parent 0-3. The single pass left that device unauthorized with the error suppressed, and a keyboard behind it dead at the LUKS prompt. Passes now repeat until one authorizes nothing; each success flips a device to 1, so the loop ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 56de916 against quattro, including two commits pushed to this branch (below). A second opinion came from Codex Medium.

What ran, on a disposable Omarchy VM with no Thunderbolt hardware:

  • ./test/cli passed. The full shell suite passed 180 of 181 files. The one failure, screenshot-sanity-test.sh, comes from this branch's older copy of that test, which still calls grim. It passes on current quattro, and nothing here touches it.
  • The runtime hook ran under the initramfs's own busybox ash against a fake sysfs tree. It left host routers alone, authorized pending endpoints, added the 2s delay only when something was pending, and returned at once when nothing was.
  • mkinitcpio built a real image with the hook. lsinitcpio -a shows it running immediately before encrypt.
  • Not reproduced: the VM has no Thunderbolt controller, so the fix itself (a keyboard behind a dock working at the LUKS prompt) has not been seen to work by anyone but the author. Early thunderbolt module removes firmware-provided dock USB before the LUKS prompt #10453 reports the same symptom on a Dell WD19TB. @davidisgeek, if you are willing to test this commit, it is reversible. From a checkout of 56de916, run sudo install -Dm644 etc/initcpio/hooks/omarchy-thunderbolt-autoauth /etc/initcpio/hooks/omarchy-thunderbolt-autoauth and the same for etc/initcpio/install/omarchy-thunderbolt-autoauth. Then add a drop-in /etc/mkinitcpio.conf.d/zz-thunderbolt-test.conf containing HOOKS=(${HOOKS[@]/#encrypt/omarchy-thunderbolt-autoauth encrypt}) and run sudo limine-mkinitcpio. To undo it, delete those three files and rebuild.

Pushed to this branch:

  • 93b97dd renames the hook to omarchy-thunderbolt-autoauth. omarchy-settings copies etc/ into the package wholesale, so shipping /etc/initcpio/{hooks,install}/thunderbolt_autoauth would make those paths package-owned. Add thunderbolt / USB-C display + dock compatibility #934's installer wrote exactly those paths, unowned, on the machines that ran it. On the VM, pacman refused the whole transaction with exists in filesystem ("no packages were upgraded"). Under the new name those old files stay inert. A test now requires every hook shipped under etc/initcpio to carry the omarchy- prefix.
  • 56de916 authorizes a daisy-chained device behind a parent that sorts after it. The kernel's tb_domain_approve_switch returns -EINVAL until the parent is authorized, and route names are hex, so the glob visits 0-103 before its parent 0-3. The single pass left that device unauthorized, with the error suppressed. Passes now repeat until one authorizes nothing, and a test that makes the fake sysfs refuse child-first writes fails against the old single pass.

Open, not changed here:

  • The first scan is a one-shot check. If the dock has not finished enumerating when the hook runs, it sees nothing pending and returns without authorizing. udev has settled by then, but Thunderbolt enumeration is asynchronous. A bounded rescan would close this, but without hardware to prove it I have not pushed one.

For the maintainer: this authorizes every Thunderbolt endpoint attached at boot, before the disk is unlocked, on every install. That replaces the user security level's explicit approval for anything plugged in at power-on. On machines whose domain reports iommu_dma_protection=0, it gives such a device PCIe access before unlock. The reporter of #10453 argued against exactly this, and #11874 and #12510 move toward requiring approval. Narrower options include opt-in, gating on iommu_dma_protection, or authorizing only an enrolled dock. Which trust model Omarchy wants is your call.

Codex Medium raised the ordering defect and the enumeration race on its own, and agreed on the pacman conflict and the trust-model question. It reviewed both pushed commits and found nothing wrong with them. It can read this session's work, so its independence is not guaranteed. I did not act on its point that the migration's literal grep is brittle: that grep reads the packaged omarchy_hooks.conf, and on a machine where someone edited that file, their HOOKS rightly win.

This waits on the maintainer's decision about the trust model, and on a hardware confirmation.

@davidisgeek

Copy link
Copy Markdown

Tested commit 56de916c7f05c0e8405f038ca5518789591cb3cc successfully on real hardware.

System:

  • GMKtec NucBox K8 Plus, Ryzen 7 8845HS
  • Dell WD19TB Thunderbolt 3 dock
  • Omarchy 4.0.3-1
  • Kernel 7.2.3-arch1-3
  • Thunderbolt domain: security=user, bootacl=0/0, iommu_dma_protection=0

I installed the two omarchy-thunderbolt-autoauth files from this commit, inserted the hook immediately before encrypt, rebuilt the UKI, and verified the hook ordering in the image.

Results:

  • Warm reboot: dock keyboard worked at the LUKS prompt; dock displays remained visible; no perceptible delay.
  • Full shutdown/cold boot: dock keyboard worked at the LUKS prompt; dock displays remained visible; no perceptible delay.

The cold-boot journal shows the firmware-provided WD19TB xHCI controller being removed at 18.139s, returning at 18.156s, and its keyboard/mouse enumerating by approximately 18.172s. Plymouth started at 19.170s, while userspace boltd did not start until 20.258s.

The warm-boot sequence was similar: the controller was removed at 19.408s, returned at 19.425s, and dock input enumerated by approximately 19.44s. Plymouth started at 20.411s, and boltd started at 21.505s.

So on this hardware the hook authorized the dock and restored its USB input before Plymouth/LUKS on both warm and cold boot, independently of userspace boltd. I did not encounter the one-shot enumeration race mentioned above.

@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Sep 30, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you, @davidisgeek. Your test is the hardware confirmation this was waiting on. It covers 56de916, the current head: on the WD19TB from #10453, the dock keyboard worked at the LUKS prompt on both warm and cold boot. The pull request is now labelled verified on that basis, and it now says it fixes #10453, so that issue closes only if this merges.

Nothing was pushed and nothing was re-run on a worker: the head has not moved since the last review, and it still merges cleanly into current quattro. I checked the drift since the fork point. omarchy_hooks.conf has not changed on quattro, and the migration runner tracks a marker for each file, so this migration's older timestamp will not be skipped.

Codex Medium reviewed the confirmation and the diff again. It agreed that the confirmation shows the symptom fixed on that hardware, and it found no new defect. It can read this session's work, so its independence is not guaranteed. It made two points of its own:

The label is verified and not ready for two reasons. The branch's older copy of screenshot-sanity-test.sh still fails on the worker suite, and would pass after a merge from quattro. More importantly, this waits on the maintainer's decision about the trust model: authorizing every Thunderbolt device attached at boot, before unlock, on every install, and how that sits beside #11874.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 10, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

The head is still 56de916, but this no longer merges into quattro, and two things that landed there change what it would do. The verified label came off when the conflict appeared. I have not resolved the conflict, because the resolution depends on a decision only the maintainer can make. Nothing was pushed and nothing ran on a worker; this re-review read the branch against current quattro (0b9dace).

The conflict. e1b0e5e (#14431) moved the HOOKS baseline out of omarchy_hooks.conf and into a new 00-omarchy-hooks.conf, with one case per platform. Mechanically, the port would put omarchy-thunderbolt-autoauth before encrypt in that file's default busybox case and retarget both migrations/1786961462.sh and test/shell.d/thunderbolt-autoauth-test.sh at it. Without the retargeting, the migration's grep on omarchy_hooks.conf finds nothing and silently skips the rebuild. The Apple Silicon case boots a systemd initramfs, so a run_hook script cannot run there. That case stays as it is.

The policy. #11874 merged into quattro on 9 October. It makes Thunderbolt accessories require approval through Bolt by default, and migration 1790344599 turns that on for existing installs. This hook runs before Bolt, and it writes authorized=1 for every attached endpoint without consulting #11874's trust list. A device trusted there stays trusted. An unknown device plugged in at power-on gets PCIe access before unlock, and Omarchy's policy service leaves it that way:

  • tb_snapshot (install/helpers/thunderbolt-policy.sh:156) warns about an authorized, untrusted device only when Bolt flags it boot. Bolt takes that flag from the sysfs boot attribute, which is set only for devices the firmware authorized. A device this hook authorized gets no warning.
  • No approval prompt appears either, because install/helpers/thunderbolt-review.sh:135 skips devices that are already authorized.
  • Reconciliation (thunderbolt-policy.sh:283–304) restores trusted devices, but it never deauthorizes one.
  • The optional Thunderbolt at Boot setting clears the firmware allowlists, and it tells the user up front that trusted Thunderbolt keyboards may not work at disk unlock. This hook would authorize those devices again in the initramfs, which undoes that choice.

In short, porting it as it stands would ship a default that overrides the default quattro just adopted, with no warning to the user.

Options for the maintainer:

  • Run the hook only when Thunderbolt approval is turned off. This is the smallest change.
  • Authorize at unlock only devices in the trust list. That would keep an approved dock working, but the initramfs would need a copy of the trust list and a way to keep it current. Secure-mode trust also involves keys.
  • Drop this PR. Require approval for new USB and Thunderbolt devices by default #11874 already accepts that a Thunderbolt keyboard may not work at the LUKS prompt.

The rest of the earlier findings stand. On the WD19TB from #10453, @davidisgeek's confirmation still shows the hook fixing the symptom at this head. The change is the right size for the problem. The one-shot first scan can still miss a dock that has not finished enumerating.

Codex Medium reviewed the same questions. It agreed with the analysis and the recommendation not to port mechanically. It can read this session's work, so its independence is not guaranteed. It added three points of its own: the boot flag comes from the sysfs attribute, so the ordinary outcome is silent; the migration would silently skip a mechanical port; and the hook would undo Thunderbolt at Boot.

This waits on the maintainer's decision about how this should coexist with #11874. Once that is decided, @chriopter or I can port it to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Early thunderbolt module removes firmware-provided dock USB before the LUKS prompt

5 participants