Skip to content

WIP: Add TCG Opal disk unlock support - #2196

Draft
Sean-StarLabs wants to merge 2 commits into
linuxboot:masterfrom
StarLabsLtd:sean/heads-opal-qemu-20260826
Draft

WIP: Add TCG Opal disk unlock support#2196
Sean-StarLabs wants to merge 2 commits into
linuxboot:masterfrom
StarLabsLtd:sean/heads-opal-qemu-20260826

Conversation

@Sean-StarLabs

Copy link
Copy Markdown

Summary

  • add a Linux-ioctl backend to scan, query, unlock, and rollback TCG Opal global locking ranges as Admin1
  • run the unlock gate from init before normal, basic, or network boot scripts
  • make production enablement and backend selection immutable at build time
  • reject production board configurations that omit the required kernel OPAL support
  • optionally use coreboot's upstream OPAL S3 APMC v1 service
  • add host functional coverage and a deterministic QEMU control-flow fixture

The prompt completes before the backend starts. Heads opens and unlinks its mode-0600 password file before passing the anonymous file descriptor to the C helper, so credentials are not placed in command arguments, the environment, or a production Bash variable. Credential buffers and anonymous storage are cleared after use.

If a later disk, status check, or S3 handoff fails, Heads relocks disks already unlocked during that attempt. A rollback failure powers off instead of exposing an unlocked disk through recovery.

Functional validation

The host fixture exercised no-device and already-unlocked paths, successful unlock, wrong-password retry and exhaustion, cancellation, prompt failure after producing output, empty and oversized input, backend and S3 pre/post-unlock failures, rollback failure, malformed scan output, multiple disks, partial multi-disk rollback, post-unlock verification, and argv/environment/path secret checks.

The exact committed QEMU ROM completed the overlaid mock scan, mocked unlock and S3 handoff, confirmed the unlocked state, and entered detect_boot_device in that order. The fixture password and linked-password-file failure marker were absent from serial output.

QEMU does not emulate a TCG Opal device or the coreboot SMM service. Production OPAL ioctls, NVMe Security Receive, physical-address lookup, SMI handling, and S3 resume remain hardware validation. This PR remains Draft for that reason.

Board requirements

Production boards must use Linux 6.1 or later and enable CONFIG_BLK_SED_OPAL=y. Boards selecting CONFIG_HEADS_OPAL_S3_APMC_V1=y must also enable CONFIG_PROC_PAGE_MONITOR=y and run coreboot with the ABI merged through coreboot change 91045.

Add a kernel-ioctl-backed helper and an immutable gate before every normal, basic, or network boot script. Unlock each locked TCG Opal disk as Admin1.

Keep credentials out of arguments, the environment, and production Bash variables. Retain them only in anonymous file descriptors until every disk is ready so failures can relock earlier disks before recovery.

Optionally compile in coreboot's OPAL S3 APMC v1 service, and fail closed if setup or rollback cannot be completed.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Overlay deterministic prompt and disk backends for the pre-boot unlock gate, retries, failure rollback, S3 handoff requests, post-unlock verification, and secret transport without requiring an emulated Opal device.

Run the host fixture and build the QEMU board in CI. QEMU covers the Heads control flow; production OPAL ioctls, NVMe security commands, SMI handling, and S3 resume remain hardware-only paths.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Comment thread Makefile
$(INSTALL)/include/linux/limits.h \
$(build)/$(musl-cross-make_dir)/.build
@mkdir -p "$(dir $@)"
$(heads_cc) -Os -Wall -Wextra -Werror \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can this be built with Oz?

Comment thread util/heads-opal.c

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ideally, this would be into a modules/* where this project evolves on its own?

@tlaurion tlaurion left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

First quick review, will try to review thoroughly in the next days.

Will also need to update threat model, TCG had its bypasses before, so "trusting trust" kinda issues here

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.

2 participants